Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
14.22k stars 3.03k forks source link

Sonoff B1 support #3034

Open sgilissen opened 1 year ago

sgilissen commented 1 year ago

Is your feature request related to a problem? Please describe. The Sonoff B1 is a ESP8285-based wifi smart bulb. This device is already supported in Tasmota: https://tasmota.github.io/docs/devices/Sonoff-B1/

Describe the solution you'd like It would be great if WLED supports this device as well.

Describe alternatives you've considered I have set up a few of these bulbs with Tasmota, but unfortunately it lacks a proper way to sync with WLED.

Additional context I have tried using flashing WLED onto this device. Unfortunately, while the flashing completes successfully, it does not start the AP, as far as I can tell. I used install.wled.me.

blazoncek commented 1 year ago

Just use appropriate ESP8266 binary matching flash size.

sgilissen commented 1 year ago

It seems that the ESP01 binary works, but it needs the MY9291 usermod. @spectrenoir06 I see that this particular usermod has been created by you. After discussing on the WLED discord, this may need to be updated for the latest versions. Anything I can do to help?

Thanks!

spectrenoir06 commented 1 year ago

I don't made it for the Sonoff B1 but if it use the MY9291 it should be easy to change the GPIO https://twitter.com/spectrenoir06/status/1358255523959865347?s=20

blazoncek commented 1 year ago

It seems that the ESP01 binary works, but it needs the MY9291 usermod.

Use bot on Discord to compile a custom binary. Use appropriate environment and add -D USERMOD_MY9291 to build flags.

blazoncek commented 1 year ago

@spectrenoir06 it would be great if you'd update it to be able to modify GPIO using settings page.

sgilissen commented 1 year ago

It seems that the ESP01 binary works, but it needs the MY9291 usermod.

Use bot on Discord to compile a custom binary. Use appropriate environment and add -D USERMOD_MY9291 to build flags.

Tried doing that with the following config:

[env:esp01_1m_full]
board = esp01_1m
platform = ${common.platform_wled_default}
platform_packages = ${common.platform_packages}
board_build.ldscript = ${common.ldscript_1m128k}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP01 -D WLED_DISABLE_OTA -D WLED_DISABLE_BLYNK -D USERMOD_MY9291
lib_deps = ${esp8266.lib_deps}

I'm getting the following error from the bot: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory

I may be doing something wrong though

Edit: Modified reply for clarity

spectrenoir06 commented 1 year ago

I didn't look how to add parameter in the user setting but it only need to change few values

#define MY92XX_MODEL        MY92XX_MODEL_MY9291
#define MY92XX_CHIPS        1
#define MY92XX_DI_PIN       13
#define MY92XX_DCKI_PIN     15

#define MY92XX_RED          0
#define MY92XX_GREEN        1
#define MY92XX_BLUE         2
#define MY92XX_WHITE        3

https://github.com/Aircoookie/WLED/blob/main/usermods/MY9291/usermode_MY9291.h

blazoncek commented 1 year ago

Use addToConfig()/readFromConfig(). See examples in other usermods.

The approach with #defines is best avoided as it requires re-compilation.

spectrenoir06 commented 1 year ago

it seam the sonoff B1 use two MY9291 https://user-images.githubusercontent.com/17343162/29202638-6b2c39ee-7e6a-11e7-93eb-727d7efaa24c.png

sgilissen commented 1 year ago

Interesting! I'm wondering how this is handled. The B1 has 3 RGB LEDs and a cluster of warm white and cool white LEDs (each cluster with 8 LEDs respectively in the devices I have here)

I'm guessing that the RGB LEDs are hooked up to U3 and the white clusters are hooked up to U4.

According to the Tasmota wiki, it only needs 1 clock (GPIO14) and 1 data (GPIO12) pin.