Distributed weather monitoring in gardens
Data Analysis and Visualization
Building full-featured dashboards is not really possible with the limited graphing capabilities of Prometheus. For that task, I turned to another free and open source Linux tool, Grafana [21]. Again, you can find many excellent tutorials for installing Grafana on your system online [22].
Once installed, navigate to the home page and click on the settings icon (the gear icon, to the left). Select Prometheus from the list, and unless the Prometheus data port has been changed or Prometheus is running on another machine, you can accept the defaults.
Now you can create your first dashboard by clicking New | New dashboard. The new dashboard has one panel, initially called New Panel. To see the simplest Grafana visualization, click Visualization and choose Gauge. Next, switch to query, and type avg(temperature), which displays the current temperature averaged over all the sensors. The avg
function is an example of the powerful Prometheus query language that allows data to be manipulated before it is displayed.
If you repeat the above process but choose the Graph visualization and simply type temperature for the query, Grafana produces a time-based graph (Figure 10). At the top right you can select the time period. Note that each sensor will have its own plot.
Starting with the basic graph, you can make many enhancements by adding units, limits, plot styles, axis labels, and so on. Moreover, you can combine many panels on a single dashboard and have many dashboards (Figure 11). One advantage of this web-based approach to data presentation is that the graphs are available on mobile devices, too (Figure 12).

Next Steps
In terms of software, it would be better if the sensor's given name, rather than hardware ID was used to identify the sensors in Prometheus and Grafana. I will have to look at the MQTT API to see if that is possible. Otherwise, a static mapping table in the golang code would work but would be less elegant.
Many other sensors could provide useful data: soil moisture meters, pH meters, rainfall indicators, and wind speed indicators, to name but a few. Additions to the code can do so much more with the data, such as generating alarms for frost and excessive temperatures or analyzing areas to find the highest light level. Another option is to generate multiple Grafana dashboards that show the data in different forms, as well as after postprocessing.
Conclusion
The system presented here is still in development, but the results are already bearing fruit. Knowing the true outdoor temperature has allowed me to plan spring planting with more certainty, and with one sensor placed in the greenhouse, I know when it's necessary to turn on heaters or open the ventilation. This system could easily be expanded to support the needs of a small market garden, a nursery, or other forms of agriculture, where access to such detailed data could save money and increase profit.
For myself, I've learned a great deal about the local weather in my garden and about IoT, and I've increased my knowledge about so much of the excellent free and open source software available. Happy gardening (and engineering)!
Infos
- LoRa wiki: https://en.wikipedia.org/wiki/LoRa
- LoRaWAN sensor devices: https://www.thethingsnetwork.org/marketplace/products/devices
- MOSFET switch: https://www.electronics-tutorials.ws/transistor/tran_7.html
- STM32L432KCU6 microcontroller: https://www.arrow.com/en/products/stm32l432kcu6/stmicroelectronics
- KiCad: https://kicad-pcb.org
- Code and files from this article: ftp://ftp.linux-magazine.com/pub/listings/linux-magazine.com/239
- STEP file definition: https://en.wikipedia.org/wiki/ISO_10303-21
- Hammond enclosure: https://www.hammfg.com/electronics/small-case/plastic/1551
- STM32CubeMX tool: https://www.st.com/en/development-tools/stm32cubemx.html
- STLink programming utility: https://github.com/stlink-org/stlink
- GitHub project page: https://github.com/andrewrussellmalcolm/instrumeted_garden
- LoRaWAN introduction: https://www.thethingsnetwork.org/docs/lorawan/
- LoRaWAN gateway: https://shop.imst.de/media/pdf/a7/a1/53/iC880A_Datasheet_V1_1.pdf
- LoRaWAN gateway quick start guide: https://github.com/ttn-zh/ic880a-gateway/wiki
- The Things Network: https://www.thethingsnetwork.org
- The Things Network console: https://console.thethingsnetwork.org/gateways/register
- The Things Network APIs: https://www.thethingsnetwork.org/docs/applications/
- The Things Network MQTT protocol: https://www.thethingsnetwork.org/docs/applications/mqtt/
- The Things Network golang example and GoDoc: https://godoc.org/github.com/TheThingsNetwork/go-app-sdk#example-package
- Installing Prometheus on Ubuntu: https://linoxide.com/linux-how-to/install-prometheus-ubuntu/
- Grafana: https://en.wikipedia.org/wiki/Grafana
- Installing Grafana: https://grafana.com/docs/grafana/latest/installation/
« 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
-
PipeWire 1.0 Officially Released
PipeWire was created to take the place of the oft-troubled PulseAudio and has finally reached the 1.0 status as a major update with plenty of improvements and the usual bug fixes.
-
Rocky Linux 9.3 Available for Download
The latest version of the RHEL alternative is now available and brings back cloud and container images for ppc64le along with plenty of new features and fixes.
-
Ubuntu Budgie Shifts How to Tackle Wayland
Ubuntu Budgie has yet to make the switch to Wayland but with a change in approaches, they're finally on track to making it happen.
-
TUXEDO's New Ultraportable Linux Workstation Released
The TUXEDO Pulse 14 blends portability with power, thanks to the AMD Ryzen 7 7840HS CPU.
-
AlmaLinux Will No Longer Be "Just Another RHEL Clone"
With the release of AlmaLinux 9.3, the distribution will be built entirely from upstream sources.
-
elementary OS 8 Has a Big Surprise in Store
When elementary OS 8 finally arrives, it will not only be based on Ubuntu 24.04 but it will also default to Wayland for better performance and security.
-
OpenELA Releases Enterprise Linux Source Code
With Red Hat restricting the source for RHEL, it was only a matter of time before those who depended on that source struck out on their own.
-
StripedFly Malware Hiding in Plain Sight as a Cryptocurrency Miner
A rather deceptive piece of malware has infected 1 million Windows and Linux hosts since 2017.
-
Experimental Wayland Support Planned for Linux Mint 21.3
As with most Linux distributions, the migration to Wayland is in full force. While some distributions have already made the move, Linux Mint has been a bit slower to do so.
-
Window Maker Live 0.96.0-0 Released
If you're a fan of the Window Maker window manager, there's a new official release of the Linux distribution that champions the old-school user interface.