Let me start by saying that I’m not a developer, or have much experience with designing electronics, but I’m what I like to call a Lazy Engineer(tm).

Pre-face: Last year I decided to start growing my own vegetables – tomatoes in fact. And nothing made me happier than literally picking the fruits of my labor at the end of summer.

This year, however, I’m ready to use my lazy engineering skill(tm) to automate the hard bits of vegetable growing (Or as I like to call it Vegimation)

So, what do you need to automate your vegetable growing awesomeness?

  1. Senors – how are you going to know when your plants need feeding
  2. Processors – your electronic brain to decide when to water your plants
  3. Outputs – you’re going to need a motor or a valve to get your water to the plants
  4. Batteries – Unless you’re running power cables across your garden, you’re going to need batteries.

Inputs:

I decided to monitor only a few inputs to keep v1 nice and simple. If this is successful, I can scale out with more sensors in v1.1.

  1. Soil moisture – This is how we know whether our plants need watering
  2. Temperature sensor – How hot will it be today
  3. Light sensor – How much sunlight are my plants getting and do I need to move them to a different spot?
  4. Weather forecast – will it rain later on today?

Processors:

I decided (after a short google search) that I could use the NodeMcu v3 (ESP8266) to base my automation around:

  1. It was cheap € 1,88 LINK
  2. It had built-in WiFi
  3. It works with the Arduino IDE
  4. It can draw as little as 20μA in deep sleep mode. Paired with a 3000mAh battery, this could last 6.7 years on a single charge!* (IoT battery calculator)
  5. It has 1x 10bit Analog input – more on this later.

*Obviously this is theoretical and doesn’t take into effect the loss via the low dropout regulator and the conditions of the environments on the battery.

After spending some time with the NodeMCU, maybe a better option would have been to go with the newer ESP-32 variant. (see here)

Problems with the NodeMcu v3:

  1. It doesn’t fit into a standard bread-board
  2. It comes with the 5v – 3.3v AM117 voltage regulator, which has a high quiescent current (~4mA) and in order to get the lowest possible current draw in deep sleep, you’re going to have to get out your soldering iron and remove it from the board.
  3. Deep sleep mode will cause your code to terminate from the point it goes into deep sleep. When it wakes up, it will start your code from the beginning again, as if it’s just been powered on.*

*There are ways to persist some data into storage, so that it is available when it wakes up, but it’s a bit complicated.

Sensors

Now here’s where you open pandora’s box. There are hundreds of different sensorsavailable for Arduino’s and Arduino type clones. Some of them run on 3.3v only, some work with 3v – 5v and some only operate at 5v. Make sure you know what the input voltage of your sensor is, before connecting it to your NodeMCU!

With a bit of reading, I decided to use the following sensors in my project:

After connecting them all and writing some test scripts, I have decided to drop 2 out of the 4 sensors.

The BH1750 is a great little sensor. It is simple to use and connects to the NodeMCU via the i2c protocol. This is a massive benefit, as it’s like the USB for Arduinos. You can connect many different sensors to just 2 ports on the NodeMCU (SDA and SCL), simplifying you life. KEEP

The Capacitive soil moisture sensor is a great addition to the suite of sensors. No metal contacts actually touch the soil, so it should theoretically be protected from the environment and the soil will be protected from the rusting. However – it doesn’t work with anything less than 3.3v. Now you may think, hey, the NodeMCU outputs 3.3v?! Well, it actually outputs 3.26v, which is not high enough to drive the soil moisture sensor. So this one goes into the projects bin for another time. BIN

The DHT22 is a cheap sensor that has been used in many Arduino weather stations, partly because of the low cost, and the easy to use library built into the Arduino IDE. However, the temperate sensor only updates every 2 seconds, and it sometimes fails to initialize when the NodeMCU powers up. (giving “NaN” values instead of actual temperate) The only way to fix it is to power up the NodeMCU and disconnect data pin and plug it back in. BIN

The rain sensor – basically two metal traces (+/-) separated by plastic. Not the most sophisticated of sensors, but definitely the most reliable. Plug one end into 3.3v and the other into Analog Input pin and you have yourself a moisture sensor. KEEP