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.
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. Summary generated by the language model.