Okay, being annoyed with losing support for my beside lamps, I too started butchering my beside lamp to see where it would get me with ESPHome.
I also traced the serial port pins, GPIO0 and GPIO2 (looking at the pinout image that was posted earlier, GPIO2 is the debug pad to the left of the QR code sticker).
After connecting these to an FTDI adapter, I was able to see logging output from the board. So far so good.
Next step I took, was trying to compile an ESPHome firmware and flash it to the device. To get the device into flashing mode is a bit fiddly, but can be done. The steps that I took were:
- Get the ESPHome flashing tool ready with the correct COM port and firmware selected
- Unplug the FTDI adapter
- Connect GPIO0 to ground (I used the large ground-connected area that is near the LED leads)
- Plug in the FTDI adapter and start flashing from the ESPHome flashing tool
- Once the log shows that flashing has started, you can disconnect GPIO0 from ground
This worked, but not very well. The boot process was stuck in a loop, showing an error about the firmware being built for dual core, while the device is single core:
[02:20:09]rst:0xc (SW_CPU_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
[02:20:09]configsip: 0, SPIWP:0xee
[02:20:09]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[02:20:09]mode:DIO, clock div:2
[02:20:09]load:0x3fff0018,len:4
[02:20:09]load:0x3fff001c,len:1044
[02:20:09]load:0x40078000,len:8896
[02:20:09]load:0x40080400,len:5828
[02:20:09]entry 0x400806ac
[02:20:09]E (352) cpu_start: Running on single core chip, but application is built with dual core support.
[02:20:09]E (353) cpu_start: Please enable CONFIG_FREERTOS_UNICORE option in menuconfig.
[02:20:09]abort() was called at PC 0x40082169 on core 0
[02:20:09]
[02:20:09]Backtrace: 0x4008c66c:0x3ffe3be0 0x4008c89d:0x3ffe3c00 0x40082169:0x3ffe3c20 0x40079053:0x3ffe3c40 0x400790b9:0x3ffe3c70 0x400790c4:0x3ffe3ca0 0x4007928d:0x3ffe3cc0 0x400806de:0x3ffe3df0 0x40007c31:0x3ffe3eb0 0x4000073d:0x3ffe3f20
[02:20:09]
[02:20:09]Rebooting...
To fix this, I had to modify my build configuration file. This is what I ended up with (thanks to some other people that figured this out for another kind of device):
esphome:
name: bedside_lamp_office
platform: ESP32
board: esp32doit-devkit-v1
platformio_options:
platform: [email protected]
platform_packages: |-4
framework-arduinoespressif32 @ https://github.com/pauln/arduino-esp32.git#solo-no-mac-crc/1.0.4
After building and uploading this firmware, I got stuck in yet another reboot loop, but this one looked kind of promising. I saw brownout errors, and I figured that these might be caused by the rest of the circuitry drawing current away from the ESP32, since it was only powered by the 3.3V lead on my FTDI adapter.
So next step was to disconnect that 3.3V lead and instead powering the device using the regular power supply. I kept the RX/TX pins connected to be able to see the device logging, and that was satisfying to see!
Using 'COM3' as serial port.
Showing logs:
[02:33:17]
[02:33:18][02:33:18]
[02:33:18]rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
[02:33:18]configsip: 0, SPIWP:0xee
[02:33:18]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[02:33:18]mode:DIO, clock div:2
[02:33:18]load:0x3fff0018,len:4
[02:33:18]load:0x3fff001c,len:1044
[02:33:18]load:0x40078000,len:8896
[02:33:18]load:0x40080400,len:5828
[02:33:18]entry 0x400806ac
[02:33:18][I][logger:166]: Log initialized
[02:33:18][C][ota:366]: There have been 1 suspected unsuccessful boot attempts.
[02:33:18][I][app:029]: Running through setup()...
[02:33:18][C][wifi:033]: Setting up WiFi...
[02:33:18][D][wifi:324]: Starting scan...
[02:33:21][D][wifi:339]: Found networks:
<long list of wifi networks in my neighbourhood>
[02:33:21][I][wifi:194]: WiFi Connecting to 'MY CONFIGURED AP'...
[02:33:22][I][wifi:457]: WiFi Connected!
[02:33:22][C][wifi:303]: SSID: 'MY CONFIGURED AP'
[02:33:22][C][wifi:304]: IP Address: 192.168.100.159
[02:33:22][C][wifi:306]: BSSID: AA:AA:AA:AA:AA:AA
[02:33:22][C][wifi:307]: Hostname: 'bedside_lamp_office'
[02:33:22][C][wifi:311]: Signal strength: -40 dB ▂▄▆█
[02:33:22][C][wifi:315]: Channel: 11
[02:33:22][C][wifi:316]: Subnet: 255.255.255.0
[02:33:22][C][wifi:317]: Gateway: 192.168.100.1
[02:33:22][C][wifi:318]: DNS1: 192.168.100.1
[02:33:22][C][wifi:319]: DNS2: 0.0.0.0
[02:33:22][D][wifi:466]: Disabling AP...
[02:33:22][C][ota:029]: Over-The-Air Updates:
[02:33:22][C][ota:030]: Address: bedside_lamp_office.local:3232
[02:33:22][C][ota:032]: Using Password.
[02:33:22][C][api:022]: Setting up Home Assistant API server...
[02:33:22][I][app:059]: setup() finished successfully!
[02:33:22][I][app:105]: ESPHome version 1.16.2 compiled on Mar 2 2021, 01:25:09
[02:33:22][C][wifi:443]: WiFi:
[02:33:22][C][wifi:303]: SSID: 'MY CONFIGURED AP'
[02:33:22][C][wifi:304]: IP Address: 192.168.100.159
[02:33:22][C][wifi:306]: BSSID: AA:AA:AA:AA:AA:AA
[02:33:22][C][wifi:307]: Hostname: 'bedside_lamp_office'
[02:33:22][C][wifi:311]: Signal strength: -36 dB ▂▄▆█
[02:33:22][C][wifi:315]: Channel: 11
[02:33:22][C][wifi:316]: Subnet: 255.255.255.0
[02:33:22][C][wifi:317]: Gateway: 192.168.100.1
[02:33:22][C][wifi:318]: DNS1: 192.168.100.1
[02:33:22][C][wifi:319]: DNS2: 0.0.0.0
[02:33:22][C][logger:185]: Logger:
[02:33:22][C][logger:186]: Level: DEBUG
[02:33:22][C][logger:187]: Log Baud Rate: 115200
[02:33:22][C][logger:188]: Hardware UART: UART0
[02:33:22][C][captive_portal:169]: Captive Portal:
[02:33:22][C][ota:029]: Over-The-Air Updates:
[02:33:22][C][ota:030]: Address: bedside_lamp_office.local:3232
[02:33:22][C][ota:032]: Using Password.
[02:33:22][C][api:095]: API Server:
[02:33:22][C][api:096]: Address: bedside_lamp_office.local:6053
Home Assistant was happy too, since it notified me that a new ESPHome device was discovered.
I was indeed able to see the device on my network. So next test: can I use OTA updating? Well, look for yourself:
INFO Successfully compiled program.
INFO Resolving IP address of bedside_lamp_office.local
INFO -> 192.168.100.159
INFO Uploading /config/bedside_lamp_office/.pioenvs/bedside_lamp_office/firmware.bin (861792 bytes)
Uploading: [============================================================] 100% Done...
So the basics are done, I am now the proud owner of a non-functional bedside lamp ![:wink: :wink:](https://community.home-assistant.io/images/emoji/twitter/wink.png?v=9)
Next steps would be:
- to find oud what pins to use for the various LEDs. It looks like an RGBW OR RGBWW style setup, because of the names on the leads (which say: R-, R+, G+, B+, W-, W+).
- to find out how the power button and slider work. There are five leads, GND + 4 others, going to the break out board that hold these, and my bestguess is that the slider might be linked to an analog input and the button to a digital one. However, since there is quite a bit of hardware on the break out board, amongst which an IC with 32 pins that I don’t recognize (but I’m not that well-versed in IC-ology), the communication to the main boar could be really anything.
Tomorrow I will investigate a bit further and see if I can come up with at least some controllable LED lights. Would be nice to get this working.