Close

Running out of space

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/28/2018 at 19:590 Comments

This display is so tiny that it takes a lot of work to arrange all the required pieces and still be able to tell what they are meant to represent.  I just uploaded a new image with what I think will be the final layout.  Most noticeable from the picture are the relay icons, which now show all 16 potential slots.  To fit these I had to compress the icons to 6x7 pixels, and I still can't create an image for lights that I like.  I have added a boolean array to keep track of the status of the relays, and have the icons blinking when the relay is turned on.  Another bit you can't see from the picture is that the bottom row of text now scrolls to the left.  I print two overlapping text fields to make the scrolling marquee continuous.

I'm still debating the idea of allowing this unit to try and auto-connect to any open wifi access points.  Realistically the device would not move around much (if at all) so it should only connect to a known SSID.  I added some code to re-check the connection and reconnect as needed every 30 seconds to make sure we stay online.  I could also create a rotating list of SSIDs and passwords here if I wanted to try connecting to several known access points.

There is now a working clock displayed on the bottom status bar.  When it sends data to the web server, I reply with a timestamp and time zone, and the ESP32 keeps track of the offset between real time and the internal millis() time.  I added a function time() which returns the actual calculated unix timestamp and it seems to stay fairly accurate.  I dropped the wifi signal overnight and the displayed time still appeared to be accurate in the morning.  The time is updated as the status bar scrolls so you can see it updating each time it passes across the display.

I've been working a bit on how to represent the triggers for each relay.  I think I can provide for all the possibilities with a 16-character string, but unfortunately arduino doesn't really handle string arrays.  I'll probably have to keep all the triggers in a single string, but if they are always the same character length then it is easy to read one trigger at a time.  Besides the current state of each sensor I also want to maintain an average and a trend for each.  The averages would be over the past hour and would be more reliable that the current value for some items such as the amount of sunlight.  The trends would represent rising, falling, or steady values and again would be calculated over readings from the past hour.  I'm also thinking it would be better to average out each reading over a 5-minute period, in between each time the data is sent to the server, to ensure a more accurate reading.

Which brings me to another point... the idea of running this device from solar power.  It occurred to me that having a solar-powered device and a device that runs a bank of relays is mutually exclusive -- you can have one or the other, and if you are triggering AC-powered devices then you probably don't care to run the ESP32 from solar power.  However I still want the ability to collect data from other locations using solar.  So while I am currently focusing on a powered device running continuously and able to control relays, I will also develop a second device that is just the bare ESP32 without a display, which still has the same sensor inputs but uses a low-power mode in between readings and only powers up wifi as needed.  This second device then should be able to run from solar power and a battery to meet the originally-stated goals.

Discussions