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
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.