Skip to main content

Plant monitor


First project of the year, and it’s hardware! I want 2024 to be the year of harware.

This one is a remote plant monitor. I made a proof of concept of this project using PlatformIO a long time ago, and I decided to revisit it. This time using rust and Embassy. It has a bunch of sensors that collect useful data when it comes to monitoring the state of a plant. The sensors I included for this version are:

  • HTU21D
    • Relative (ambient) humidity
    • Temperature
    • Dew point temperature
  • Capacitive soil humidity sensor
  • Photoresistor (light level)

And it’s all put into my first ever custom PCB!


You might be thinking: “…What happened to the copper layer?” And you’d be absolutely correct, I completely forgot I had to do that. I won’t forget next time though! (I fixed it on the repo) I also learnt that the default through-hole dimensions on KiCad aren’t ideal for header pins and for soldering. I’ll make sure to make the holes and pads bigger next time too. There also was some confusion picking the resistor footprint, so it’s in the wrong orientation (It’s standing up). I’ll take more care next time. Despite everything, I’m super proud with my first PCB to the point that I want to frame it.

I’m proud of the software side too. It’s quite a bit more techincally complex than what I usually make, and it even has server side stuff, which is way out of my comfort zone.

For the microcontroller, I used the ESP32-C3 (on a Seeedstudio XIAO formfactor). The C3 is riscV, which means it has official rustc support. I usually use an RP2040 for evertrhing, but esp-rs has way more mature wifi and internet support than the pico W does. Despite this, the docs can be lacking or sometimes completely inexistent (looking at you, esp-wifi), and the fact that they use Nightly means things break. I had put the firmware on pause to work on the hardware, and when I went back to finish the firmware, it was broken. After going through a dependency hell and then fighting with the compiler, I got it to work. It’s not ideal that it’s fixed to a specific rustc version, but the ecosystem is constantly changing and I can’t be bothered to propperly fix it now when it’s going to break again. I might revisit it once all these crates reach stability and make something robust, but who knows.

Working on this firmware was quite a stretch for me. Making DNS querries and POST requests! Who would think I’d ever do that. Even though it’s not the best written, fast or robust firmware, I’m happy with what I made.

And finally the server stack. I didn’t have access to my server while making it, so I used DigitalOcean. And I must say, it was an absolute pleasure to use! Really made the job easy. After some fighting with docker, I came out successful with a stack yml file. It uses grafana for the graphing (obviouslt xP), prometheus for the database as is usual, and prometheus’ pushgateway. I decided to use pushgateway because the plant and the server are on different locations (and therefore networks), and the network the plant is on is closed so it can’t be scraped.

Getting the firmware to make the correct request for it to be propperly pushed to prometheus was a fight. But I couldn’t be happier when I saw the following:

Plant Monitor request #

POST /metrics/job/plant_monitor HTTP/1.1
Content-Length: 15
Content-Type: application/x-www-form-urlencoded

dewt 11.279297

Server reply #

HTTP/1.1 200 OK
Date: Fri, 05 Jan 2024 18:50:38 CMT
Content-Length: 0

This meant I got it all to finally work, and that the project was finally done and fully working! The only thing left to do was deploy the server stack once I got access to my server some days after.

And here it is, the grafana dashboard:


I’m really happy with how this project turned out and looking forward to a year of more hardware and more complex projects.

Check out the project on gitlab: