UART interlock? [Solved]

I am trying to get something setup to prevent shorting a motor if both relays are turned on at the same time. I want to prevent this on a UART connection, but am unsure how to complete this. I know on GPIO I can use the interlock group and this works well for that, but I cannot figure it out for the UART. What am I missing?

uart:
  baud_rate: 115200
  tx_pin: GPIO1
  rx_pin: GPIO3

switch:
  - platform: template
    name: 'Fan Low Speed'
    icon: "mdi:fan-speed-1"
    id: relay1
    turn_on_action:
      - uart.write: [0xA0, 0x01, 0x01, 0xA2]
    turn_off_action:
      - uart.write: [0xA0, 0x01, 0x00, 0xA1]
    optimistic: true
  - platform: template
    name: 'Fan High Speed'
    icon: "mdi:fan-speed-2"
    id: relay2
    turn_on_action:
      - uart.write: [0xA0, 0x02, 0x01, 0xA3]
    turn_off_action:
      - uart.write: [0xA0, 0x02, 0x00, 0xA2]
    optimistic: true

May I suggest an alternative? Go for a hardware solution, if you can. It sounds like you could blow up the motor or some other components if this goes wrong (when you get a short-circuit). With a software interlock there is a possibility that the timing or something else could go wrong. A software interlock should be fine to avoid two zones of an irrigation system running concurrently, but maybe not for this.

Previous advice is right. Never relay on software in such situations. Allways should be error proof hardware protection first.

This is simply a controller to turn on a fan at low speed or high speed. If the suggested method is hardware to control such a feature, is there anywhere you can direct me to such a controller?

For the instance used, I am just looking to not allow both on at the same time in the lamda settings but am unsure how to do it.

instead of trying to figure it out, why not simply turn off the other relay before turning on the desired relay?

uart:
  baud_rate: 115200
  tx_pin: GPIO1
  rx_pin: GPIO3

switch:
  - platform: template
    name: 'Fan Low Speed'
    icon: "mdi:fan-speed-1"
    id: relay1
#
# Turn off the second relay.
# Then turn on the first relay.
#
    turn_on_action:
      - uart.write: [0xA0, 0x02, 0x00, 0xA2]
      - uart.write: [0xA0, 0x01, 0x01, 0xA2]
    turn_off_action:
      - uart.write: [0xA0, 0x01, 0x00, 0xA1]
    optimistic: true
  - platform: template
    name: 'Fan High Speed'
    icon: "mdi:fan-speed-2"
    id: relay2
#
# Turn off the first relay.
# Then turn on the second relay.
#
    turn_on_action:
      - uart.write: [0xA0, 0x01, 0x00, 0xA1]
      - uart.write: [0xA0, 0x02, 0x01, 0xA3]
    turn_off_action:
      - uart.write: [0xA0, 0x02, 0x00, 0xA2]
    optimistic: true

@FredTheFrog THANK YOU!! I am still learning and I knew someone would see something I didn’t think of.

You’re very welcome. Been that, done that. Still learning, every day. :slight_smile:

OK so what exactly is a software interlock? It’s a software check to see if relay one actually shuts off before relay 2 is turned on.

Now relays don’t respond back their state, like hey I got the message turn the other relay on. All it can do is check to makes sure that the off command is fired before the on command.

This is still considered dangerous when dealing with AC, it’s even worse when not using a software interlock. Like you are now.

You can isolate the two power supplies on relay 1. This way it’s either speed 1 or 2. Relay 2 can disconnect power to the fan.

2 Likes