syssi / esphome-yeelight-ceiling-light

ESPHome custom firmware for some Yeelight Ceiling Lights
Apache License 2.0
138 stars 22 forks source link

Add YLXD05YL and YLXD01YL support (Mediatek devices) #10

Open splitatom44 opened 3 years ago

splitatom44 commented 3 years ago

Is it possible to assist with flashing the YLXD05YL and YLXD01YL models of the Yeelights? Photos attached of mainboards. Thankyou

20210403_074056 20210403_074107 20210403_074251 20210403_075015 20210403_075017 20210403_075709 20210403_075716

syssi commented 2 years ago

May be you should try to pull-down/pull-up the standby pin once. Just to make sure the lamp doesn't turn off in one of the cases. It's possible the LED driver / power supply runs permanently now and it would be better to use the standby pin.

wf1nder commented 2 years ago

May be you should try to pull-down/pull-up the standby pin once. Just to make sure the lamp doesn't turn off in one of the cases. It's possible the LED driver / power supply runs permanently now and it would be better to use the standby pin.

Have anyone found out which pin is 'standby' on mediatek board? Anyway, I have already installed the lamp on the ceiling, and I don't want to climb to it yet :) So far everything is working fine without any failures, including when I powering off/on lamp. But I will keep in mind in case something goes wrong.

Notrial commented 2 years ago

May be you should try to pull-down/pull-up the standby pin once. Just to make sure the lamp doesn't turn off in one of the cases. It's possible the LED driver / power supply runs permanently now and it would be better to use the standby pin.

Have anyone found out which pin is 'standby' on mediatek board? Anyway, I have already installed the lamp on the ceiling, and I don't want to climb to it yet :) So far everything is working fine without any failures, including when I powering off/on lamp. But I will keep in mind in case something goes wrong.

Any updates on how it's working so far? Is it dimming nicely? I have three of those, just want to be sure before I proceed :)

NopeFinder commented 2 years ago

Thank you all guys, I managed to get my YLDX01YL to work perfectly thanks to you. I set up my bluetooth remote a little different though. I used this repo https://github.com/dentra/esphome-components/tree/master/components/miot_ylxx0xyl_pair to get the bindkey off of the remote that came with my light and from the same author I used this repo https://github.com/dentra/esphome-components/tree/master/components/miot_ylyk01yl to make it work on the esp32 that's controlling the lights. I tried the ble_monitor setup linked above as well, but I believe it only works using the bluetooth on the home assistant itself (or I might have done something wrong), but the room I use the remote in is too far away for it to have a stable connection. I used pretty much the same yaml as wf1nder, just with the added automations for when a button on the remote is pressed, and it's working great so far!

spn91 commented 2 years ago

Hello, I somehow managed to remove the mediathek device from my YLXD05YL (was very hard with my beginner tools). If I compare my board with the screenshots in this issue, it seems that mine is different? Can someone help me please? :) i know that I have to clean the board first, but my bottle with isopropanol is empty..

42DCFC50-ED4B-4203-8CD2-1529EEA79095

syssi commented 2 years ago

I assume your biggest issue is the shorting of the two pads at the bottom left of the photo. ;-) Could you provide some more and high-res photos of your mainboard?

spn91 commented 2 years ago

Which pads do you mean? The ones which are completely „brown“? Is there something I can do to rescue the board? :(

Is Github compressing the photos? The last one should already be high-res.

But here some more.

A5E4B667-E368-4378-87DA-5676C72E3125 E5F015C4-58F1-4315-BE60-279A831CD6CE

syssi commented 2 years ago

It's fine now. I was talking about the two connected pins next to C39.

syssi commented 2 years ago

Could you provide a photo of the mediatek board? I would like to make sure this board hasn't changed.

spn91 commented 2 years ago

I have found this picture, it looks like this is the same layout: link

Do you know if this is a working configuration? I would connect 3,3V and GND to the same row where the START pin is, but all the others to same as shown in the picture.

spn91 commented 2 years ago

EB75115B-FB85-4EE8-8541-59C8D923F194

syssi commented 2 years ago

Looks good to me. The photo of @jaddel does fit to your board.

spn91 commented 2 years ago

Ok, thank you :) I will give it a try later today.

spn91 commented 2 years ago

Successfully changed the mediathek controller with an esp32 last night. Thank you and all the others for the great work on this repository! Just seven more yeelights left :grin: at least two of them are the new arwen lights (YLXD013-B)

syssi commented 2 years ago

Congratulations! 🎉 If you convert or flash new lights like the YLXD013-B please try to identify the required GPIOs using the stock firmware/microcontroller first. This can be done easily using a multimeter. Ping me if you need support.

spn91 commented 2 years ago

Converted the second YLXD05YL today. This time I have used the esp32-cam module from azdelivery because this one has a connector for the yeelight antenna onboard. It is working, but if i turn off the light it is transitioning from 100% to 0% and changing the colour from warm white to cold white shortly before turning off. The first ceiling light doesn't show this behaviour. Do you know what could be wrong?

Here is my yaml:

#Variables
substitutions:
  device_name:  deckenleuchte-schlafzimmer
  friendly_name: Schlafzimmer

esphome:
  name: ${device_name}
  platform: ESP32
  board: nodemcu-32s
  #board: esp32dev

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Yeelight-Test Fallback Hotspot"
    password: "xxx"

captive_portal:

output:
  - platform: ledc
    pin: GPIO13
    id: output_warm
    frequency: 4882Hz
    min_power: 0.07
    zero_means_zero: true

  - platform: ledc
    pin: GPIO12
    id: output_cold
    frequency: 4882Hz
    min_power: 0.07
    zero_means_zero: true

  - platform: ledc
    pin: GPIO14
    id: output_nightlight
    frequency: 9765Hz

light:
  - platform: monochromatic
    name: "${friendly_name} nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${friendly_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: on
    on_turn_on:
      - light.turn_off: night_light

The two YLXD013 will be the last ones, which I'm going to convert. The multimeter is ready ;)

syssi commented 2 years ago

Could you try to change the light to 100% warm white and 0% cold white and turn the light off again? This time the transition is "warm" only. Right?

If you mix WW and CW (f.e. 50/50) and turn off the ligh you should see the effect always. It's because the WW LEDs are less intense because of the low number of LEDs IMO. It's possible the gamma correction could help here.

spn91 commented 2 years ago

Alright, I have changed it to 100% warm white and now the transition is warm only. Thank you, I will also give the gamma correction a try.

dellorianes commented 2 years ago

I could convert a yeelight.celing.4 (YLXD02YL), following the above tutorials and also I could set the upper RGB ring light, wiring the pins R, G and B of

ylxd05yl-mediatek-pinout

I hope this helps a bit.

Find the code I used for it:

output:
  - platform: ledc
    pin: GPIO26
    id: plafon_rgb_rojo

  - platform: ledc
    pin: GPIO27
    id: plafon_rgb_verde

  - platform: ledc
    pin: GPIO5
    id: plafon_rgb_azul

light:
  - platform: rgb
    name: "Aro Plafón Salón"
    id: plafon_aro_rgb
    red: plafon_rgb_rojo
    green: plafon_rgb_verde
    blue: plafon_rgb_azul

I have also could get the encryption_key of the yeelight YLKG08YL dimmer, following option 5 of the guide (get_beacon_key python script) and could add it to Home Assistant though ble_monitor integration.

What I can not find is any info about how to automaticethe dimming of the light using the YLKG08YL sensor.. Someone have an example? thank you

adrez99 commented 2 years ago

I've been able to replace the Mediatek board with an ESP32 in YLXD02YL and almost everything is working but now I have flickering on low brightness (20%) on cwww light. If I set the temperature to 2700K or 6500K it doesn't flicker, just when both channels are mixed. I've tried different ledc frequencies but the behaviour is the same. Does anyone know how to fix this? Thanks

czAtlantis commented 1 year ago

I've been able to replace the Mediatek board with an ESP32 in YLXD02YL and almost everything is working but now I have flickering on low brightness (20%) on cwww light. If I set the temperature to 2700K or 6500K it doesn't flicker, just when both channels are mixed. I've tried different ledc frequencies but the behaviour is the same. Does anyone know how to fix this? Thanks

Hi, I just finished replacing the same model and it works fine. I used yeelight_light_ceiling20.yaml as template and wired the ESP32 according to this. One thing I had to change (and I got stuck there for a while) was LEDC frequency. But it was not so easy: I had this working quite fine, but night light was emitting strong audible noise. So I wanted to change the ledc frequency - Mediatek was running this at 20kHz (WW/CW at 10kHz) and esphome default is just 1kHz. So I changed it for the night light but it didn't help. It just limited my maximal brightness. Weird right? I checked it with oscilloscope and I was still getting only 1kHz with lower duty cycle. I later discovered (and don't quote me on this) that you can't just have multiple different ledc frequencies. More info here So I changed the frequency to 20kHz (10kHz was still emitting some noise) for all channels (WW, CW, R, G, B, Night_light) and it started working just fine. Maybe something like this happens in your case aswell?

EDIT: some measurements: Original mediatek idle power consumption: 1.2W ESP32 idle power consumption 1.1W ESP32 idle power consumption ( power_save_mode: none): 1.5W

Original minimum brightness non-night light 9.5W ESP32 minimum brightness: around 3W/channel = 3W only warm/only cold. 5.5-6W in mixed color sitation

EDIT2: if you need to open the light, I advise to spray isopropyl alcohol along the edge where the lampshade shell and base meets and then twisting the lampshade counterclockwise. The isopropyl alcohol acts as short term lubricant that eases the friction between sealing foam strip and the plastic shell. The same goes for closing - here you can spray retaining clips inside the light aswell.

When unscrewing/screwing in the LED board and taking out the main circuit board be careful and gentle - at least mine 4 lights I transformed have really brittle plastic inside. I assume it is because of the heat. I have them for at least 3 years and they have been used daily for multiple hours (6+). The plastic clips that hold the circuit board snapped almost instantly in 3 lights out of 4 - I fixed this in 4 places with silicone to the base.

I would like to thank everyone that mapped out the mediatek pins - I was hesitant to do the transformation myself but once I found this topic it really motivated me to do this.

Here is how mine looks like. Just some generic ESP32 dev board that has U.FL antenna connector

Board is held with regular silicone. Don't use hot melt glue because it wil probably thaw in the heat the LEDs generate

PXL_20221003_141004399

adrez99 commented 1 year ago

Maybe something like this happens in your case aswell?

Yes, that was the problem! I still had some flickering so I've set the frequency as yours (20kHz) and it works perfectly now!

syssi commented 1 year ago

I would like to collect the miIO model identifiers / mDNS names of the mediatek lamps above. Could somebody help here?

YLXD01YL: ?
YLXD02YL: yeelink.light.ceiling4, Jiaoyue 650 (white + RGB backlight)
YLXD04YL: yeelink.light.ceiling3(?)
YLXD05YL: yeelink.light.ceiling3(?)
MJXDD01YL: ?

@spn91 Did you modify/convert your YLXD013-B successfully?

czAtlantis commented 1 year ago

Hi, I have YLXD01YL, YLXD04YL and YLXD05YL. YLXD01YL shows as yeelink.light.ceiling1 YLXD04YL shows as yeelink.light.ceiling3 YLXD05YL shows as yeelink.light.ceiling3

I am taking this info from Yeelight app, settings and info about device and it is shown there

syssi commented 1 year ago

Thanks for your feedback! I will extend the README to provide some more guidance for owner of mediatek devices.

UnchartedBull commented 1 year ago

Just did the conversion on my YLXD05YL. The light was flickering badly on Nightmode if the brightness was above 30%. That's completely gone now!

Used a 'naked' ESP-12E on one of these little breakout boards. No issue with software PWM so far. Thanks for all the work!

Desoldering the Mediatek chip is a PITA though. Needed to use a heatgun, since solder wick didn't seem to work.

image

stomko11 commented 1 year ago

Anyone managed to convert YLXD01YL? Could you share photos and esphome yaml please? I have few of these and would like to get rid of stock firmware.

NopeFinder commented 1 year ago

Anyone managed to convert YLXD01YL?

Yeah I did about a year ago and still works great. I can't find any after photos but did find this one where I wrote down the pinouts. Process of replacing it is basically the same as with the other ones on here. IMG_20220203_193653

#Variables
substitutions:
  device_name: bedroom-light
  friendly_name: Bedroom

esphome:
  name: ${device_name}

esp32:
  board: esp32dev
  framework:
    type: arduino

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

logger:
api:
ota:
  password: !secret ota_password

external_components:
  - source: github://dentra/esphome-components

sensor:
  # Presence based on MAC address
  - platform: miot_ylyk01yl
    mac_address: !secret mi_remote_mac
    bindkey: !secret mi_bindkey
    on_click:
      # String (Required), The button name (case insensitive):
      #     on, off, dimmable or sun or moon, plus or +, moonlight or M, minus or -
      - button: "on"
        then:
          - logger.log: button ON click
          - light.turn_on: night_light
      - button: "off"
        then:
           - logger.log: button OFF click
           - light.turn_off: night_light
           - light.turn_off: ceiling_light
      - button: "+"
        then:
           - logger.log: button PLUS click
           - if:
              condition:
                light.is_on: ceiling_light
              then:
                - light.dim_relative:
                    id: ceiling_light
                    relative_brightness: 5%
                    transition_length: 0.1s
                - delay: 0.1s
           - if:
              condition:
                light.is_on: night_light
              then:
                - light.dim_relative:
                    id: night_light
                    relative_brightness: 5%
                    transition_length: 0.1s
                - delay: 0.1s      
           - if:
              condition:
                - light.is_off: night_light
                - light.is_off: ceiling_light
              then:
                - light.dim_relative:
                    id: ceiling_light
                    relative_brightness: 5%
                    transition_length: 0.1s
                - delay: 0.1s      

      - button: "-"
        then:
           - logger.log: button MIN click
           - if:
              condition:
                light.is_on: ceiling_light
              then:
                - light.dim_relative:
                    id: ceiling_light
                    relative_brightness: -5%
                    transition_length: 0.1s
                - delay: 0.1s
           - if:
              condition:
                light.is_on: night_light
              then:
                - light.dim_relative:
                    id: night_light
                    relative_brightness: -5%
                    transition_length: 0.1s
                - delay: 0.1s  
      - button: "M"
        then:
           - logger.log: button MOON click
           - if:
              condition:
                light.is_on: ceiling_light
              then:
                - light.turn_off: ceiling_light
                - light.turn_on: night_light
           - if:
              condition:
                light.is_on: night_light
              then:
                - light.turn_off: night_light
                - light.turn_on: ceiling_light
      - button: "sun"
        then:
          - light.control:
              id: ceiling_light
              color_temperature: !lambda |-
                if(id(ceiling_light).remote_values.get_color_temperature()==167){
                  return 370;
                }
                else{
                  return 167;
                }
          - logger.log: button SUN click

output:
  - platform: ledc
    pin: GPIO19
    id: output_warm
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO21
    id: output_cold
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO22
    id: output_nightlight
    frequency: 9765Hz
    max_power: 0.92

light:
  - platform: monochromatic
    name: "${friendly_name} Nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${friendly_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: true
    on_turn_on:
      - light.turn_off: night_light

for me it was important the remote kept working as well, so I used these 2 repos by dentra to help me with that. https://github.com/dentra/esphome-components/tree/master/components/miot_ylxx0xyl_pair https://github.com/dentra/esphome-components/tree/master/components/miot_ylyk01yl

If you don't want to keep bluetooth remote functionality you could just leave out the entire sensor part.

Hope this helps!

stomko11 commented 1 year ago

Thanks. I gave it a try, although one light is YLXD12YL, but pinout seems to be the same, so is the board. Initially I used ESP-C3-12F that does not have GPIOs 19,21,22, so I used different ones and adjusted them accordingly in esphome. When I powered on the light, it did briefly (for 1/3 of second?) turn on and off, but then no reaction to any light operations from within HA. After I have changed ESP to nodemcu-32s

#  board: esp32-c3-devkitm-1
#  framework:
#    type: arduino
esp32:
  board: nodemcu-32s

Adjusted GPIOs according to post above and all seems to work just fine

I just have issue - there is noticeable delay when I power it on (from AC) - I did read this through: https://github.com/syssi/esphome-yeelight-ceiling-light/issues/41 and added default transition, but seems to have no effect. Here is mu light config:

output:
  - platform: ledc
    pin: GPIO19
    id: output_warm
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO21
    id: output_cold
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO22
    id: output_nightlight
    frequency: 9765Hz
    max_power: 0.92

light:
  - platform: monochromatic
    name: "${friendly_name} Nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${friendly_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: true
    on_turn_on:
      - light.turn_off: night_light
    restore_mode: RESTORE_AND_ON
    default_transition_length: 0s
stomko11 commented 1 year ago

I did go ahead and converted also YLXD01YL. So the only thing that "bugs" me is that compared to stock yeelight FW, this one has slightly longer boot. I measured (+-) that stock takes 0,85 seconds to turn on after AC is switched on (i use relays in switches to shut it off) where this one takes about 1 second. Not big deal, but slightly noticeable. I tried playing around with on_boot actions, priorities, default transition set to 0s - none of this makes any difference. I guess this is just the way it will be. What is your experience - how long does it take to turn on after switched on @syssi @NopeFinder ?

NopeFinder commented 1 year ago

Personally I don't turn off the AC power to it (removed ac switch altogether) so I wouldn't know how long it takes right now. But I do remember it taking a bit longer than usual when I still did have a regular ac switch

syssi commented 1 year ago

Same here. My Yeelights are always powered. I will prepare a test bench setup to reproduce the issue.

stomko11 commented 1 year ago

@syssi @NopeFinder I have switched from ESP32 to ESP8266 (Wemos D1 Mini). Powering is now instant. The only issue is there is small flicker (like 3 blinks) upon powering it. Below is my config. I am saving preferences to flash every minute. I did try on_boot automation, but even with high priority, light turned on with 100% brightness and 6000K, only after few seconds (way longer than previously on ESP32) it switched to set value (80% and 3000K). Also restore mode did not work the way it did on ESP32. So below config is something that works instantly, but I would like to see if anything can be done about those 3 short blinks upon turning power on:

#Variables
substitutions:
  device_name: kids-light
  friendly_name: Kids Light

esphome:
  name: ${device_name}
#  on_boot:
#    priority: 1200
#    then:
#      - light.turn_on:
#          id: ceiling_light
#          brightness: 80%
#          color_temperature: 3000K

esp8266:
  board: esp01_1m
  restore_from_flash : true

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxx"

ota:
  password: "xxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Kids-Light Fallback Hotspot"
    password: "xxx"

captive_portal:

output:
  - platform: esp8266_pwm
    pin: GPIO5 #D1
    id: output_warm
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: esp8266_pwm
    pin: GPIO4 #D2
    id: output_cold
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: esp8266_pwm
    pin: GPIO0 #D3
    id: output_nightlight
    frequency: 9765Hz
    max_power: 0.92

# Example usage in a light
light:
  - platform: monochromatic
    name: "${friendly_name} Nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${friendly_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: true
    on_turn_on:
      - light.turn_off: night_light
    #restore_mode: RESTORE_AND_ON
    #restore_mode: ALWAYS_ON
    #default_transition_length: 0s

preferences:
  flash_write_interval: 1min
syssi commented 1 year ago

I guess you can fix the flickering if you don't use GPIO0 for the nightlight because GPIO0 is enabled/pulled high on boot (cp. https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/). Please try GPIO14 (D5) or GPIO12 (D6) instead.

stomko11 commented 1 year ago

Thank you @syssi , it was indeed due to this. I moved night light to GPIO14 (D5) and the issue is gone. Now it is almost perfect. The only thing that still happens is - when I power it on via AC, for a very brief moment, it looks like it starts dimmed (or night light starts) and then immediately goes to desired (either restored from flash, or set on boot) color/brightness (with or without transition, depending on how it is set). This isn't as annoying as 1 second delay or flicker, but still - maybe i am just missing something. Below is my config with omitted unnecessary piece of code:

#Variables
substitutions:
  device_name: kids-light
  friendly_name: Kids Light

esphome:
  name: ${device_name}
  on_boot:
    then:
      - light.turn_on:
          id: ceiling_light
          brightness: 90%
          color_temperature: 3100K

esp8266:
  board: esp01_1m
#  restore_from_flash : true

output:
  - platform: esp8266_pwm
    pin: GPIO5 #D1
    id: output_warm
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: esp8266_pwm
    pin: GPIO4 #D2
    id: output_cold
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: esp8266_pwm
    pin: GPIO14 #D5
    id: output_nightlight
    frequency: 9765Hz
    max_power: 0.92

# Example usage in a light
light:
  - platform: monochromatic
    name: "${friendly_name} Nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${friendly_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: true
    on_turn_on:
      - light.turn_off: night_light
    #restore_mode: RESTORE_AND_ON
    #restore_mode: ALWAYS_ON
    default_transition_length: 0s

preferences:
  flash_write_interval: 1min
stomko11 commented 1 year ago

I had a chance to do few more tests. It looks like that it is night light that gets triggered for a split second on the boot. If I disconnect GPIO pin that connects the night light, it is not happening. I have tried D5, D6 and D7 and all behave the same. Any idea why?

syssi commented 1 year ago

If you play with the idea to add a resistor please double check the LED driver board is probably already equipped with a pull-down/pull-up resistor. Please don't destroy your driver board while tinkering!

stomko11 commented 1 year ago

I am not sure my skills are good enough to try that. I rather disconnected the night light completely for now as I barely used it anyway. However I would be willing to try if I knew exactly what and how :)

syssi commented 1 year ago

Same here. I don't want to instruct you to do dangerous things where I am not 100% sure they are a good idea.

stomko11 commented 1 year ago

I will give it a try and try various esp32 or esp8266. I am reading that this may be just the thing for wemos, and others (even clones) may behave differently. So i ordered a few and will report back.

syssi commented 1 year ago

@avion23 Do you like to add your 5 cents of a professional here?

Short summary: This picture describes what we have done: https://user-images.githubusercontent.com/19818061/211223563-126fef62-f918-4a00-a9bb-7778376285ed.jpeg

We've replaced a Mediatek microcontroller with an ESP8266. The ESP is attached to a LED driver board and the three colors (RGB) can be controlled using PWM. A fourth PWM signal is used to control a subset of the LEDs as nightlight.

The issue: The nightlight flickers on boot-up of the ESP. I assume the output pin of the ESP is floating and causes the flicker. How can we make sure the LED driver isn't equipped with a pull-up/pull-down already? If the resistor is missing I would like to add one to pull the line to a logic level to "turn/keeping off the nightlight if there is no PWM signal".

avion23 commented 1 year ago

It is recommended to use a pullup or pulldown resistor in this application. Based on the assumption that the lines switch an N-Channel MOSFET, it is appropriate to use a pulldown resistor. This is based on my assumption that a high output from the ESP8266 results in the light being turned on. A resistor value in the range of 10k Ohm to 100k Ohm should be suitable.

To provide mechanical isolation of the solder joints, consider applying a small amount of adhesive to the lines.

syssi commented 1 year ago

@stomko11 I've found this article on reddit today: https://static.xtremeownage.com/blog/2023/esphome-on-critical-infrastructure/

It mentions early_pin_init: false. You could give this setting a try too.

https://static.xtremeownage.com/blog/2023/esphome-on-critical-infrastructure/ https://esphome.io/components/esp8266.html

stomko11 commented 1 year ago

@syssi this works on switch only, not on pwm. So I would not be able to adjust code to make things work.

89Amaterasu commented 10 months ago

I had a chance to do few more tests. It looks like that it is night light that gets triggered for a split second on the boot. If I disconnect GPIO pin that connects the night light, it is not happening. I have tried D5, D6 and D7 and all behave the same. Any idea why?

GPIO4 and GPIO5 are the only pins on the ESP8266 that are always high impedance and do not float or are actively pulled during boot. I'd test those if I were you. Will start to play with my YLXD01YLs in the coming days. GPIO15 might be an option as well, but there is conflicting information on its exact behavior during boot.

stomko11 commented 10 months ago

I did, however you need 3 PINs - night light, warm white, cold white.

89Amaterasu commented 10 months ago

I did, however you need 3 PINs - night light, warm white, cold white.

The setup below works fine for me. One of the pins not being on GPIO4, GPIO5, or GPIO15 leads to a short flash of the respective color during boot.

ESP8266 D1 mini clone GPIO4: WW GPIO5: CW GPIO15: Nightlight

stomko11 commented 10 months ago

It is that flash that annoyed me on esp2866. And delay on esp32 (got used to it)

89Amaterasu commented 10 months ago

It is that flash that annoyed me on esp2866. And delay on esp32 (got used to it)

The flash is gone if you use those three pins on the esp8266.

Here's an explanation for the flashes during boot if other pins are used: https://rabbithole.wwwdotorg.org/2017/03/28/esp8266-gpio.html

wmlex commented 8 months ago

Tell me why, when I turn off the light, the lamp (YLXD17YL) does not go out evenly? Cold&Warm 50/50 https://youtu.be/jaf6tGkBfgs Cold&Warm 0/100 https://youtu.be/ibINSGMekM0 Cold&Warm 100/0 https://youtu.be/JFTfzDFalsA photo_2023-11-18_10-17-32 photo_2023-11-18_10-18-02 photo_2023-11-18_10-17-59

output:
  - platform: ledc
    pin: GPIO19
    id: output_warm
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO21
    id: output_cold
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO23
    id: output_nightlight
    frequency: 9765Hz
    max_power: 0.92

light:
  - platform: monochromatic
    name: "${board_name}_nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${board_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: true
    on_turn_on:
      - light.turn_off: night_light