Smart Farming IoT - Moisture Content Dashboard
The provided Node-RED flow is designed to create a moisture content dashboard for smart farming applications. It visualizes the moisture content data over time using a line graph/chart and generates a warning message when the average moisture content falls below 40,000.
Here's how the flow works and how it can be used:
Simulated Moisture Data: The inject node triggers the flow at a specified interval, simulating the arrival of moisture data from sensors or other data sources.
Generate Random Moisture Value: The function node generates a random moisture value between 30,000 and 50,000. This value represents the moisture content of the agricultural land at a given time.
Calculate Average Moisture: The function node calculates the average moisture content by storing the received values in the context. It keeps track of the last 10 values and calculates their average.
Generate Warning: If the average moisture content falls below 40,000, a warning message is generated. The message indicates that the moisture level is low and the land requires watering.
Moisture Content Line Graph: The ui_chart node is responsible for visualizing the moisture content data over time. It displays a line graph/chart that represents the moisture values received in the flow. The graph is updated dynamically as new data arrives.
Moisture Debug: The debug node is used for monitoring purposes. It can be enabled to view the average moisture value and the warning message in the Node-RED editor debug sidebar.
To use this flow:
- Import the flow into your Node-RED editor by copying the provided flow JSON and pasting it in the Import dialog.
- Deploy the flow in Node-RED.
- Access the Node-RED dashboard to view the moisture content line graph/chart, which shows the moisture values over time.
- Monitor the debug sidebar to check the average moisture value and the warning message when the moisture level falls below the threshold.
By utilizing this flow, farmers can remotely monitor the moisture content of their agricultural land, make informed decisions about irrigation based on the visualized data, and receive warnings when the land needs watering. It enables efficient water management and helps optimize agricultural practices for better crop yield.
[{"id":"d244c57d.60b0a","type":"tab","label":"Moisture Content Dashboard","disabled":false,"info":""},{"id":"fa5e70c1.8ce5f8","type":"inject","z":"d244c57d.60b0a","name":"Simulated Moisture Data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":100,"wires":[["a15c0d88.101ce"]]},{"id":"a15c0d88.101ce","type":"function","z":"d244c57d.60b0a","name":"Generate Random Moisture Value","func":"// Simulate moisture data between 30,000 and 50,000\nvar moisture = Math.floor(Math.random() * (50000 - 30000 + 1)) + 30000;\n\nreturn {payload: moisture};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":100,"wires":[["a06a9938.29dbb8"]]},{"id":"a06a9938.29dbb8","type":"function","z":"d244c57d.60b0a","name":"Calculate Average Moisture","func":"// Store the moisture values in context\ncontext.data = context.data || [];\ncontext.data.push(msg.payload);\n\n// Keep the last 10 values in context\nif (context.data.length > 10) {\n context.data.shift();\n}\n\n// Calculate average moisture\nvar sum = context.data.reduce((a, b) => a + b, 0);\nvar average = sum / context.data.length;\n\n// Generate warning if average falls below 40,000\nif (average < 40000) {\n msg.warning = \"Moisture level is low. Land needs watering!\";\n}\n\n// Set average moisture as payload\nmsg.payload = average;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":100,"wires":[["dbbb3c19.72f018","2c6df0b4.f14162"]]},{"id":"dbbb3c19.72f018","type":"ui_chart","z":"d244c57d.60b0a","name":"Moisture Content Line Graph","group":"1e1cb181.5f2e01","order":0,"width":0,"height":0,"label":"Moisture Content","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":970,"y":100,"wires":[[]]},{"id":"2c6df0b4.f14162","type":"debug","z":"d244c57d.60b0a","name":"Moisture Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":960,"y":180,"wires":[]},{"id":"1e1cb181.5f2e01","type":"ui_group","name":"Moisture Content","tab":"45ff8c14.8ef9a4","order":1,"disp":true,"width":"6","collapse":false},{"id":"45ff8c14.8ef9a4","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]