logo elektroda
logo elektroda
X
logo elektroda

DOIT/Cozylife ESP-C2 Mini Smart Switch: Aiyato BRK-HW1KN1/DS-1311WN V1.2

divadiow 3612 11
ADVERTISEMENT
  • #1 21237176
    divadiow
    Level 38  
    Posts: 4835
    Help: 420
    Rate: 852
    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.

    On the PCB is printed DS-1311WN V1.2 2023.05.15 which links it to this CB2S version posted by @p.kaczmarek2 https://www.elektroda.com/rtvforum/topic4057978.html

    Flashing/backup and log capture was the same as with the BSD16, so I'll not detail that. Straight to some pics and logs.

    Aiyato BRK-HW1KN1 smart switch and packaging on a blue background. ESP-C2 module on a wooden surface ESP-C2-02 module with Wi-Fi and Bluetooth on a wooden surface Close-up of DS-1311WN V1.2 circuit board from May 15, 2023. Wi-Fi/Bluetooth module ESPC2-02 on a PCB with markings. Image of a green PCB labeled DS-1311WN V1.2 with electronic components and a button. Close-up of a PCB with electronic components and connectors. ESPC2-02 module on PCB labeled DS-1311HN-1 YONGWEI Y12FT-105DM relay on a circuit board. ESPC2-02 module on a PCB with a relay. PCB module of a smart switch with a relay and capacitors. Close-up of the PCB of the Aiyato BRK-HW1KN1 smart switch. Side of the packaging with product and manufacturer information for a smart switch. Product box with information on compatibility with Apple HomeKit. Mini smart switch in a white casing with a perforated pattern. ESP-C2 module with connected colored wires.

    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


    ESPC2-02 schematic with PCB connections.

    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
    Wiring diagram for one-way control using a switch.

    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.
  • ADVERTISEMENT
  • #2 21237189
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14393
    Help: 650
    Rate: 12314
    It's interesting that they reused the PCB label...

    Regarding button presses, maybe this needs configurable pull up on ESP? @insmod

    So you're saying that you're unable to control GPIO7 on this platform?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21237193
    divadiow
    Level 38  
    Posts: 4835
    Help: 420
    Rate: 852
    it's certainly the case that nothing I've tried is opening/closing the relay
  • #4 21237195
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14393
    Help: 650
    Rate: 12314
    So GPIO7 in general is not working on ESP platform? Even on dev boards? It can't toggle LED?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21237209
    divadiow
    Level 38  
    Posts: 4835
    Help: 420
    Rate: 852
    I've just tried IO7 on C2 and C3 with LED assignment and the LED is always lit dimly after assignment. So always pulled high? it is not controllable
    Close-up of a breadboard with connected LEDs and resistors.
  • #6 21238286
    divadiow
    Level 38  
    Posts: 4835
    Help: 420
    Rate: 852
    1344_merge_0d72382ec124
    To extend testing and in summary:

    ESP32S3 - IO7 controllable

    ESP32C2 - IO7 not controllable - dim LED
    ESP32C3 - IO7 not controllable - dim LED
    ESP32C6 - IO7 not controllable - dim LED

    ESP32 - IO7 always dim high - cannot assign pin - maybe not meant for GPIO?

    anyway, maybe the issue is just with the Cx types
  • #7 21238295
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14393
    Help: 650
    Rate: 12314
    GPIO7:
    https://www.flux.ai/p/blog/esp32-pinout-everything-you-need-to-know
    Table showing GPIO pin functions on ESP32.
    @ElektrodaBot 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?
    Helpful post? Buy me a coffee.
  • #8 21238303
    ElektrodaBot
    AI OpenAI ChatGPT4
    Posts: 8722
    Help: 349
    Rate: 917
    Board Language: polish
    p.kaczmarek2 wrote:
    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.
  • #9 21244368
    divadiow
    Level 38  
    Posts: 4835
    Help: 420
    Rate: 852
    Built on Sep 29 2024 21:52:31 version 1344_merge_77dfe2ae2220

    Toggle now works on this build and the relay is opening and closing on this device from OBK GUI and with the physical button.

    current assignments:

    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • #11 21246663
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14393
    Help: 650
    Rate: 12314
    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....
    Helpful post? Buy me a coffee.
  • #12 21247316
    divadiow
    Level 38  
    Posts: 4835
    Help: 420
    Rate: 852
    p.kaczmarek2 wrote:
    I guess now it's time for a DHT11 mod or something?

    I guess this could be an option. But..

    Maybe Tasmota drivers are more forgiving of fake sensors or there's an ESP issue.

    A table displaying temperature, humidity, and dew point readings from AM2301 and DHT11 sensors connected to an ESP32-DevKit using Tasmota. Screenshot of the OpenESP32 user interface displaying DHT22 and DHT11 sensor information

    Display with readings for temperature, humidity, and dew point for AM2301-04 and DHT11-06 sensors on ESP32C6 with Tasmota. OpenESP32C6 user interface with sensor data.

    Screenshot of sensor readings for DHT11-04 and AM2301-06 showing temperature, humidity, and dew point values. OpenESP32S2 user interface displaying DHT11 and DHT22 sensor information.

    Added after 1 [minutes]:

    divadiow wrote:
    Maybe Tasmota drivers are more forgiving of fake sensors


    I should add to that that I recall inconsistent experience with these same DHTs even on Beken

Topic summary

✨ 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.

FAQ

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.

Quick Facts

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:
  1. Update to OpenBeken build 1344 or newer.
  2. Set pins: 4 TglChanOnTgl; 7 Rel; 10 LED_n; 20 Btn_Tgl_All.
  3. Save, then toggle from the OBK GUI and the physical button to confirm. [Elektroda, divadiow, post #21244368]

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]
Generated by the language model.
ADVERTISEMENT