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 email@example.com Adafruit Unified Sensor@1.1.2 ESP8266 and ESP32 OLED driver for SSD1306 firstname.lastname@example.org
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 will need to store it so that I know if the propagator actually does get too cold or to dry when I was not there eyeballing it. I see two options:
- BRUTE FORCE - Add a Raspberry Pi, fire up Grafana or whatever. A Pi can do all the IO we need so could even ditch the NodeMCU.
- Keep it small (but-probably-not-so-simple) - Add an SD card for data logging right from the ESP8266 and run a tiny webserver on the thing to show the data directly.
It would be fun to see how far I can push it with the ESP, but on the other hand I'm not sure I will be feeling up for that kind of "fun" down the line 🤔