Simple message queue for IoT in 5 minutes


Whether you are building a hobby project or fully profesional development, you will end up with the choice: How do I send my data from the device to the internet?

The easiest way is to send this data to the message queue, then from which this data will be read by the program or script (in any programming language). The following method works on every platform and device, some of them are:

  1. - Arduino
  2. - ESP8266 NodeMCU 1/2/3
  3. - Raspberry PI - wszystkie wersje
  4. - C.H.I.P Komputer
  5. - Beagle board
  6. - Any platform that is able to make HTTP requests

In this case I will use an example of the excellent ESP8266 NodeMCU v3 system, popularly known as NodeMCU. This system is equipped with WiFi connectivity and USB-UART programmer which allows developers, without any additional tools, upload the program (written in C or Lua) and start working. In addition, the system has many analog and digital inputs and outputs. For more, I refer you to the project specification page

In this particular case we just send simple string value to the message queue. But you can send anything that you are able to serialize, just to name a few:

  1. 1. Temperature - TMP36, DS18B20
  2. 2. Humidity - DHT11 DHT22
  3. 3. Air Pressure - BMP180
  4. 4. GPS coordinates - GY-NEO6MV2
  5. 5. Accelerometer values - ADXL345
  6. 6. Gyroscope values - MPU6050
  7. And many more

Let’s see the code:

This is the minimal code needed to send a simple string to a queue. To send data from the system to the network you need:

  1. 1. Connect to the WiFi network
  2. 2. Collect data eg. from a temperature sensor
  3. 3. Send data in request to the queue server

As you can see, I am not using any special library or AMQP/MQTT protocol. Just a simple plain old HTTP client, that sends requests over TCP/IP stack, to the service called — platform that offers a message queue as a service (SaaS). With its simple HTTP API interface, the developer can send the collected data from the level of virtually any embedded device and place them in the queue. The same interface is used to read data from the queue. Qutrunk is a managed platform, which means that the developer is not obliged to maintain the entire solution, care for consistency, replication and data availability.

The service deals with maintaining the highest availability of the queues, offering access using the REST API and gRPC (Protocol Buffers + RPC). The whole platform is wrapped in a simple graphical interface available through the browser. The process of creating an account and the simplest implementation takes less than 5 minutes in any language. The secret of the platform lies in its simplicity, to send a message to a queue, developer just sends a GET or POST request, at this point the message is already in the queue buffer and is ready to pull, which is carried out again using the GET method. It’s so simple, two HTTP methods are enough to implement the simplest queue mechanism. Try it yourself, create a free account that allows you to handle a small project.

What can it be useful for?

Along with the increase in the availability of IoT technologies, the interest of customers on the market is also growing. Projects in which you can use messaging:

  1. - monitoring the car fleet (sending GPS coordinates and telemetry data)
  2. - cooling sequence monitoring (real-time temperature transfer)
  3. - monitoring the level of dustiness in research stations

Code Fibers provides services for building IoT solutions along with a full backend, from the end device to the data bus and data storage, to the user interfaces. If you are interested in our offer, I invite you to visit our website and contact also get to know how we work and what is our exprience.

These posts might be interesting for you:

  1. RabbitMQ cluster on Docker with Nodejs in 5 minute
  2. 3-node MongoDB replica set with SystemD and metrics in Telegraf / Grafana
Author: Peter

I'm a backend programmer for over 10 years now, have hands on experience with Golang and Node.js as well as other technologies, DevOps and Architecture. I share my thoughts and knowledge on this blog.