PiOT Relay Board Handshake Confirmation
One of the features of our PiOT Relay Board is the ability to activate and deactivate it using a handshake pulse train. This is a neat little feature, however wouldn’t it be nice to know with confidence that when you’ve sent the pulse train that the relay board has indeed activated or deactivated?
Well it’s possible! At the cost of one relay…
To do this simply wire up one of the relays as shown in the below diagram. We’ve also included a LED in the circuit for visual confirmation as well!
The value of the resistor connected to the LED will depend on your LED, but a value of about 100ohms should be fine.
We also use a current limiting resistor to protect the GPIO pins, a value of 10k is perfect.
Here’s a little breakdown of the circuit:
We connect the 3v3 GPIO pin to the Normally Open (NO) port of the relay
Connect a GND pin to the Normally Closed (NC) port of the relay
Connect a free GPIO pin (GPIO21/pin40) to the Common (COM) port of the relay via a 10k resistor.
We have also connected the + leg of the LED to the COM port via a 100 ohm resistor, and the – leg of the LED to a GND pin.
So how does this circuit work?
When the relay is off, the COM port is connected to the NC port, which we have connected to GND. In this state the LED is off and our input GPIO is LOW.
Once we turn the relay on, it connects the COM port to the NO port, connecting the COM port to 3v3. This then illuminates the LED and sets our GPIO HIGH.
With a bit of python code, we can detect if our relay board is activate by trying to turn on/off the relay and seeing if our input GPIO changes state. If when we try to turn the relay on, our input pin doesn’t go HIGH then we know the relay board is deactivated and we can send the pulse train to activate it. Simple!
The example code can be found on our GitHub here - https://github.com/modmypi/PiOT-Relay-Board/blob/master/relay_handshake_check.py