Close

First pic

A project log for ESP32 Greenhouse Monitor

Collect temp/humidity, soil moisture, sunlight data to be stored on local web server

jeff-taylorJeff Taylor 01/25/2018 at 16:200 Comments

The display is nearing its final version, I believe, and I thought it would be a good time to grab a picture of it.  At the top-left is the temperature in Fahrenheit (also easily displayed in Celsius).  Directly below that is the current humidity.  To the right the four bars show the wifi strength, sunlight strength, and two bars for soil moisture inputs.  Underneath that are icons for heaters, and a fan, and a water valve (in operation these would blink while each device is turned on).  The bottom line is reserved for text showing such things as the current barometric pressure and the device's IP address obtained from the wifi network.

It turns out that creating the bitmap for images which are greater than 8 bits wide is rather a pain in the...  The larger icons are actually 12x12, and after some experimenting I figured out that I have to take the last 8 bits first, and then the first four bits after that.  So if your bitmap for a line was 000011111111 then the actual line of code to hold it would be: B11111111, B0000.  Fun, eh?

So at this point the hardware connections have been mostly worked out, it's just a matter of fine-tuning the divider resistor for the light sensor and possibly the soil moisture sensors.  There are enough pins exposed on this board to handle three analog inputs and eight relay outputs, however I would rather add in a TTL latch so I could control more relays and still have I/O pins left over on the ESP32 for more inputs.  An example here would be a 74LS259, which only requires a 3-bit input plus an enable line and would also control eight relays.  If I can find a similar chip with a 4-bit input then we could control 16 relays with only five I/O lines from the ESP32.

Within the code, the next step is enabling it to try and auto-connect to any available open wifi and if that fails, set itself up as an access point so you could connect to it directly from a phone or tablet and use its web page to set up the proper wifi credentials.  As for the web page itself, I've had some ideas there...  I would like to be able to associate each relay with a set of conditions.  For example, turn on relay one (heater) if the temp drops below 50F.  And if soil moisture sensor 1 drops below 20% then turn on the water for 5 minutes, but don't allow it to come back on again for another 55 minutes.  Basically use the web page to set up multiple conditions for each relay based on the sensors we have available to try and regulate the greenhouse conditions.  The worst problem will be in keeping the web page small enough that it still fits in the ESP32's memory.

Discussions