I had thought that this might be a common situation, but a lot of googling and forum searching hasn't turned up anything, so I thought I'd ask here - apologies in advance if this is the wrong board, as I'm new to these forums! Perhaps I'm searching with the wrong terms? If so, any hints on what to search for existing solutions welcome!
I'd like to add a gate controller to a home automation system. The gate controller is in place and working, and has a terminal block to allow wiring in external switches for both:
- sensing (e.g. open & closed limit switches, and photocells - these are already wired in as NC switches, and being used by the gate controller), and
- actuation (e.g. start open, start closed - not yet wired, but intended to be NO switches).
The controller is a CTR-06 and the full spec is here. An extract of the wiring diagram (pg 8 ) for the terminal block is attached.
I'm comfortable with the actuation (I've tested shorting terminals 11 & 12 and it successfully starts and stops the gate), but I would like to be able to sense the status of the limit switches and photo cells without impacting on the existing controller's functionality.
I've done some measurements, and the 3 input terminals (5,6,7), are at 0V compared with COM when the switches are closed (i.e. the normal situation), but go up to 5V when the switch is activated - e.g. when the limit is reached, or when the photo cell is blocked.
Based on this, I speculate that the existing gate controller has an internal pull-up resister to a 5V reference - and this is at the heart of my uncertainty about how to sense the status of these switches.
Considered Options and Concerns
I've considered 3 possible devices, but I'm nervous that all 3 options have risks, and I'm wondering if anyone has any suggestions or alternatives to help me avoid releasing the magic smoke - from either the existing controller, or anything I add!
The 3 options I'm considering are: Arduino, ESP8266-based device, Shelly 2.5
It seems that if I configure Arduino GPIO pins as INPUT and leave them as floating (i.e. not INPUT_HIGH), then I could just wire them to the existing terminals (e.g. 5, 6 7), wire between the controller's terminal 8 (COM) and the arduino's GND, and leverage the existing controller's pullup resister to ensure that the pin isn't actually floating.
When the switches are closed, the existing gate controller's input and the arduino's input would both be pulled to ground by the switch, registering as LOW input, when the switches are open, the gate controller's input would pull up to 5V and the arduino input would also be pulled up to 5V.
My concern here is that the gate controller's 5V reference may be different to the arduino's power supply, and I'm nervous about an over-voltage or over-current on the arduino input.
I'm also nervous that this would effectively create two parallel circuits through the two inputs and since I don't really know the internals of the gate controller, I'm not sure what the impact might be on either of them.
As the ESP8266 is at 3.3V, I have a similar concerns to with the Arduino, but even stronger as it's definitely above the ESP8266's voltage. I have read that in theory the ESP8266 is tolerant to 5V inputs, but also lots of people commenting that they toasted their chips with inputs over the standard voltage. In theory any solution to the Arduino concerns could also solve for an ESP8266 (with adjustments for 3.3V).
The Shelly 2.5 is basically an ESP8266, however I think it is default configured to utilise it's own internal pull up resister. I suspect this is a bad idea as it basically creates a potential difference between the two internal reference voltages across the two pullup resisters and I'm not sure what that will do! I think if I flash the Shelly with something non-standard I might be able to explicitly configure it to not use the pullup, but I haven't been able to verify that.
I have considered some solutions to the issues noted above, but not sure if there is more I should think about:
Adding components to avoid over-current or over-voltage
I wondered if adding some combination of diodes & resisters could help protect the arduino/esp without impacting the existing gate controller. In particular a resister between the switches and the arduino input pin to help limit current flowing into the arduino - but without knowing the internal pullup resistance in the existing gate controller, I'm not sure what resistance to use to ensure the resulting voltage doesn't disrupt the existing controller's input.
It seems that if I wire an opto-coupler between the existing switches and my device (arduino or esp), it should ensure electrical isolation, but still allow to signal whether the input is HIGH or LOW into my device. I have found a cheap board with 4 optocouplers on it, so this seems like it might be a good bet.
One thought here is that since the gate usually closed, the 'closed limit switch' is normally active and since it's NC that means it's usually HIGH, so one of the opto couplers will be almost permanently 'ON'/'HIGH', not sure if that is a concern.
Put my controller between the switches and the gate controller
Another option might be to wire the switches directly into my controller, so that they are not shared, and then wire outputs from my controller into the gate controller, and use software to mirror the inputs to the outputs. At first glance this seems safe, but also seems to add risk - ideally I want the existing gate system to work fine, even if my home-grown kit fails for some reason (likely my error!).
I could just wire up reed switches to sense gate limit, and a second photo cell dedicated for use in my own controller. This seems simple enough, but also doesn't seem ideal to be sensing statuses that may not be the actual statuses sensed by the actual gate controller, so not a preference.
Replace the gate controller
I suppose in theory it should be possible to replicate the functionality of the gate controller in my own controller, as well as have access to the inputs, and completely remove the existing controller. The main issue here is that it would involve rewiring mains power to motors, and in my country that requires an electrician - I was really hoping to be able to do this on my own.
Thanks for reading, and as this is my first post please do let me know if I'm in the wrong area, or have inadvertently breached etiquette. For some context, I do have a degree as an electrical engineer, but it was > 20 years ago, and I've spent my whole career working in business software systems, so this relatively new foray into home automation electronics (this is my second project) is an exciting mix of nostalgia and faint memories resurfacing Suffice to say, I feel like I should be able to answer this question myself, but I just don't trust my memory of long ago ELEC subjects!