NODE-RED
Start using MQTT for sensor logs
Les Pounder is a sensitive soul and his new office needs sensors to record data. He’d better break out the maker kit!
Credit: http://nodered.org
OUR EXPERT
Les Pounder is associate editor at Tom’s Hardware and a freelance maker for hire. He blogs about his adventures and projects at http://bigl.es.
YOU NEED
> Pico W
> Breadboard
> DHT11 sensor
> 3x male-tomale jumper wires
> Network
> Code: https://github.com/lesp/LXF312-PicoW-MQTT/archive/refs/heads/ main.zip
The Internet of Things (IoT) is hard, right? Wrong. It is easy thanks to MQTT and Node-RED. For this tutorial, we are building a simple Raspberry Pi Pico W-powered sensor that sends data to a Pi-powered dashboard running on Node-RED. The protocol that we’re using is called MQTT and there are more details in the boxout (opposite page).
There is only one sensor connected to the Pico W. This is a common DHT11 temperature and humidity sensor, which can be picked up cheaply and is often bundled in electronics kits. The DHT11 has only three connections to the Pico W: 3V, Data and GND (red, yellow and black wires in the diagram). Please refer to the high-res image in the download for this issue.
While holding the BOOTSEL button, connect your Pi Pico to your computer. Go to https://bit.ly/lxfupdate and download the version of MicroPython for your Pico or Pico W. Open your file manager, go to the downloaded file and copy it to the root of the RPI-RP2 drive. This flashes the new firmware to the Pico. Using your distro’s package manager, install Thonny. For the latest Ubuntu release we have to use a Snap package: