My ESP8266 flashes error (fast flashing) on boot up and reboots constantly. It’s started once I added code for setting a WS2811/12 LED on/off then controlling a relay. The debug output doesn’t start either. I’m thinking I have mangled the code in some way that allows it to compile, but the code that’s comes out must be bad in some way.
The code runs when I block out the whole switch: section so I’m thinking the problem is in there. The relays worked until I added the code for the WS2812 LED’s.
It’s probably simple (I’m only new to YAML/ESPHome), but after 2 days of trying to get it to work I have hit a wall…
You are using gpio16 for relay. This pin is used for sleep wakeup and should be high at boot. Maybe it’s pulled down via external resistor (the one who drives relay transistor) and prevents from correct booting?
It’s not too good idea to use this pin unless you have no other options.
The board is one of those 4 relay boards from Aliexpress and has worked great so far. The pin is in the correct state for bootup and the code I have used before works well, even for the relay driven by GPIO16.
It will run without any of the light.addressable stuff so I suspect I have just done some bad code…
The board is supplied by a 12V 1Amp plug pack. I can get the code to run fine with the LED’s all on if I don’t try driving individual lights on the 8 LED strip. I could change the color etc, but only if I control them all as a group. It went wrong when I tried to control them separately.
Other thing is, am I using the right method for controlling the WS2812 LED’s individually? I looked for code that could showed a more direct indexing of a particular light but couldn’t find any. Using range_to: and range_from: seemed a little excessive to just change one LED.
Try to flash bin file via uart again. It happened to me before that all of the suddena after OTA update board didn’t work. Reflashing via uart helped. Coulnd’t find a reason, i guess it was an error when transferring update file via OTA…?
Looking at the debug info I saw the line [18:10:53][D][switch:037]: ‘Relay1’: Sending state OFF. So I commented out that block so relay2 would be the first relay the program would get to and now it’s relay2 that is the relay mentioned. I wonder if there is some kind of underlying issue with switch: and using light.addressable_set: that doesn’t work when sending state info to HA?
I have removed the LED code. Not being someone who can program very well, I can see this is way beyond my skill set, and after 20h of digging around forums it would seem C++ knowledge would be needed to be able to debug this further…
Replying to an old post as I had the same issue with the Light addressable_set call causing a boot loop, with the same error as the OP :
I don’t know the root cause of this error, but I found that if I prevented calls to addressable_set duirng boot/initialisation, then the error doesn’t occur. I did this with a global boolean with an initial value set to false, and only set to true at the end of the on_boot script. I then test this global in the operations that were causing the calls to addressable_set.
It’s not pretty, there’s probably more elegant ways, and it doesn’t solve the underlying issue, but hopefully this may help someone else having the same problem…
esphome:
on_boot:
- lambda: "id(boot_completed) = true;"
globals:
# This is used to stop a boot loop caused by addressable_set
- id: boot_completed
type: bool
restore_value: no
initial_value: '0' # false
binary_sensor:
# Physical button that toggles a light output
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
id: button_1
on_press:
then:
- light.toggle: light_1
output:
# GPIO output for the light
- platform: gpio
pin: GPIO12
id: relay_1
light:
# Addressable RGB LED
- platform: neopixelbus
id: leds
type: RGB
variant: WS2811
pin: GPIO13
num_leds: 1
# Light connected to the relay_1 output
- platform: binary
name: "Light 1"
id: light_1
output: relay_1
on_turn_on:
- if:
# addressable_set seems to cause issues during boot, so ignore this during boot
condition:
lambda: 'return id(boot_completed);'
then:
- light.addressable_set:
id: leds
range_from: 0
range_to: 0
red: 0%
green: 100%
blue: 0%
on_turn_off:
- if:
# addressable_set seems to cause issues during boot, so ignore this during boot
condition:
lambda: 'return id(boot_completed);'
then:
- light.addressable_set:
id: leds
range_from: 0
range_to: 0
red: 100%
green: 100%
blue: 100%