Wireless thermo-hygrometer
Final Steps
Now you need to integrate the messages of the MQTT server into the Node-RED flow. You can do this directly via the Node-RED interface. To do so, start the input node by typing mqtt and configure it to receive messages from the topic of one sensor (/home/sensor1). To create the input node, you need to define an MQTT server (Figure 6).
So the Node-RED can process the sensor data, the JSON strings need to be converted to JavaScript objects. Because this type of conversion occurs very often, a JSON node does this by default, allowing you to convert back and forth between JSON strings and JavaScript objects.
Before passing on the JavaScript object to the gauge display instrument, you have to separate the values for humidity and temperature. You can do this by using two change nodes (Figure 7), which you will set up to extract the values for temperature and humidity from the message and pack them into new messages:
msg.payload.humidity => msg.payload, msg.payload.temperature => msg.payload
The gauge nodes have to be configured (double-click on the nodes) so that the measured values lie within their display intervals; then, connect the individual nodes (Figure 8). Repeat the described steps for the other two sensors of the encoder trio. Finally, adjust the layout for your dashboard (Figure 9).
Conclusions
The easy-to-use Node-RED tool is ideal for visualizing measured values. Other tasks from the IoT sector can also be implemented easily. When setting up the sensors, you can learn a great deal about the ESP8266 microcontroller, which is also suitable as a basis for your own applications of all kinds.
A small problem remains: The AM2321 works at a level very close to its minimum operating voltage, which is why the measured values are sometimes slightly inaccurate. To solve this problem, you would have to make the power supply of the complete circuit a little more complex by using three batteries and generating the required 3.3V operating voltage with a voltage regulator.
Infos
- MQTT project: https://mqtt.org
- "RaspPi-controlled toy sailboat" by Pete Metcalfe, Linux Magazine, issue 216, November 2018, p. 52, http://www.linuxpromagazine.com/Issues/2018/215/RaspPi-Controlled-Toy-Sailboat
- MQTT app for Chrome: https://chrome.google.com/webstore/detail/mqttbox/kaajoficamnjijhkeomgfljpicifbkaf
- PCB prototyping board: https://www.aliexpress.com/item/32824842884.html
- ESP8266 and breakout board: https://www.sparkfun.com/products/15258
- USB-to-serial: https://www.amazon.com/XCSOURCE-FT232RL-Adapter-Arduino-TE203/dp/B00HSX3CXE
- AM2321: https://www.amazon.com/Quickbuying-Digital-Temperature-Humidity-Replaced/dp/B07H3SSVYL/ref=sr_1_2
- Arduino IDE: https://www.arduino.cc/en/Main/Software
- Code and diagrams for this article: ftp://ftp.linux-magazine.com/pub/listings/linux-magazine.com/226/
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.