How to connect smart devices to the Amazon IoT Core service and watch it send MQTT messages?
Tags: Aws Iot, AWS, Smart Cities, Workfall, IoT

AWS IoT

How to connect smart devices to the Amazon IoT Core service and watch it send MQTT messages? Workfall Jun 25·15 min read

The internet of things, also known as IoT, in recent years, successfully disrupted our daily lives. If you are using smartphones, smart watches, smart fire alarms, smart door locks, smart bicycles, medical sensors, fitness trackers, smart security systems, smart refrigerators or smart cars, you are using IoT devices! IoT devices are making our lives better in so many ways, and it will likely continue to do so.

With the escalating uses of IoT devices, we need solutions to connect them, and collect, store, and analyze different devices’ data. AWS IoT is the only cloud platform which provides data management and rich analytics in easy to use services designed for IoT data. In this blog, we will discuss AWS IoT Core, it’s features, benefits, how it works, etc. In part 2 of this blog, we will do step by step hands-on to connect smart devices to the Amazon IoT Core service and watch it send MQTT messages.

Fortune Business Insights, indicating that the IoT global market, which was valued at $190 billion in 2018, would reach $1.11 trillion ($1111.3 billion) by 2026.

In this blog we will cover:

What is IoT?

What is AWS IoT?

How does AWS IoT work?

Use cases of AWS IoT

Various AWS IoT services

What is AWS IoT Core

Benefits of AWS IoT Core

Features of AWS IoT Core

Why should you use AWS IoT Core?

AWS IoT Core capabilities

How does AWS IoT Core work?

Companies Using AWS IoT Core

Conclusion

What is IoT ?

Internet of Things (IoT) refers to any device or physical object that connects and exchanges data with other devices and systems over the internet. These devices or objects are embedded with sensors, software, and other technologies. As you control different appliances in your homes (i.e. fans, thermostats, and refrigerators), or go on a jog and track your exercise activity using a smart watch, then you know that IoT touches our daily lives. Other day-to-day use cases for IoT include using vacuuming robots to help with cleaning houses, or using devices to monitor and secure homes, businesses, or packages.

Some examples of how we use Internet of Things in our everyday lives include:

Smart voice assistants (Alexa or Siri)

Smart security systems, smart locks, and smart doorbells

Smart home appliances like stoves, refrigerators, washers and dryers, coffee machines, slow cookers

Fitness trackers, smart watches, sleep trackers, and smart scales

Smart home hubs (home heating and cooling, smart control lighting, )

What is AWS IoT?

AWS IoT provides the cloud services that connect your IoT devices to other devices and AWS cloud services. AWS IoT provides device software that can help you integrate your IoT devices into AWS IoT-based solutions. If your devices can connect to AWS IoT, AWS IoT can connect them to the cloud services that AWS provides.

AWS IoT lets you select the most appropriate and up-to-date technologies for your solution. To help you manage and support your IoT devices in the field, AWS IoT Core supports these protocols:

MQTT (Message Queuing and Telemetry Transport)

MQTT over WSS (Websockets Secure)

HTTPS (Hypertext Transfer Protocol — Secure)

LoRaWAN (Long Range Wide Area Network)

How does AWS IoT work ?

AWS IoT provides cloud services and device support that you can use to implement IoT solutions. AWS provides many cloud services to support IoT-based applications. So to help you understand where to start, this section provides a diagram and definition of essential concepts to introduce you to the IoT universe.

Apps

Apps give end users access to IoT devices and the features provided by the cloud services to which those devices are connected.

Cloud services

Cloud services are distributed, large-scale data storage and processing services that are connected to the internet. Examples include:

IoT connection and management services.

AWS IoT is an example of an IoT connection and management service.

AWS IoT is an example of an IoT connection and management service. Compute services, such as Amazon Elastic Compute Cloud and AWS Lambda.

Database services, such as Amazon DynamoDB

Communications

Devices communicate with cloud services by using various technologies and protocols. Examples include:

Wi-Fi/Broadband internet

Broadband cellular data

Narrow-band cellular data

Long-range Wide Area Network (LoRaWAN)

Proprietary RF communications

Devices

A device is a type of hardware that manages interfaces and communications. Devices are usually located in close proximity to the real-world interfaces they monitor and control. Devices can include computing and storage resources, such as microcontrollers, CPU, memory. Examples include:

Raspberry Pi

Arduino

Voice-interface assistants

LoRaWAN and devices

Amazon Sidewalk devices

Custom IoT devices

Interfaces

An interface is a component that connects a device to the physical world.

User interfaces

Components that allow devices and users to communicate with each other.

Components that allow devices and users to communicate with each other. Input interfaces

Enable a user to communicate with a device

Examples: keypad, button

Enable a user to communicate with a device Examples: keypad, button Output interfaces

Enable a device to communicate with a user

Examples: Alpha-numeric display, graphical display, indicator light, alarm bell

Enable a device to communicate with a user Examples: Alpha-numeric display, graphical display, indicator light, alarm bell Sensors

Input components that measure or sense something in the outside world in a way that a device understands. Examples include: Temperature sensor (converts temperature to an analog voltage),Humidity sensor (converts relative humidity to an analog voltage), Analog to digital convertor (converts an analog voltage to a numeric value), Ultrasonic distance measuring unit (converts a distance to a numeric value), Optical sensor (converts a light level to a numeric value), Camera (converts image data to digital data)

Input components that measure or sense something in the outside world in a way that a device understands. Examples include: Temperature sensor (converts temperature to an analog voltage),Humidity sensor (converts relative humidity to an analog voltage), Analog to digital convertor (converts an analog voltage to a numeric value), Ultrasonic distance measuring unit (converts a distance to a numeric value), Optical sensor (converts a light level to a numeric value), Camera (converts image data to digital data) Actuators

Output components that the device can use to control something in the outside world. Examples include: Stepper motors (convert electric signals to movement), Relays (control high electric voltages and currents)

Use cases of AWS IoT

Industrial

AWS IoT customers are building industrial IoT applications for predictive quality and maintenance and to remotely monitor operations.

Connected home

AWS IoT customers are building connected home applications for home automation, home security and monitoring, and home networking.

Commercial

AWS IoT customers are building commercial applications for traffic monitoring, public safety, and health monitoring.

Various AWS IoT Devices

AWS IoT Core has many features that tackle different challenges IoT customers often have. Now we go into the different components of AWS IoT Core and walk through an example of how a fictional startup will use the different components of AWS IoT Core to their benefit.

Some of the most widely used IoT device types include smartphones, smartwatches, smart refrigerators, smart door locks, medical sensors, etc. Here’s a list of a few of the most popular IoT devices:

Google Home Voice Controller: IoT device that allows users to enjoy, manage, and control features such as media, alarms, lights, thermostats, volume, and more through voice commands.

IoT device that allows users to enjoy, manage, and control features such as media, alarms, lights, thermostats, volume, and more through voice commands. Amazon Echo: IoT device that is capable of processing voice commands to play songs, take phone calls, set timers and alarms, answer questions, check the weather forecast, manage to-do lists, manage smart home devices, and much more.

IoT device that is capable of processing voice commands to play songs, take phone calls, set timers and alarms, answer questions, check the weather forecast, manage to-do lists, manage smart home devices, and much more. Fitbit: High-performance, IoT wearable that provides smart features such as heart rate tracking, workout tracking, sleep pattern monitoring, food intake, and more.

High-performance, IoT wearable that provides smart features such as heart rate tracking, workout tracking, sleep pattern monitoring, food intake, and more. Bigbelly Smart Waste and Recycling System: Platform for smart waste management in a smart city framework. It provides historical and real-time data collection capabilities via a cloud-based service to assist with smart trash collection and reduction in overflow.

Platform for smart waste management in a smart city framework. It provides historical and real-time data collection capabilities via a cloud-based service to assist with smart trash collection and reduction in overflow. Medication Dispensing Service: Made by the tech giant Philips, the Medication Dispensing Service automatically notifies patients when it’s time to take medication or refill medication, or a dose has been missed.

Made by the tech giant Philips, the Medication Dispensing Service automatically notifies patients when it’s time to take medication or refill medication, or a dose has been missed. Libelium Waspmote Sensor Nodes: Sensor device network that enables easy integration of industrial devices with the cloud for data communication.

Sensor device network that enables easy integration of industrial devices with the cloud for data communication. Ring Doorbell: Smart home automation system that enables users to monitor their homes through the use of motion-based cameras and smart doorbells.

Smart home automation system that enables users to monitor their homes through the use of motion-based cameras and smart doorbells. Logitech Harmony Universal Remote: Powerful smart device that enables users to control house media, lighting configurations, and other smart devices from a remote location.

Powerful smart device that enables users to control house media, lighting configurations, and other smart devices from a remote location. ESP32: Low-cost, low-power system on a chip (SoC) with WiFi and dual-mode Bluetooth capabilities that are engineered and widely used to work for mobile devices, wearable electronics, and the prototyping and development of IoT applications.

Low-cost, low-power system on a chip (SoC) with WiFi and dual-mode Bluetooth capabilities that are engineered and widely used to work for mobile devices, wearable electronics, and the prototyping and development of IoT applications. Raspberry Pi 3: Small, affordable yet powerful computer that can be used in IoT projects due to the simplicity of connecting multiple sensors simultaneously.

Small, affordable yet powerful computer that can be used in IoT projects due to the simplicity of connecting multiple sensors simultaneously. Odroid: It stands for Open and Droid, it is a development platform with hardware and software used to create IoT applications.

What is AWS IoT Core

AWS IoT Core lets you connect IoT devices to the AWS cloud without the need to provision or manage servers. AWS IoT Core can support billions of devices and trillions of messages, and can process and route those messages to AWS endpoints and to other devices reliably and securely. With AWS IoT Core, your applications can keep track of and communicate with all your devices, all the time, even when they aren’t connected.

AWS IoT Core also makes it easy to use AWS and Amazon services like AWS Lambda, Amazon Kinesis, Amazon S3, Amazon SageMaker, Amazon DynamoDB, Amazon CloudWatch, AWS CloudTrail, Amazon QuickSight, and Alexa Voice Service to build IoT applications that gather, process, analyze and act on data generated by connected devices, without having to manage any infrastructure.

Benefits of AWS IOT Core

Secure device connections and data

AWS IoT Core provides automated configuration and authentication upon a device’s first connection to AWS IoT Core, as well as end-to-end encryption throughout all points of connection, so that data is never exchanged between devices and AWS IoT Core without proven identity. In addition, you can secure access to your devices and applications by applying policies with granular permissions.

Choose your preferred connection protocol

AWS IoT Core lets you select the communication protocol most appropriate for your use case to connect and manage IoT devices. AWS IoT Core supports MQTT (Message Queuing and Telemetry Transport), HTTPS (Hypertext Transfer Protocol — Secure), MQTT over WSS (WebSockets Secure), and LoRaWAN (low-power long-range wide-area network).

For devices and clients that use MQTT, MQTT over WSS, and HTTP protocols, AWS IoT Core Message Broker provides a high-throughput publish/subscribe message broker to transmit messages to and from all of your IoT devices and applications. For LoRaWAN devices, AWS IoT Core for LoRaWAN provides a managed capability that eliminates the need for you to develop or operate a LoRaWAN Network Server (LNS).

Process and act upon device data

With AWS IoT Core, you can filter, transform, and act upon device data on the fly, based on business rules you define. You can update your rules to implement new device and application features at any time. AWS IoT Core makes it easy to use AWS services like AWS Lambda, Amazon Kinesis, Amazon S3, Amazon DynamoDB, Amazon CloudWatch, and Amazon Elasticsearch Service for even more powerful IoT applications.

Connect and manage devices without managing servers

AWS IoT Core allows you to connect any number of devices to the cloud and to other devices without requiring you to provision or manage servers. AWS IoT Core allows you to scale your device fleets easily and reliably.

Features of AWS IoT Core

AWS IoT Device SDK : The AWS IoT Device SDKs include open-source libraries, developer guides with samples, and porting guides so that you can build innovative IoT products or solutions on your choice of hardware platforms.

The AWS IoT Device SDKs include open-source libraries, developer guides with samples, and porting guides so that you can build innovative IoT products or solutions on your choice of hardware platforms. Device Advisor : It provides pre-built tests that helps developers to validate their IoT devices for reliable and secure connectivity with AWS IoT Core. By using Device Advisor, developers can test if their IoT devices can reliably interoperate with AWS IoT Core and follow security best practices. Developers can identify and resolve the most common device software issues during development before they deploy their devices in production.

It provides pre-built tests that helps developers to validate their IoT devices for reliable and secure connectivity with AWS IoT Core. By using Device Advisor, developers can test if their IoT devices can reliably interoperate with AWS IoT Core and follow security best practices. Developers can identify and resolve the most common device software issues during development before they deploy their devices in production. Message Broker : Securely transmits messages to and from all of your IoT devices and applications with low latency. The flexible nature of the Message Broker’s topic structure allows you to send messages to, or receive messages from, as many devices as you would like. It supports messaging patterns ranging from one-to-one command and control messaging, to one-to-one million (or more!) broadcast notification systems and everything in between.

Device Gateway : The Device Gateway manages all active device connections and implements semantics for multiple protocols to ensure that devices are able to securely and efficiently communicate with AWS IoT Core.

The Device Gateway manages all active device connections and implements semantics for multiple protocols to ensure that devices are able to securely and efficiently communicate with AWS IoT Core. Registry : The Registry establishes an identity for devices and tracks metadata such as the devices’ attributes and capabilities. The Registry assigns a unique identity to each device that is consistently formatted regardless of the type of device or how it connects. It also supports metadata that describes the capabilities of a device

The Registry establishes an identity for devices and tracks metadata such as the devices’ attributes and capabilities. The Registry assigns a unique identity to each device that is consistently formatted regardless of the type of device or how it connects. It also supports metadata that describes the capabilities of a device Device Shadow : The Device Shadow makes it easier to build applications that interact with your devices by providing always available REST APIs. In addition, applications can set the desired future state of a device without accounting for the device’s current state. AWS IoT Core will compare the difference between the desired and last reported state, and command the device to make up the difference.

The Device Shadow makes it easier to build applications that interact with your devices by providing always available REST APIs. In addition, applications can set the desired future state of a device without accounting for the device’s current state. AWS IoT Core will compare the difference between the desired and last reported state, and command the device to make up the difference. Authentication and Authorization : You can create, deploy and manage certificates and policies for the devices from the console or using the API. Those device certificates can be provisioned, activated and associated with the relevant IoT policies that are configured using AWS IoT Core. This allows you to instantly revoke access for an individual device if you choose to do so.

You can create, deploy and manage certificates and policies for the devices from the console or using the API. Those device certificates can be provisioned, activated and associated with the relevant IoT policies that are configured using AWS IoT Core. This allows you to instantly revoke access for an individual device if you choose to do so. Rules Engine : The Rules Engine makes it possible to build IoT applications that gather, process, analyze and act on data generated by connected devices at global scale without having to manage any infrastructure. The Rules Engine evaluates inbound messages published into AWS IoT Core and transforms and delivers them to another device or a cloud service, based on business rules you define. A rule can apply to data from one or many devices, and it can take one or many actions in parallel.

The Rules Engine makes it possible to build IoT applications that gather, process, analyze and act on data generated by connected devices at global scale without having to manage any infrastructure. The Rules Engine evaluates inbound messages published into AWS IoT Core and transforms and delivers them to another device or a cloud service, based on business rules you define. A rule can apply to data from one or many devices, and it can take one or many actions in parallel. AWS IoT Core for LoRaWAN : AWS IoT Core for LoRaWAN enables customers to connect wireless devices that use low-power, long-range wide area network (LoRaWAN) technology. Using AWS IoT Core, customers can now setup a private LoRaWAN network by connecting their own LoRaWAN devices and gateways to the AWS Cloud — without developing or operating a LoRaWAN Network Server (LNS). This eliminates the undifferentiated development work and operational burden of managing an LNS and associated infrastructure, accelerating the network set-up time.

AWS IoT Core for LoRaWAN enables customers to connect wireless devices that use low-power, long-range wide area network (LoRaWAN) technology. Using AWS IoT Core, customers can now setup a private LoRaWAN network by connecting their own LoRaWAN devices and gateways to the AWS Cloud — without developing or operating a LoRaWAN Network Server (LNS). This eliminates the undifferentiated development work and operational burden of managing an LNS and associated infrastructure, accelerating the network set-up time. Alexa Voice Service (AVS) Integration : Alexa Built-in is a category of devices created with the Alexa Voice Service (AVS) that have a microphone and speaker. You can talk to these products directly with the wake word “Alexa,” and receive voice responses and content instantly.

Alexa Built-in is a category of devices created with the Alexa Voice Service (AVS) that have a microphone and speaker. You can talk to these products directly with the wake word “Alexa,” and receive voice responses and content instantly. Amazon Sidewalk Integration : Amazon Sidewalk is a shared network that helps connected devices work better through improved connectivity options. Operated by Amazon at no charge to customers, Sidewalk can help simplify new device setup, extend the low-bandwidth working range of devices, and help devices stay online even if they are outside the range of their home Wi-Fi.

Why should you use AWS IoT Core ?

Quick device connectivity: Connecting your hardware device or your mobile application to AWS IoT Core quickly is simple and easy using AWS IoT Device SDK.

Connecting your hardware device or your mobile application to AWS IoT Core quickly is simple and easy using AWS IoT Device SDK. Secure data ingestion: Ingest millions of data records/messages collected from multiple devices securely and easily using AWS IoT Core.

Ingest millions of data records/messages collected from multiple devices securely and easily using AWS IoT Core. Easy device management: With AWS IoT Device Management, organizing, monitoring, and remotely managing the IoT devices is easy and simple.

With AWS IoT Device Management, organizing, monitoring, and remotely managing the IoT devices is easy and simple. Supports Multiple protocols: AWS Device Gateway supports the MQTT, WebSockets, and HTTP 1.1 protocols.

AWS Device Gateway supports the MQTT, WebSockets, and HTTP 1.1 protocols. Simple codebase management: Application code base can be easily managed with your current team of .NET developers. No need for additional expertise to handle the code base.

AWS IoT Core capabilities

Publish and subscribe to messages with message broker

The Message Broker is a high throughput publish/subscribe (pub/sub) message broker that securely transmits messages to and from all of your IoT devices and applications with low latency. AWS IoT Core supports devices and clients that use the MQTT and the MQTT over WSS protocols to pub/sub to messages, and devices and clients that use the HTTPS protocol to publish messages.

Mirror device state

With Device Shadow, AWS IoT Core stores the latest state of a connected device so that it can be read or set at any time, making the device appear to your applications as if it were online all the time. This means that your application can read a device’s state even when it is disconnected, and also enables you to set a device state and have it implemented when the device reconnects.

Build Alexa Built-in devices cost-effectively at scale

The Alexa Voice Service (AVS) Integration for AWS IoT Core introduces a new virtual Alexa Built-in device in the cloud. To use the AVS Integration, customers use a new set of AWS IoT-reserved MQTT topics to transfer MQTT-based audio messages between devices connected to AWS IoT Core and the new virtual Alexa Built-in device. This allows customers to send and receive audio messages over the reserved MQTT topics, interface with the device microphone and speaker, and manage the device-side state all while using the same secure AWS IoT Core connection.

Connect and manage LoRaWAN devices

AWS IoT Core for LoRaWAN enables customers to set up a private LoRaWAN network by connecting their own LoRaWAN devices and gateways to the AWS cloud — without developing or operating a LoRaWAN Network Server (LNS).

How does AWS IoT Core work?

Connected devices, such as sensors, actuators, embedded devices, smart appliances, and wearable devices, connect to AWS IoT Core over HTTPS, WebSockets, or secure MQTT or LoRaWAN. Included in AWS IoT Core is a Device Gateway that allows secure, low-latency, low-overhead, bi-directional communication between connected devices and your cloud and mobile applications.

AWS IoT Core also contains a Rules Engine which enables continuous processing of data sent by connected devices. You can configure rules to filter and transform the data. You also configure rules to route the data to other AWS services such as DynamoDB, Kinesis, Lambda, SNS, SQS, CloudWatch, Elasticsearch Service with built-in Kibana integration, as well as to non-AWS services, via Lambda for further processing, storage, or analytics.

There is also a Registry where you can register and keep track of devices connected to AWS IoT Core, or devices that may connect in the future. The Device Shadow in AWS IoT Core enables cloud and mobile applications to query data sent from devices and send commands to devices, using a simple REST API, while letting AWS IoT Core handle the underlying communication with the devices. The Device Shadow accelerates application development by providing a uniform interface to devices, even when they use one of the several IoT communication and security protocols with which the applications may not be compatible. The Device Shadow also accelerates application development by providing an always available interface to devices even when the connected devices are constrained by intermittent connectivity, limited bandwidth, limited computing ability or limited power.

Communication with AWS IoT Core is secure. The service requires all of its clients (connected devices, server applications, mobile applications, or human users) to use strong authentication (AWS IAM credentials, or 3rd party authentication via AWS Cognito). All communication is encrypted. AWS IoT Core also offers fine-grained authorization to isolate and secure communication among authenticated clients.

Companies Using AWS IoT Core

Conclusion

In this blog, we have discussed IoT, AWS IoT, AWS IoT Core and it’s benefits, use cases, features, how it works and different companies who use AWS IoT. We also have discussed that IoT enables computing physically to be created quickly and brings advanced analytics capabilities to the real world. In part 2 of this blog, we will demonstrate how to connect devices to the Amazon IoT Core service and watch it send MQTT messages? We will also discuss about AWS IOT Analytics in our upcoming blogs. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies.

For any further queries, feel free to post your comments, we are happy to help!

Meanwhile …

Keep Exploring -> Keep Learning -> Keep Mastering

This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At Workfall, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you’re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at workfall.com/partner today.