I just moved from the city to the countryside and want to grow plants in our garden this summer. With about zero experience, the first attempt at growing some seeds, in a home made propagator made from toilet rolls and an ice cream box, failed miserably. Probably the air was to dry after I removed the cover. Or did the temperature get to low at night? Or was there not enough light? I figured adding some sensors would be a good way to figure out what I did wrong...
After the first attempt at growing sprouts failed miserably, I went through my boxes and had a look for things that might help me do better the second time around. The most obvious thing to monitor was temperature and humidity, but I was also pretty sure the sprouts had gotten too cold at night and wanted to have a heater in the box. I came up with:
NodeMCU (ESP8266) wifi-enabled microcontroller
AM2302 (DHT22) temperature and humidity sensor
SSD1306 0.96" LCD display
Car headlight lamp for a crude heating element
I did find an old salvaged power resistor that I wanted to use as the heating element, but it turned out to be broken. (Tip💡: don´t salvage and keep broken parts!? 😂) Then I found this old halogen bulb that I used to discharge NiCd RC-batteries back in the day and remembered vividly how hot it used to get 🔥. Since the NodeMCU is powered from the 5 V off a micro USB I hooked up the bulb to my power supply to see how much current it would draw at that voltage:
It turns out the current tops out at around 1 A so we should be able to run this off a regular USB charger as long as it is rated at more than 1.5 A or so - the ESP8266 will only use a few hundred milliamperes at most. 5 V times 1 A equals 5 W, which should be enough to nudge the temperature up a few degrees inside a small container (I hope).
In order to keep the lamp upright, I printed a small holder and folded a salvaged battery tab over itself to use as the negative terminal:
Next, I set up a new Platformio project for the NodeMCU in VSCode. I highly recommend Platformio for prototyping with Arduino-compatible boards by the way, much nicer experience than the Arduino IDE. One of the benefits is the library management; you can install different versions of the same library for different projects, so that your old projects keep working even if you upgrade to a newer version of some library for a new project. I added the following lines to `platformio.ini` to get Adafruit's DHT library and a driver for the SSD1306 display:
lib_deps =
DHT sensor library@1.3.8
Adafruit Unified Sensor@1.1.2
ESP8266 and ESP32 OLED driver for SSD1306 displays@4.1.0
Tip💡: Specifying a version with the `@x.x.x` syntax is what will ensure the libraries are not automatically upgraded and potentially break you code when you come back and try to compile it in six months time 😉
Mashing together some of the code examples from these libraries got me the temperature and humidity readings updating on the display every second as seen in the background on the first picture. Now I just needed a way to turn on the "heater". I went through by parts drawer again and somewhat hesitantly pulled out a TIP120. I knew people love to complain about these old school Darlington transistors and how you are not supposed to use them, but I for some reason had them laying around and did not have a suitable MOSFET that I could switch directly with my 3.3 V GPIO on the ESP8266. So I went ahead and hooked it up with a 2.2 k base resistor and added a hardcoded temperature value where the lamp would turn on. Now, if you scroll back up and compare the two images, you will see that the test with the power supply shines much brighter. Of course, this is caused by the silly TIP120 itself burning off more than one Volt so the lamp now only runs at 3 odd Volts. I say "of course", but of course I tried all sorts of things before remembering to read up some more on the TIP120. This might not have been such a bad thing if only I had planned to put the transistor in the box with the lamp, I mean it got hot after all. Maybe I can just re-purpose the pile of TIP120s as heating elements?
I put in an order for some IRF3708PBF MOSFETs which should work well all the way down at 3.3 V gate voltage. Will hopefully get those some time next week. In the meantime I'm thinking about the project architecture. If the information from the DHT sensor is going to be useful I...
This is a very non-technical first log entry just to explain the background of the project.
So, I just moved from the city to the countryside and want to grow plants in our garden this summer. I got some seeds and a tip to just plant them in toilet paper rolls cut in half. I saved up some rolls and got a couple of ice cream containers:
...put in some soil and the seeds:
...then covered them up and sprayed with water:
Finally the containers were covered with plastic and put on a windowsill in a south-facing window above a radiator to keep them both warm well lit. This started out pretty well and the sprouts soon got so tall I had to remove the plastic covering the containers:
However, a few days after this, the sprouts started falling over and drying out, even though I kept the soil fairly moist at all times. I tried reading up a bit. Probably the air was to dry after I removed the cover. Or did the temperature get to low at night? Or was there not enough light?
It was at this point I figured adding some sensors would be a good way to figure out what I did wrong...