Relay control

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/30/2018 at 04:000 Comments

A quick update tonight...  I've been looking at chips to handle the relay operations without the need for using 1 pin for every relay.  I thought something like a 74LS259, a 3-to-8 decoder with latching outputs, would be the way to go but adding more lines appears to be less than ideal.  I kept finding references to a 74HC595 and finally looked into it.  The chip takes a serial input using only three I/O lines, and there is already an arduino driver available to operate this chip.  Even better, you can add multiple chips together and they still only require the same three I/O lines to talk to all of them.  Now being a serial operation means that talking to these chips will be slower than other options, but we're talking about relays that will see cycle times in minutes or hours, so speed is not really a priority here.  I have a bag of these chips on order so once they come in I'll see how they perform at 3.3v.

In the meantime I will start setting up the code changes.  I'm going to add a variable to hold the number of relays in use, then I just need to create a bit register to push out the on/off state of all relays each time there is an update and pad it out to an even multiplier of 8 bits (one set for each 595 that is being used).  Of course the real problem will be figuring out how to display a virtually unlimited number of relays on this screen.  I might have to write some code to vertically scroll that section of the display.

If anyone is curious, there is a nice article here that describes the usage of this chip with a regular arduino: