MQTT CLIENT IMPLEMENTATION BASED ON A SINGLE-CHIP MICROCONTROLLER FOR REMOTE EQUIPMENT MANAGEMENT TASKS
Abstract
The article describes a device that transmits data and processes commands over the MQTT
protocol on the Internet. A small batch was made to assess the performance in real practice. The
software for the microcontroller is written in C using a real-time operating system (RTOS), which
allows you to streamline software development through pseudo-parallel code execution, task synchronization
mechanisms (semaphores, mutexes), and a queue mechanism. The paper presents an
example of an algorithm for the interaction of FreeRTOS tasks: the tasks of waiting for a command
from the server, the tasks of measuring temperature, the main thread that sends a message
to the server in response to the appearance of a line in the message queue. The core of the MQTT
client being developed is the STM32 microcontroller and the GSM/GPRS SIM800 module. A large
number of interfaces are displayed on the device, which allows you to connect a wide variety of
peripherals (temperature, humidity, pressure sensors, servos, etc.). The device is able to independently
restore the connection to the network in case of its interruption. The proprietary implementation
of the MQTT protocol version 3.1 QoS 0 is used in the software of the control microcontroller.
MQTT messages are transmitted as part of a TCP connection established by means of a GSM module. The control microcontroller communicates with the GSM module via AT commands.
The possibility of two-way real-time messaging is implemented, which allows using the developed
microprocessor system both in the mode of an autonomous control device and in the interactive
mode of executing commands received wirelessly and sending the execution statuses of these
commands. The main feature of the MQTT client is the ability to remotely update the microcontroller
software (OTA), implemented using an auxiliary microcontroller and a flash memory chip.
The developed MQTT client is intended to be used as the basis of microprocessor systems - clients
of the Internet of Things.
References
Conf. Ser., 2021, Vol. 1755, 012035.
2. Hussein M., Galal A.I., Abd-Elrahman E., Zorkany M. Internet of Things (IoT) Platform for
Multi-Topic Messaging, Energies, 2020, No. 13, 3346. Available at: https://doi.org/
10.3390/en13133346.
3. Lawrence O., Aghenta M. Tariq Iqbal. Design and implementation of a low-cost, open source
IoT-based SCADA system using ESP32 with OLED, Things Board and MQTT protocol, J.
AIMS Electronics and Electrical Engineering, 2020, No. 4 (1), pp. 57-86. DOI:
10.3934/ElectrEng.2020.1.57.
4. Wu F., Wu T., Yuce M.R. An Internet-of-Things (IoT) Network System for Connected Safety
and Health Monitoring Applications, Sensors, 2019, No. 19, pp. 21. Available at:
https://doi.org/10.3390/s19010021.
5. Saraereh O.A., Alsaraira A., Khan I., Choi B.J. A Hybrid Energy Harvesting Design for On-
Body Internet-of-Things (IoT) Networks, Sensors, 2020, No. 20, pp. 407. Available at:
https://doi.org/10.3390/s20020407.
6. Sudarsono Novianta M.A., & Parwati,C.I. Application of Internet of Things (IoT) on air pollution
monitoring database system, E3S Web of Conferences, 2019.
7. Syafaah L. et al. Distance Measurement of ESP8266 for Control and Monitoring in Smart
Home Application, J. Phys.: Conf. Ser., 2019, Vol. 1381, 012058.
8. Hongan Mu et al. Discovering and Analyzing Internet of Things (IoT) Technologies and Applications
for Aged Care, J. Phys.: Conf. Ser., 2021, Vol. 1948, 012141.
9. Yadgarova Yu.V. Model' i algoritm vybora programmnoy arkhitektury dlya sistem Interneta
veshchey [A model and algorithm for choosing a software architecture for Internet of Things
systems], Programmnye produkty i sistemy [Software products and systems], 2019, No. 4,
pp. 682-689. EDN QLQDSZ.
10. Mikrokontrollery lineyki STM32F446 [Microcontrollers of the STM32F446 line]. Available at:
https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html (accessed 29 May 2022).
11. Modul' SIM800 [SIM800 module]. Available at: https://www.simcom.com/ (accessed 29 May
2022).
12. Li P. Arkhitektura internet veshchey [Architecture of the Internet of Things]: transl. from engl.
by M.A. Raytmana. Mщысщц: DMK Press, 2019б зз. 282-293.
13. Standart NB-IoT: primenenie i perspektivy [NB-IoT standard: application and prospects],
Besprovodnye tekhnologii [Wireless technologies], 2019, No. 3 (56), pp. 27-31. EDN
SUHNQH.
14. Batuev B. Rabota so vstroennym TCP/IP-stekom moduley GSM/GPRS serii SIM800 kompanii
SIMCom Wireless Solutions [Working with the built-in TCP/IP stack of GSM/GPRS modules
of the SIM800 series of SIMCom Wireless Solutions], Besprovodnye tekhnologii [Wireless
Technologies], 2016, No. 2 (43), pp. 38-43. EDN XRLINH.
15. Operatsionnaya sistema real'nogo vremeni FreeRTOS [FreeRTOS real-time operating system].
Available at: https://www.freertos.org/features.html (accessed 29 May 2022).
16. Kurnits A. FreeRTOS - operatsionnaya sistema dlya mikrokontrollerov [FreeRTOS - operating
system for microcontrollers], Komponenty i tekhnologii [Components and Technologies],
2011, No. 2 (115), pp. 96-100. EDN NCDJHZ.
17. Tsifrovoy sintez: prakticheskiy kurs [Digital synthesis: a practical course], under the general
ed. A.Yu. Romanova, Yu.V. Panchula. Moscow: DMK Press, 2020, 556 p.
18. Konchenkov V.I., Skakunov V.N. Realizatsiya MQTT-klienta na osnove mikrokontrollera:
ucheb.-metod. posobie [Implementation of an MQTT client based on a microcontroller: educational
and methodical manual]. Volgograd: VolgGTU, 2021, 64 p.
19. Lee In. Internet of Things (IoT) Cybersecurity: Literature Review and IoT Cyber Risk Management,
Future Internet, 2020, Vol. 12, pp. 157.
20. Spielvogel K., Pöhls H.C., Posegga J. TLS Beyond the Broker: Enforcing Fine-Grained Security
and Trust in Publish/Subscribe Environments for IoT. In: Roman R., Zhou J. (eds), Security
and Trust Management. STM 2021. Lecture Notes in Computer Science, 2021, Vol. 13075.
Springer, Cham. Available at: https://doi.org/10.1007/978-3-030-91859-0_8.