Because my green thumb is useless, but I can solder and program an Arduino
.
My better half and favorite co-author very much likes her houseplants. It is not unusual for her to come home and unapologetically present a new acquisition which she will manage to find space for. Now, while I fully support this hobby, I am not particularly good at it, and so my involvement in it usually only rises to the level of “hold this so I i can put some soil around the roots”. That is, until we started talking about the important variables to monitor in order to keep a plant happy.
One of my hobbies is electronics. I love to tinker with Arduinos and the like. So once the important variables (moisture, temperature, light, and humidity) were identified, it was not long before we got the idea to build a thingy to keep track of these. It also doesn’t hurt that my better half is also an econometrician, and so is fully on board with having more data to work with.
So I set out to build this thingy with the following goals:
I did this in a few stages. Here they are!
The first attempt was a proof-of-concept with just one one component. For this, I used the Monk Makes Plant Monitor, which measures temperature, humidity, and soil moisture. Three out of four isn’t too bad for the first try! This was a relatively easy hook-up:
Arduino | Plant monitor |
---|---|
3.3V | 3V |
GND | GND |
TX | RX, through a 1k resistor |
RX | TX |
And then I just ran the example code supplied in the above link. Everything worked, moisture went up when I dropped it in a cup of water, humidity and temperature went up when I breathed on it, all good!
The problem with this thingy was that it had to be plugged into my laptop for us to be able to read the data. As this was not a good long-term solution, I asked my better half if she would rather have the readings shown on a screen, or posted to somewhere on the web. She opted for the latter, so on the next iteration, I focused on connecting it to the internet.
As much as I love Arduinos, the cheap ones don’t connect to the internet. This meant for the second thingy, I would have to choose another microcontroller to use. Fortunately, I had a whole lot of WeMos D1 mini clones that would do this perfectly. I also had acquired some other capacitave soil sensors that didn’t require serial communication, and were substantially cheaper. This would mean I’d need to also have temperature and humidity sensors, so I went with the AHT10, which does both over I2C with 3.3V logic. This last part is important becuase the D1 mini pins work with 3.3V, not the 5V of Arduino.
On top of these, I added a momentary switch for recording events (e.g. so we could press it when we watered the plant), and two LEDs for communicating different things about the status of the thingy.
For the software, I found this tutorial on how to send data from an ESP8266 module (of which the D1 mini is one) to a Google sheet. This seemed like a good solution, as we could both have access to the data easily.
From here, the only thing left to do was add in a light sensor. It is fairly easy to set up a circuit that responds to light: use a light-dependent resistor in series with a (regular) resistor, and read off the voltage between them. However here the D1 mini poses a problem: it only has one analog pin, and I was already using it to measure moisture. One possible solution was to use a multiplexer integrated circuit, like a 4051. I had some of these lying around, but it seemed like overkill: it could handle eight analog inputs (I only needed two), and needs three digital inputs to manage, and that would require more wiring. Fortunately, this tutorial was exactly what I needed: basically, instead of powering the two sensors with the 3.3V pin so that they were always on, you use separate digital pins for power. This means that you can always power down a sensor, so its voltage goes to zero. Diodes then ensure that the signals only go to the analog pin, and don’t get drained into the other sensor.
Here is what I ended up with for the hardware:
.
That is, in order to take the two analog readings:
Some other features of this design that I have are:
Finally, here is the Arduino code I used to program the microcontroller.
I set the Thingy to log data every ten minutes, which is probably overkill for this project, but I got impatient.
Here is what the data look like:
.
Some things to note about these:
Probably the thing I’d like to fix the most out of these is a connection problem I am having with out WiFi. Roughly every 24 hours, the thingies get stuck in their transmit stage (I know this because of the status of the LEDs on the boards) and just stop sending data. Ironing this out would mean I would not need to go and reset them every day or so. Resetting is not hard to do, but it does mean that I need to be watching the data come in somewhat regularly so that I notice it quickly. Ideally these things would be set-and-forget, and we would only have to look at the data when we wanted to.
Once we have collected enough data, I would like to re-program the boards to send notification reminders for watering.