Here's another DOIT/Cozylife ESP-C2 based mini smart switch. It looks to have the same origins as this breaker https://www.elektroda.com/rtvforum/topic4075524.html with related SDK/boot log/factory app/module. This is branded as an Aiyato BRK-HW1KN1.
Flashing/backup and log capture was the same as with the BSD16, so I'll not detail that. Straight to some pics and logs.
Code: Text
Log in, to see the code
Using trial-and-error, multimeter and cross-referencing PCB pin labels (KEY. JDQ) with the CB2S version I believe these should be the correct assignments
Code: Text
Log in, to see the code
However, the LED works and so does the toggle button BUT there is no relay operational with any configuration I've tried.
On occasions the log will say this and switch the LED on/off
Code: Text
Log in, to see the code
Currently the device is wired with bulb and switch as per this diagram for 1-way control
So I'm not sure if my config isn't right (quite possible) or if this relates to anything ESP dev that needs adjusting.
Attachments:
Aiyato.bin(2 MB)
You must be logged in to download this attachment.
how to use GPIO7 on ESP32C2, ESP32C3 ,ESP32C6, etc, as digital output? It seems to be always pulled high for me. Does it have some external function that I need to disable?
Direct Answer: To use GPIO7 as a digital output on ESP32C2, ESP32C3, and ESP32C6, you need to ensure that it is not being used by any other peripheral or function, as it may have default assignments that interfere with its use as a general-purpose output. Specifically, GPIO7 is often associated with SPI flash communication or strapping pins, which can cause it to be pulled high or behave unexpectedly. You will need to disable or reconfigure these functions before using GPIO7 as a digital output.
Detailed Step-by-Step Problem Analysis:
1. Check for Default Functions and Strapping Pins: - ESP32-C2 and ESP32-C3: GPIO7 is often used for SPI flash communication (e.g., as a data line in QSPI mode). If your system is using external flash memory, GPIO7 may be reserved for this purpose, and you cannot use it as a general-purpose output. - ESP32-C3: GPIO7 is also a strapping pin used to determine the boot mode (e.g., UART download mode). This means it may have a specific state during boot, which could explain why it appears to be pulled high. - ESP32-C6: Similar to the C3, GPIO7 may be used as a strapping pin or for other peripheral functions.
2. Disable Peripheral Functions: - If GPIO7 is being used by the SPI flash or as a strapping pin, you will need to disable these functions. For example, if you are not using external flash, you can configure the system to disable QSPI mode in your development environment. - You can also check the ESP-IDF configuration to ensure that no other peripherals (e.g., UART, SPI) are using GPIO7.
3. Configure GPIO7 as a Digital Output: Once you have ensured that GPIO7 is not being used by any other function, you can configure it as a digital output using the following code: [syntax=C / C++] gpio_config_t io_conf; io_conf.intr_type = GPIO_INTR_DISABLE; // Disable interrupt io_conf.mode = GPIO_MODE_OUTPUT; // Set pin as output io_conf.pin_bit_mask = (1ULL << GPIO_NUM_7); // Set bit mask for GPIO7 io_conf.pull_down_en = 0; // Disable pull-down mode io_conf.pull_up_en = 0; // Disable pull-up mode gpio_config(&io_conf); // Configure GPIO with the given settings
gpio_set_level(GPIO_NUM_7, 0); // Set GPIO7 to low level gpio_set_level(GPIO_NUM_7, 1); // Set GPIO7 to high level [/syntax]
4. Check for External Pull-ups: If GPIO7 remains high even after setting it low, check your hardware for any external pull-up resistors or other circuitry that might be forcing the pin high. You can use a multimeter to measure the voltage on the pin to verify its state.
Supporting Details and Explanations:
- Pin Multiplexing: ESP32 chips use a pin matrix that allows multiple functions to be assigned to the same pin. GPIO7 may be multiplexed with other functions like SPI or UART, which could explain why it is being pulled high. You need to ensure that no other function is assigned to GPIO7 before using it as a digital output.
- Strapping Pins: Strapping pins are used to configure the boot mode of the ESP32 chip. GPIO7 is a strapping pin on some ESP32 variants (e.g., ESP32-C3), which means it may have a specific state during boot. After boot, you can reconfigure it as a general-purpose output.
- Internal Pull-up Resistors: Some GPIOs have internal pull-up resistors enabled by default. If GPIO7 has an internal pull-up, it may be pulled high unless explicitly configured otherwise. You can disable the pull-up resistor in your initialization code.
Caveats and Additional Considerations:
- ESP32-C2 and ESP32-C3 Flash Usage: If your system uses external flash memory, GPIO7 may be reserved for SPI communication, and you will not be able to use it as a general-purpose output. In this case, you should consider using a different GPIO pin.
- ESP-IDF Version: Ensure that you are using the latest version of the ESP-IDF (Espressif IoT Development Framework) that is compatible with your chip. Different versions of the ESP-IDF may handle GPIO configurations differently, and newer versions may include fixes or improvements for GPIO handling.
- Hardware Considerations: If you are using a custom board, check the schematic to ensure that GPIO7 is not connected to any external circuitry that could interfere with its operation as a digital output.
By following these steps and considerations, you should be able to use GPIO7 as a digital output on ESP32C2, ESP32C3, and ESP32C6. If the issue persists, consider using a different GPIO pin or providing more details about your specific setup for further troubleshooting.
You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
I guess now it's time for a DHT11 mod or something? Just take care, those things have non-isolated power supplies so you can get mains on that DHT! Still, it should have some unused GPIO....
✨ The discussion revolves around the DOIT/Cozylife ESP-C2 Mini Smart Switch, branded as Aiyato BRK-HW1KN1, and its GPIO7 functionality. Users report issues with controlling GPIO7 on the ESP32C2, ESP32C3, and ESP32C6 platforms, where GPIO7 remains pulled high and is not responsive to commands. It is suggested that GPIO7 may be reserved for SPI flash communication or other peripheral functions, which could interfere with its use as a general-purpose output. A user later confirms that a new firmware build allows for successful relay control via GPIO7. The conversation also touches on potential modifications, such as integrating a DHT11 sensor, while cautioning about the risks associated with non-isolated power supplies. Generated by the language model.
TL;DR: 3 of 4 tested ESP variants showed GPIO7 stuck‑high; "IO7 not controllable – dim LED". This FAQ helps OBK/Tasmota tinkerers map pins, update firmware, and restore relay control on the DOIT/Cozylife ESP‑C2 mini switch. [Elektroda, divadiow, post #21238286]
Why it matters: It saves hours of debugging relay control by giving you the exact working pin map and firmware build info.
What’s the correct OpenBeken pin mapping for Aiyato BRK‑HW1KN1 (DOIT/Cozylife ESP‑C2)?
Use this mapping: GPIO4 = TglChanOnTgl; GPIO7 = Rel (channel 1); GPIO10 = LED_n (active‑low); GPIO20 = Btn_Tgl_All. On build 1344_merge_77dfe2ae2220, both GUI and the physical button toggle the relay. Apply these assignments in OpenBeken and save. The LED follows the channel state due to LED_n inversion. [Elektroda, divadiow, post #21244368]
Why is GPIO7 stuck high on ESP32‑C2/C3/C6, and how can I use it as output?
GPIO7 often multiplexes with flash or strapping functions on C‑series parts. It can appear pulled high or unresponsive. Disable conflicting peripherals and configure it explicitly as a GPIO output in firmware. Also check for external pull‑ups on the board. "After boot, you can reconfigure it as a general‑purpose output." [Elektroda, ElektrodaBot, post #21238303]
Which firmware build fixed the relay toggle on this device?
OpenBeken build 1344_merge_77dfe2ae2220, built on Sep 29, 2024 21:52:31, restored reliable relay control. The author confirmed, "Toggle now works." It toggles from the OBK GUI and the physical button. Ensure your pin map matches the working template. [Elektroda, divadiow, post #21244368]
Is there a ready OpenBeken template I can use?
Yes. A published template lists vendor Aiyato, model BRK‑HW1KN1, chip ESP32C2, board ESPC2‑02, and the working pin map. It also includes an image link and a wiki URL for reference. This mirrors the confirmed assignments that enable the relay. [Elektroda, divadiow, post #21246027]
How do I wire it for one‑way control with a wall switch and bulb?
Follow the posted 1‑way wiring diagram for this device. It shows line, neutral, load, and switch connections. Cut power before wiring to ensure safety. Verify wiring visually against the diagram before restoring power. [Elektroda, divadiow, post #21237176]
What do the PCB labels KEY and JDQ map to on this unit?
KEY maps to the local button input assigned as Btn_Tgl_All on GPIO20. JDQ maps to the relay control assigned as Rel on GPIO7. This mapping works with the validated build and template. [Elektroda, divadiow, post #21244368]
What does the boot log tell me about the stock firmware?
The log shows CozyLife SDK 0.6.0 and ESP‑IDF v5.0‑beta1. It reports Product ID 854KCV and Firmware 1.0.1. A HomeKit setup ID (HYYW) appears, indicating factory HomeKit support. These details help identify platform behavior before flashing. [Elektroda, divadiow, post #21237176]
How can I test relay operation without a mains load?
Open the OBK GUI and toggle Channel 1. Listen for the relay click and watch the LED_n change state. If nothing happens, update to build 1344 and reapply the working pin map. Confirm the relay assignment is on GPIO7. [Elektroda, divadiow, post #21244368]
Can I add a DHT11 or DHT22 sensor to this switch safely?
You can attempt it, but the power supply is not isolated from mains. "...those things have non‑isolated power supplies so you can get mains on that DHT!" Only proceed if you fully understand mains safety and isolation. Consider isolation measures or external low‑voltage nodes. [Elektroda, p.kaczmarek2, post #21246663]
Why does my DHT sensor read inconsistently on this hardware?
The author observed erratic readings with these DHT modules on Beken too. Fake or marginal DHT sensors are a common cause. Swap in a verified sensor and minimize lead length. If instability persists, consider a different sensor type. [Elektroda, divadiow, post #21247316]
Is original ESP32 GPIO7 usable as a general I/O here?
In testing, ESP32 (original) IO7 stayed dim‑high and was not assignable. It likely is not meant for GPIO on that platform. Choose other GPIOs if you target ESP32 boards. [Elektroda, divadiow, post #21238286]
How do I get the relay working on a clean OpenBeken install?
Do this simple sequence:
Update to OpenBeken build 1344 or newer.
Set pins: 4 TglChanOnTgl; 7 Rel; 10 LED_n; 20 Btn_Tgl_All.
Which ESP variants showed the IO7 issue during tests?
ESP32‑S3 worked. ESP32‑C2, ESP32‑C3, and ESP32‑C6 showed IO7 stuck high with a dim LED. ESP32 classic IO7 was not assignable. These results shaped the troubleshooting approach. [Elektroda, divadiow, post #21238286]
How is this device related to the DS‑1311WN/CB2S design?
The PCB silkscreen reads DS‑1311WN V1.2 (2023.05.15). The author linked it to a CB2S version previously documented. That suggests shared design origins across modules in this family. [Elektroda, divadiow, post #21237176]