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
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.