logo elektroda
logo elektroda
X
logo elektroda

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

divadiow 2175 11
ADVERTISEMENT
  • #1 21237176
    divadiow
    Level 34  
    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.
  • ADVERTISEMENT
  • #2 21237189
    p.kaczmarek2
    Moderator Smart Home
    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 34  
    it's certainly the case that nothing I've tried is opening/closing the relay
  • ADVERTISEMENT
  • #4 21237195
    p.kaczmarek2
    Moderator Smart Home
    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.
  • #5 21237209
    divadiow
    Level 34  
    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 34  
    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
  • ADVERTISEMENT
  • #7 21238295
    p.kaczmarek2
    Moderator Smart Home
    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
    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 34  
    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
  • #11 21246663
    p.kaczmarek2
    Moderator Smart Home
    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 34  
    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.
Summary generated by the language model.
ADVERTISEMENT