What should we build IoT? Your IoT on Amazon in One Day

To begin to deal with IoT (Internet of Things) platforms, I was stopped by the lack of an IoT device that would be compatible by protocols and access methods. But when I realized that you can use an ordinary smartphone as a device, the implementation of a working chain took one day.



Take a smartphone that will emulate an IoT device with temperature, humidity and pressure sensors and send readings to the Amazon IoT platform. On the platform, we will establish a rule that upon receipt of data from our device will call a notification service, which in turn will send an e-mail with the received data.



Such a system, of course, carries little practical value, but it allows you to understand how everything works:



image



Why Amazon’s IoT Platform? And why do you need to understand how IoT platforms work?



M2M - IoT - IoE



There are more and more IoT devices in the world, both analytical agencies and world statistics speak about this.



We ourselves can clearly see that more and more systems are connected to the Internet and are controlled automatically or by people: smart homes, cars, wearable devices. And now they are talking not just about IoT, but about IoE (Internet of Everything), because devices that connect to platforms are used not only in industrial systems, but also by people.



Therefore, we need to understand the principles of work ourselves, at least in order to understand how you can effectively use your devices or what are the limitations and nuances of security.



Why amazon?



Amazon creates services taking into account global trends and as a result “universal” systems are obtained, the basic principles of which are used by all manufacturers. The cloud platform has an even bigger plus - this is the ability to deploy the system on your own in a couple of hours without involving corporate IT service and security)



Why a smartphone, not some IoT Starter Kit?



On closer inspection, the smartphone emulates the IoT device well:





Those. working with a real IoT device will be no different from working with a smartphone, except for using a specific SDK to get sensor readings. All other communications will be similar.



Let me skip the section with standards, analytics and marketing research - at the end of the article I will give some relevant links. I’m eager to do something interesting)



AWS IoT Platform



Amazon draws a fairly clear diagram of its platform:



image



Here, in general, everything is clear:





We begin to understand, the scheme is a little complicated:



image



Appear:



Jobs - perform standard actions on devices, for example, install applications, update firmware, reboot devices, etc.

Topics - the essence of the MQTT protocol. Messages from IoT devices are sent to specific topics.

IAM Roles - AWS users on behalf of whom the rules are executed and who have access to the necessary AWS resources.



Rules consist of:





Certificate - uploaded to the IoT device, with their help authentication of devices on the AWS platform occurs. Consist of:





Policy - policies are attached to certificates that determine what actions the device can perform. Policies authorize devices.

Details AWS services that receive information from the IoT platform: Analytics, DB, SNS notification service.



We connect the device



I will not fully give instructions on connecting the IoT device to the Amazon platform: Getting Started with AWS IoT . But to understand the scope of the task, I will list the steps that need to be taken in order for the scheme to work:





image





image





image





image



Now create the rule itself (my_iot_dev_rule), which will call the created topic:





image





image





Smartphone Configuration



It's time to configure the IoT device, which will be my smartphone. To do this, use the AWS SDK JavaScript instruction . To turn a smartphone into an IoT device you need:





In our case, everything will be a little easier, because I put the certificates, AWS SDK and test program on GitHub and you can just clone the IoT-Sensors repository . If someone wants to use my test program, then they will need to put their certificates in the / IoT / certs directory and write in the / server / src / services / IoT-AOI-Server file the actual Rest API Endpoint:



device = deviceModule({ … host: 'a2lqo1xxx4zydi-ats.iot.eu-central-1.amazonaws.com', … })
      
      





The Rest API Endpoint is taken from the device settings:



image



If you want to try something standard, then you can use the test programs from the AWS SDK.



Android is the same Linux, but with its limitations, so to run JS applications you need to install a special terminal, for example, Termux .



For the initial development of Termux, there are a number of articles, for example: Launching a NodeJS application on Android . But by and large, after installing Termux, you need to execute only a few magic commands:



 git clone https://github.com/AlexeySushkov/IoT-Sensors.git
      
      





Server installation



 cd ~/IoT-Sensors/server npm install npm start
      
      





If everything went well, the line will appear in the terminal:

Server started on port: 8081



Live it looks like this:



image



Client Installation



 cd ~/IoT-Sensors/client npm install npm run serve
      
      





If everything went well, the line will appear in the terminal:

App running at port: 8080



Next, in the smartphone browser, enter: http: // localhost: 8080



And a test application will appear on the screen:



image



Press the “INIT DEV” button. This authenticates and authorizes the IoT device on the AWS IoT platform. If successful, the status becomes “Init OK”.



Next, enter the values ​​of the temperature, humidity and pressure sensors, for example:

Temperature: 23

Humidity: 65

Pressure: 787



And press the “SEND DATA” button.



image



After that, the application adds a timestamp and sends the data in the form of MQTT messages to the topic “my / dev-topic”. The IoT platform receives a message and activates a rule that sends a message to the AWS SNS notification service, which sends an e-mail with the received data in JSON format:



 {"time":"Mon, 30 Sep 2019 13:54:52 GMT", "temperature":"23", "humidity":"65", "pressure":"787"}
      
      





If the message is sent successfully, then the status changes to: “publish OK” and an e-mail is sent to the mail:



image



The AWS IoT platform has a monitoring system that shows the number of connections and messages from IoT devices, statistics on protocols, message types, etc.:



image



So now everything is working for real!



Conclusion



We built a small but real IoT using a platform from Amazon. All platforms are built on the same principles, so if the question arises of choosing an IoT system, we will be ready to ask the following questions. And then, knowing the answers from Amazon, we can conclude how mature the platform is offered:



Devices





Platform





Interaction





As promised, I will provide some relevant links to standards and analytics:



IoT Standards



Surprisingly, the standardization giants ( ISO / IEC , IEEE , ITU-T ) have lost interest in IoT after 2016. They, of course, are doing something, but somehow without a twinkle). NIST also released its Networks of 'Things' study, but after 2016 there is nothing more interesting.



Telecommunication institutes look better, which is not surprising since without connectivity, IoT is not an IoT. TM-Forum, under its umbrella, collects cases and projects of IoE & Digital Ecosystems , ETSI is easier and joined OneM2M .



And now we come to two organizations that were formed relatively recently, but already determine the world direction of IoT development:



OneM2M



OneM2M is an association of standardization organizations , telecommunication companies and manufacturers from different countries. They have dozens of relevant documents in the public domain that warm the soul with architectural models and functional diagrams .



IIC



IIC (Industrial Internet Consortium) - an organization for standardizing the industrial Internet of things - these are mainly manufacturers of software and devices . They also release their reference architectures. In general, there is where to look at the perfect world! )



IoT Analytics



All of our favorite analytic agencies release IoT research, but not all are freely available. As an example, I’ll give a few relevant articles that demonstrate optimistic forecasts for the development of IoT:







It's only the beginning!



All Articles