How an engineer takes care of a plant
I recently got a plant at work. For it to survive, it needs to be watered about twice a week. One day, a coworker came to me to tell me that my plant was dying from thirst, its leaves were all brown and dry.
I decided to do something, the life of a living being depended on me!
Of course, there was no way I would remember watering a plant multiple times a week. I could setup an alert using something like a Slack or Telegram bot, which is what another coworker did.
This is the smart thing to do, but I wanted to overengineer this a little.
So I bought a pump and water humidity detector of Amazon, and searched at home for a ESP8622, an arduino, a breadboard and some wires.
Right at the start, I knew that I wanted to have some kind of monitoring system for this. This meant that I also needed a true OS, so a raspberry PI was needed
Moreover, to be able to draw some cool graphs, I needed to gather some interesting data. I won't plot time over time! So, I got a temperature sensor too.
I connected the raspberry to the ESP using a usb port. I soldered all the sensors to the ESP (humidity and temperature) as well as the pump.
I had tested that everything worked before hand using a breadboard.
Then, I wrote a bit firmware code on the ESP to send the sensor data back to the raspberry. Back on the raspberry, I used a bit of Python to spin up a webserver to send the data and be able to control the sensor through REST requests. I used FastAPI but it was a bit overblown as I did not need to generate an OpenAPI schema, I think Flask would have been enough.
I was tempted to use a compiled programming language with no large runtime to install like Go, Rust or Nim but Python already had a serial library that worked and was simple to import, so I went with that.
I then built a good looking frontend for my phone with a little Plant icon and I was good to go!
When not using Arduino boards, you have to delve into the world of SDK and embedded real time OS. I used FreeRTOS which works pretty nice and always me to compile my C code from Windows and Raspberry PI OS into the ESP, and to be able to use a real IDE and not the one provided by Arduino.
It takes a bit more time to install the build tools at first compared to Arduino, but the long term experience is in my opinion a bit better.