With the buzz around the Internet-of-Things (IoT), I felt I needed to get in on the act. For those that follow my twitter feed (@feabhas) you may be aware of the “home project” I’ve been working on. This project is based around the mbed platform to which I have connected a DS18B20 temperature sensor. The overall goal is to record the water temperature of my son’s fish tank, however due to water quality issues, it is currently sampling the air temperature outside my house.
An interesting part of the project is looking into various solutions to push out the current temperature. Using the mbed LPC1768 Workshop Development Board gives me easy access to an ethernet port and thanks to the mbed community there is an off-the-shelf library for socket programming. Once you have sockets, the options suddenly open up.
Inspired by Andy Stanford-Clark and his house that twitters, I first implemented an MQTT based publisher. Even though there was an MQTT library available I really wanted to understand the protocol. As part of my learning process I downloaded the open source MQTT broker called mosquitto and developed both a simple C based publisher and subscriber on the Mac rather than the mbed (as the mbed socket library doesn’t quite follow the standard socket programming interface). With Wireshark and the existing lightweight C client library published on google code as a reference point I have implemented a simple set of files that demonstrate the principles of the MQTT publish-subscribe model. Current the code only works to “QoS-0”, but I intend to add further Quality-of-Service levels.
The code can be found on github here and is designed to be build using CMake.
- Disassembling a Cortex-M raw binary file with Ghidra - December 20, 2022
- Using final in C++ to improve performance - November 14, 2022
- Understanding Arm Cortex-M Intel-Hex (ihex) files - October 12, 2022
Co-Founder and Director of Feabhas since 1995.
Niall has been designing and programming embedded systems for over 30 years. He has worked in different sectors, including aerospace, telecomms, government and banking.
His current interest lie in IoT Security and Agile for Embedded Systems.
LOL - like the new rendering of my surname!
Opps, sorry 🙂
Pingback: Sticky Bits » Blog Archive » Native C/C++ Application development for the mbed using CMSIS-DAP
Hi Niall, I thank you for sharing the code. I am trying to upload the code into STM32L4 Arm processor board and connect to MQTT cloud.
You do appreciate this code was written back in the very early days of MQTT back in 2012? I haven't tried it recently.