The blog of a dedicated radio amateur and electronics enthusiast

"Having fun on the air and in the workshop - communicating and creating"

27 March 2021

Using Node-RED with the Soil Moisture Meter

Node-RED is a programming tool for event-driven applications. 'Flows' to connect inputs to outputs, hardware and online services via 'nodes' are created in a browser based editor in a similar way to 'MIT App Inventor' which I use for my Android apps. I thought of an application for Node-RED with my Soil Moisture Meter ( post 16.03.2021 ).
The events I wanted to handle were to trigger an email to be sent when the soil moisture level was low, save the moisture measurements to a text file and also publish them to an MQTT* broker. The image below shows how I 'wired' nodes together in Node-RED to achieve that.
My Node-RED flow - from input (blue) to outputs (mauve & light green)
Starting at the top left of the flow, every hour the most recent data packet containing the moisture value is read from the webpage ( /Moisturevalue ) hosted by the moisture meter receiver. Only if the text 'dry' or 'partched' is found in the packet string is an email sent. I have preset the body of the email to read "The SpacerLabs Soil Moisture Meter ( Sensor 1 ) has notified a 'low moisture level' alert".
My moisture meter data published on the HiveMQ broker
All packets ( unfiltered ) are published under the topic 'SpacerLabs/Moisture1' to an online MQTT broker. I chose the free public broker 'HiveMQ'. My topic is 'open'; so anyone can connect to www/hivemq.com/demos/websocket-client and subscribe to the above topic to read my hourly data packets under the messages tab. But only when my Node-RED server and the moisture meter are running. I also publish the status, ( ONLINE, OFFLINE or DISCONNECTED ), of the moisture meter to the separate topic 'SpacerLabs/Status'.
More information on Node-RED can be found at nodered.org.
* MQTT Message Queuing Telemetry Transport https://mqtt.org      

16 March 2021

Remote Soil Moisture Meter

My current project is a remote soil moisture meter which uses LoRa wireless data technology. A soil moisture sensor will be in soil where plants are growing and be connected to a LoRa transmitter which sends the moisture measurement of the soil every hour to the LoRa receiver for display. I am thinking of using it in my herb garden. The receiver will be situated indoors.
Soil moisture sensor will be pushed into the soil
The LoRa receiver display
I have also connected a type LM35 analogue temperature sensor to the LoRa transmitter. The air temperature will also be measured and sent every hour. The complete packet of data that is sent contains the temperature, moisture value and level, and the packet number. I really only included the temperature to make the data-packet longer and more interesting.
The receiver hosts a web-page
I have completed the firmware, and added wi-fi functionality to the receiver so that the date/time stamp, web server and an Android app can be used. Everything works just fine when connected together in the lab.
Custom app "SpacerLabs_Moisture"

I shall probably post an update when I have completed the project by fitting the LoRa modules in suitable boxes, ( I'd find a 3D printer useful ! ), and purchasing a small solar panel for the transmitter. After that I might add more sensors in different locations which will require using the addressing protocol of LoRa, and also try to connect to my nearest LoRa gateway 6 kms away for LoRa-WAN.

For a short description of LoRa and my set-up see 15 Feb 2021.