My next project - Optoisolators?

Hi guys,
Looking for a bit of help in product selection please.

I need to make my Garage Door Openers smart:) and get the open / close functionality into HomeAssistant. The ESPHOME and Homeassistant part are easy. The bit that has caused me a headache is how to actually control the door opener as it only comes with RF remotes.

Turns out there are 2 Normally Open Dry contacts on the motherboard that need shorting out momenterily to instigate a UP or DN movement.

I am thinking that I can use any old ESP32 / PICO / Micro-controller and connect one side of an Optoisolator between a GPIO and GND and the otherside between the 0V and OSC pins on the door opener (these are the two that need shorting to make the door open / close).

I am currently thinking that this or this, or even this would do the job. Essentially I am thinking I just need to use the ESP32 to drive one side of a relay, which will then create the circuit. / short between the door opener pins on the other side.

What do you guys recon, should this work or do I need some other form of solid state relay?

Thx
Jon

1 Like

You need to determine the voltage across those terminals and the current that is passed when they close in order to select a suitable device for the switching. The devices you have listed will all have limits on the voltage and current they can handle, so they may not be capable of safely switching that load. On the other hand, a mechanical relay which could probably handle any likely load with plenty of margin for safety might create too much switching noise for the control board, and might be more much complexity and cost than is needed. A proper analysis of exactly what is getting switched will enable you to choose the most effective option.

1 Like

The easiest solution may be something like Ks0058 keyestudio 4-channel Relay Module - Keyestudio Wiki. I’ve used the 8 channel version to control water solenoid valves from an Arduino and they work very well. The inputs are opto-isolated, though that probably isn’t necessary. The outputs are floating contact closures, suitable for your application. They do need a power supply with enough capacity to drive the relay coils (e.g. power an Arduino from 12 V plug pack), and they might be over-rated but they are inexpensive and readily available in Australia.

Logic level drive power FETs (KS0449 keyestudio 3-Channel IRF540NS Large Current MOS Module - Keyestudio Wiki) are another option, though they aren’t fully isolated, so whether they ar5e suitable depends on the details of what you are connecting to. For example if your microcontroller power supply is isolated from the load ground, it may be suitable.

Thanks Peter. I do have a 3 channel version of this that is sat on top of a raspberry pi at the moment on another project. I could borrow that for testing purposes.

Thx,
Jon

Thanks Jeff.
I must admit, when I spoke to the technical support guys for the door opener I never thoguht to ask about voltage or current passing between the contacts.

I am assuming however, it will be low voltage with a low current - The said bell-wire and a door-bell switch is the most common connection.

I’ll pull the cover off the motherboard and put a volt-meter between the 2 pins.

1 Like

I also just found this on the core electronics website: a Solid State Relay

Will this board accept a GPIO at 3.3V or 5V input from an ESP32 to trigger the relay, or does it need to be below 2V? The description on the site confuses me.

I did try to short the pins today - with a simple jumper-wire. Sure enough, the door opened and closed with a momentry short across the terminals.

Thx
Jon

Hi Jon

As stated in the product title this relay will only switch AC loads.
Cheers Bob

1 Like

My bad - I missed that. Thanks.

2 Likes

Hey @Jon13024,

Any more information on the load across those 2 pins?

It shouldn’t be hard to find a suitable relay but having that information would be super useful in tracking down the correct one!

Update.
I got nothing further out of the Door opener technical team, so purchased on of these, knowing that they could handle just about any load the opener might through across it and is microcontroller friendly.

In short, it all now works perfectly:)

With an ESP32, relay, POE-5V adapter and some wire in hand, I got to work.

My immediate problem was making the relay operate as I expected within ESPHOME. It was either on when it should be off or on and then not turn off as expected. A bit of googling later and found that I had fallen into the traps that many others have found before me!! Ive added working relay / switch code for anyone else that is using Homeassistant with ESPHOME. Essentially the door opener is expecting a momentary short across two terminals. I found that turning the relay on for 1s and then turning it off again is enough time for the door to reliably function and not too long that it drops into a start/stop/start routine.

switch:
  - platform: gpio
    name: ${friendly_name} Relay
    id: relay
    icon: mdi:garage-open-variant
    pin:
      number: 4
      inverted: True
      mode:
        output: True
        open_drain: True
    restore_mode: ALWAYS_OFF
    on_turn_on:
      then:
        - wait_until:
            condition:
              for:
                time: 1s
                condition:
                  - switch.is_on: relay
        - switch.turn_off: relay

For those interested, the ESP32 that drives the relay has no physical switch connected directly to it, but is triggered over wifi by a physical button on an existing smart switch (Bunnings Smart switch (Deta) flashed with ESPHOME) in the house.
Once the switch detects the double click, it triggers the switch’s internal relay (so I can hear something happening), calls homeassistant to trigger the garage door relay and then turns off the switch relay, ready for the next double-click. The below is the action that does the thing once the double-click is detected.

switch:
  - platform: gpio
    pin: 15
    id: relay4

  - platform: template
    name: ${device_name} Shed Main Garage Door
    id: relay_template4
    lambda: |-
      if (id(relay4).state) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - switch.turn_on: relay4
      - homeassistant.service:
          service: switch.toggle
          data:
            entity_id: switch.garage_door_opener_front_relay
      - delay: 3s
      - switch.turn_off: relay4
    turn_off_action:
      - switch.turn_off: relay4

Hope this helps someone else in the future.

R
Jon

1 Like

Well done getting this working. Hopefully you will save someone a bit of a headache down the line.

Hi Jon
I am not trying to kill off your project here but I would be a bit wary of that relay module.

It might give you one too.
There has been a lot said (by me mostly) in the past about operating these relays at 3.3V. OK some might work but if you check the data sheet for the relay you will find that 3.3V falls well outside the “must operate” voltage which is 75% of the rated voltage (5V).

So if the system malfunctions or fails down stream a bit my first suspect would be the relay itself. There exists 3.3V versions of this relay. If my memory serves me correctly you can’t power the relay separately (with 5V) with this module. It has to be the same as the logic voltage.

Might pay to do a little research.
Cheers Bob

1 Like

Thanks for the heads up Bob. I must admit, I didnt look at the spec sheet, just the descitption on the Core website. Im using. D1 Mini and my VCC on the relay is connected to VBUS, ie 5V.

At the moment its super reliable. I will however make a mental not of your comment - thanks.

Time will tell.

Thanks again,
Jon

1 Like

Hi Jon

That should be OK. My concern was the use of this 5V relay at 3.3V. the spec says the must operate voltage is 75% of the relay rating, in this case 5V. 3.3V is only 66% so it would be 10% outside of spec. A bit dubious in my book.
I might point out here that the relay has to be switched by something, Transistor or Mosfet usually. No matter what there will be a voltage drop across this device which has to be subtracted from Vcc to arrive at the effective voltage across the relay coil. This will make the situation a bit worse.

It is this departure from spec that would be my concern if using one of these modules at 3.3V Vcc. Some might work and some might not while in fact the relay is still OK.
Cheers Bob

1 Like