This may be a little premature given that ESP32 OpenESP32 development is still in progress (at the time of posting). But I was too excited to find a device I ordered, and was just delivered, before the ESP news came out has an ESP-C2 module inside. The hope is that this device look-over will end with a working switch running OpenESP32C2.
It's a non-Tuya HomeKit 10A breaker/switch in a standard white casing. Model BSD16.
and inside
The module is a DOIT ESP-C2-02 N2. I think N2 means it has 2Mb flash.
Before I unsolder or solder up too much, in case the ESP is locked and I cannot flash it (and so it can go into the resale pile), I attached 3.3v and ground and used a sewing needle on TX to capture the UART log (74880 baud).
Code: Text
Log in, to see the code
So it's a Cozylife device, also evidenced by the logo in the QR code in the manual. No mention of Secure Boot or encrypted flash.
Proceeding to solder RX/TX and using a pogo pin to ground BOOT pad to pull it low and into flash download mode:
Flash success. After a power-cycle with BOOT/GPIO9 disconnected from ground, the OpenESP32C2 AP can be seen broadcasting
Connecting to the AP causes a brownout reboot though, so I guess I'm not feeding it enough power, despite it being connected to an external PSU that should be able to give it <5A.
Code: Text
Log in, to see the code
Attachments:
BSD16_ESP32C2_PT.bin(24 KB)
You must be logged in to download this attachment.
BSD16_ESP32C2_BL.bin(32 KB)
You must be logged in to download this attachment.
BSD16_ESP32C2.bin(2 MB)
You must be logged in to download this attachment.
and powered from the mains the device does not brownout when AP is joined.
I went through each GPIO pulling all those available on the module high - 4, 5, 6, 7, 10, 18, 19, 20 but they had no effect. Taking the unit apart again it seems the button is GPIO5 and the LED is GPIO7. The button always seems to have continuity with GPIO5, pressed or not. I've not found the GPIO for the relay.
The main GUI is responsive, but I am finding I need to power-cycle the unit quite a lot. The logs sometimes come through and sometimes nothing shows for a while.
lots of malloc errors appear sometimes.
Code: Text
Log in, to see the code
With the button set and after a quick push, these will sometimes show in the logs
Code: Text
Log in, to see the code
I might flash original firmware back to be sure all works as expected.
Very interesting experiments, I wonder if there is OTA possiblity for this platform, or is it too secured? I mean, before flashing via UART.
The decreasing amount of free 22804 memory usually means that something is blocking TCP sockets of HTTP server and they don't free HTTP buffer. It's an unexpected behaviour of LWIP. Maybe we can fix it by adjusting some LWIP settings, like a socket timeout, etc, I don't know, just speculating at the moment. @insmod might have some ideas. Does it happen only on this ESP module or on others as well?
hmm. untouched, the free memory slowly decreases towards unresponsiveness. the device seems to be staying up, but there are periods where it is unresponsive. When it comes back it'll splurge a load of mallocs into the log.
Code: Text
Log in, to see the code
Added after 40 [minutes]:
p.kaczmarek2 wrote:
I wonder if there is OTA possiblity for this platform, or is it too secured
still responsive.
and I just thought to try PWM on for the LED instead of LED and that works.
It does oddly flickery when 'off' though. Still, feels like progress.
Added after 24 [minutes]:
and it turns out the relay is on IO4 and is also PWM. I guess the frequency needs determining as with 4:PWM:2 it'll click on and off when switched to on
Added after 1 [hours] 27 [minutes]:
There's a BP2525 (bottom middle) and there appears to be continuity from at least 2 of the legs to the D3 side of the T4 component, the other side of which is connected to the leg of the relay in that corner. Not sure what this means for an OBK config at this point though.
LED, and to some extent the relay, are better with 1344_merge_be604adfa333 where I see some PWM/pin changes have been made. Currently LED does not flicker when off and is solid when on. Relay are both a bit hit-and-miss triggering on, but maybe this is down to the unknown PWM frequency needed for either.
Added after 4 [minutes]:
strings from factory fw
Attachments:
BSD16.bin.txt(89.38 KB)
You must be logged in to download this attachment.
relay, button, LED all work as normal. I didn't mention that I'd hooked up a logic analyser to LED and relay contacts and there was no sign of PWM, so this makes sense.
Added after 2 [hours] 53 [minutes]:
unless there are other, yet to be identified, issues this could be considered a complete conversion to OpenESP32C2. In which case the template would be
Seems fast and stable in all the testing above since malloc issue was sorted. I've not left it online for any longer than a day but I'll leave it plugged in to be sure it's happy for days/weeks
>>21229886 The system itself runs stable.
Problems:
I2C not working on some pins (most important - i wasn't able to get bp5758d on wroom-07 module working)
UART receiving (on C6 if connected to RX pin - works okay, on C2 soldered to tuyamcu battery pir sensor - receives nothing). Sending works ok.
OTA can be very slow, up to 3-4 minutes. Restart before OTA is recommended.
PWM was flickering heavily on C2, cause unknown. But, i believe it is solved when timer clk_cfg started using SOC_MOD_CLK_RC_FAST instead of LEDC_AUTO_CLK.
No static ip.
When using powersave dynamic frequency, if entered freq is wrong - esp-idf driver will print it to uart only - so we won't know that custom frequency wasn't applied. Also, when max freq value is too low (like 40mhz on C3), wifi will disconnect and won't be able to reconnect.
No pindeepsleep.
BL0937 gpio isr is not implemented.
Those are off the top of my head, some other issues may also be present.
For I2C - perhaps because Soft_I2C_SetHigh calls for HAL_PIN_Setup_Input_Pullup, instead of HAL_PIN_SetOutputValue(pin, 1)?
✨ The discussion revolves around the BSD16 HomeKit 10A breaker switch, which incorporates a DOIT ESP-C2-02 N2 module. The user is experimenting with the device to run OpenESP32C2 firmware. Initial tests revealed issues with GPIO functionality, particularly with the button and LED connections. Users reported memory management problems, including malloc errors and unresponsiveness, which were addressed through firmware optimizations. The relay and LED behavior improved after adjustments to PWM settings. The device is now considered stable for use, with successful integration into the OpenESP32C2 environment, although some issues with I2C and OTA performance remain. The final configuration includes specific GPIO assignments for the relay, button, and LED. Generated by the language model.
TL;DR: OTA on ESP32‑C2 can take 3–4 minutes; "The system itself runs stable." This FAQ shows how to flash OpenESP32C2 on the BSD16, set GPIO4/5/7, fix brownouts, and track current limits. [Elektroda, insmod, post #21229957]
Why it matters: It helps ESP32‑C2 tinkerers convert CozyLife/HomeKit breakers safely and understand current platform constraints.
What hardware is inside the BSD16 HomeKit breaker?
It uses a DOIT ESP‑C2‑02 N2 module with an ESP32‑C2 rev v1.2. Detected flash size is 2 MB. Stock boot logs show CozyLife SDK 0.6.0 and HomeKit (HAP) initialization with mDNS announcements. It is a non‑Tuya HomeKit 10 A breaker. [Elektroda, divadiow, post #21225221]
How do I flash OpenESP32C2 onto the BSD16 safely?
Hold BOOT/GPIO9 low and power on to enter DOWNLOAD(UART0).
Back up flash: esptool read_flash 0x0 0x200000; optionally dump bootloader and partition table.
Use Tasmota‑ESP‑Flasher to write the latest OpenESP32C2 factory binary, then power‑cycle with BOOT released. The device should broadcast its AP. [Elektroda, divadiow, post #21225221]
How do I enter UART download mode on the ESP32‑C2 module?
Ground the BOOT pad (GPIO9) while powering the device. The ROM prints boot:0x4 (DOWNLOAD(UART0)) and “waiting for download.” Release BOOT after flashing to boot normally. [Elektroda, divadiow, post #21225221]
Is Secure Boot or Flash Encryption enabled on this unit?
No. get_security_info shows Secure Boot: Disabled, Flash Encryption: Disabled, and SPI_BOOT_CRYPT_CNT: 0x0. That allows full backups and custom firmware flashing without decryption keys. [Elektroda, divadiow, post #21225221]
What’s the correct UART baud to capture the stock boot log?
Use 74880 baud on TX with 3.3 V and GND attached. The captured log shows CozyLife SDK details, HomeKit HAP initialization, BLE MAC, and other startup info. [Elektroda, divadiow, post #21225221]
My unit reboots with BROWNOUT_RST when I join the AP. How do I fix it?
This occurred on bench power during setup. When reassembled and powered from mains, the brownout disappeared and the AP join was stable. Use a robust supply or mains power during configuration. [Elektroda, divadiow, post #21225606]
What GPIO mapping works for relay, button, and LED in OpenESP32C2?
Use GPIO4=Rel1, GPIO5=Btn1, and GPIO7=WifiLED. The LED and relay operate as simple digital outputs; PWM is not required on the latest build. “Relay, button, LED all work as normal.” [Elektroda, divadiow, post #21228574]
Why did PWM flicker on ESP32‑C2, and what’s the fix?
Earlier builds flickered on C2. The fix uses an LEDC timer clock based on RC_FAST rather than AUTO. Alternatively, avoid PWM for the LED and relay on this device. “PWM was flickering heavily on C2.” [Elektroda, insmod, post #21229957]
I see free heap dropping and HTTP malloc errors. What’s happening?
A maintainer noted the HTTP server’s TCP sockets can block and not free LWIP buffers. Free memory falls and the web server becomes unresponsive. Adjusting LWIP timeouts may help. “Something is blocking TCP sockets of HTTP server.” [Elektroda, p.kaczmarek2, post #21225735]
Did the recent RAM optimizations help ESP32‑C2 stability?
Yes. After updates, free heap is about 40–60 kB at 500 seconds online with no malloc errors observed. Responsiveness improved during extended runs. [Elektroda, insmod, post #21225929]
Is OTA supported, and how long does it take?
Yes, OTA works but can be slow. Expect about 3–4 minutes per update. Restarting before OTA is recommended to ensure sufficient free RAM and reliability. “Restart before OTA is recommended.” [Elektroda, insmod, post #21229957]
Does I2C work on ESP32‑C2 right now?
Not consistently. I2C failed on some pins, and the BP5758D driver did not work on a WROOM‑07 test module. Developers are investigating software I2C handling and pin behavior. [Elektroda, insmod, post #21229957]
Is UART receive reliable on C2?
Mixed results. On ESP32‑C6, RX worked fine. On C2 with a TuyaMCU battery PIR sensor, RX received nothing, although TX worked normally. Testing your sensor is advised. [Elektroda, insmod, post #21229957]
Can I set a static IP or use deep sleep?
Static IP is not available yet, and pin deep sleep is not implemented. Also, using an incorrect dynamic Wi‑Fi frequency can break connectivity on some chips. [Elektroda, insmod, post #21229957]
How do I confirm the device runs Apple HomeKit stock?
Capture the boot log at 74880 baud. You should see HAP initialization, Setup ID (e.g., 93UR), mDNS for _hap._tcp, and “Accessory is not Paired.” CozyLife SDK details also appear. [Elektroda, divadiow, post #21225221]
Is the ESP32 port stable enough for daily use now?
A tester reports it “fast and stable” since the RAM fixes. They plan multi‑day runs, and early uptimes look solid with responsive UI and buttons. [Elektroda, divadiow, post #21229894]