Prevent Relay from triggering on power loss or broker reboot
djzang last edited by
I'm wondering if its not your code that is bringing the PIN high momentarily during boot up but the device or boot loader itself. Try flashing it with blank code and power cycle it and see if it triggers the relay still. If it does then you may need to put a pullup resistor on the pin to prevent it from happening.
Ben Andrewes last edited by
@rhuehn I know this is an old post but I had a similar issue which I solved by inserting a line in my sketch to pull the pin high before setting it as output
digitalWrite(RELAY_1_PIN , HIGH); //stops relays cycling state during boot digitalWrite(RELAY_2_PIN , HIGH); //stops relays cycling state during boot pinMode(RELAY_1_PIN , OUTPUT); pinMode(RELAY_2_PIN , OUTPUT);