Every IoT project, big or small, consists of 3 main components namely the sensors, the actuators and the communication medium by which the things talk to each other also known as the control center.
In this article, I would like to demonstrate how we could simulate a sensor action, a control center and an actuation based on the sensor condition. I am therefore calling it a “Hello World” as this is what we try to do when we learn something new :)
Before we move any further, refer to my IoT device setup article to have the device ready for this tutorial.
Firstly, we would set up the control center, in this case a managed MQTT broker. Message Queuing Telemetry Transport (MQTT) is a most widely used IoT protocol due to its inherent properties which make it most ideal for IoT applications. Go to CloudMQTT website and create an account. We would use the free plan in this tutorial. Since MQTT is open source, we even could have a local MQTT broker setup, but let’s use something out there. In my future series, I will show you how we can set up a local MQTT broker.
Go to the details of the instance and take a note of the server, port and the credentials which we would need when we create the application to send and receive simulated sensor data. If you see the left side panel, there are a bunch of other options like creating more users, attaching self-signed certificates, which is out of scope of this tutorial but are interesting things for exploration. Might be a good topic for one of my future articles.
Now that the control center is setup, let's dive into in creating the simulated sensor which can send data to our MQTT Broker.
Simulated Sensor and Actuator Setup
Boot the Raspberry Pi, and it should automatically connect itself with the Wi-Fi router. If you have it hooked up to a monitor, keyboard and mouse, open 2 terminals. If not, try to connect to it via SSH using Putty on Windows or on…