📜 ⬆️ ⬇️

How to create an Internet of things from LEGO bricks based on AWS IoT platform


In one of the projects, we tested the capabilities of the AWS IoT cloud platform by connecting to it several devices from the Lego set for the programmable Mindstorms EV3 robots.

At the start, we explored several large cloud services for IoT, which gave a good impetus to the development of the entire concept of the Internet of things (IoT) - Microsoft Azure IoT Suite, AWS IoT and IBM Watson IoT - but as a result we stopped on Amazon Web Services (AWS).

The general structural scheme is as follows:

At this stage, the project does not look too complicated, which allows us to consider IoT as a whole, without unnecessary details.
')
To work with AWS, we create an Amazon Web Service account, right there we select and configure the necessary services.

First of all, we needed EC2 virtual server with Linux onboard.

We created a new instance of the class (instance) selected the Ubuntu Server OS image from the proposed Linux list from Amazon, Red Hat, SUSE and Windows Server 2012 with and without SQL Server Express. Next we configure the instance itself: CPU, memory, storage, network capabilities, tagging and security settings. At the end - we generate a pair of keys to access the service (you can use an existing pair).

→ More detailed guidance from AWS

To access the server, we used the free PuTTY client.

In our project, the Lego Mindstorms EV3 “building blocks” became things — devices connected to AWS IoT.

Specifications:


You can combine up to four such modules.



In addition to the main brick itself, we also have:



To begin, each IoT device must be registered with AWS IoT. There we get certificates and keys for connecting the device, register a unique identifier of our stuff.



Then we wrote an application for "bricks" in C #. For this used:


On the server, we deployed a web server application on Node.js using the restify module and special AWS modules for IoT and applications that use their services: aws-iot-device-sdk and aws-sdk.

For storing configuration data for each item, we used the Amazon Dynamo DB NoSQL database. It is created in the AWS account - one base for one account. All necessary tables are created there and attributes are configured.

As stated on the AWS official website, AWS IoT supports messaging using the publish and subscribe model, i.e. Our site or item can create the required number of topics for a subscription, and all other services or devices must subscribe to them in order to work with this item. In practice, it looks like this: during registration, the main topic of a thing is created, the name of which corresponds to its identifier during registration, and then the topics are created inside this main topic when the message is first published (<item ID> / <some topic>). Therefore, it is important to first subscribe to all your topics at the beginning of the device application.

Each of our devices had the following topics:




When the application is turned on, the device publishes information about itself in a configuration topic that the server reads and stores in the database. Next, using the web interface, you can configure the connection of any sensor from any connected device to any motor of any connected device, choose mathematical logic for the sensor, which will process the value from it, send a specific value to the motor, or receive data from the sensors.



As a result, we received a web terminal for controlling and monitoring controllers with a customizable ability to control the outputs (motors) of one terminal from the inputs (sensors) of another.

Cloud platforms such as AWS IoT combine any sensors with the necessary interfaces, collect data in the cloud, help analyze information and manage the Internet of their things through mobile applications. All the technologies are there, only fantasy is needed to realize these capabilities in specific devices - sensors for smart home and office, entertainment, road haulage, production automation, even for huge combat humanoid robots.

Source: https://habr.com/ru/post/324992/


All Articles