-
Notifications
You must be signed in to change notification settings - Fork 12
Platformio support #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @bubulgum, I think this library can be used in PlatformIO as follows. What issue are you encountering? In platformio.ini file:
|
I'm using it with CH422G. On Arduino IDE this example works fine:
But with Palformio have a lot of issues:
|
The ... |
this will make more trouble.
|
It looks like your build environment does not support C++17. Maybe you can use an older version v0.1.0 that does not depend on esp-lib-utils? |
I've tried |
@bubulgum Please post your platformio.ini The driver needs Arduino 3.x / >=IDF 5.1 so you have to use the Platformio fork pioarduino |
please have a look
|
Official Platformio only supports Arduino core 2.0.17. So the config can not work.
|
Thank you for your support, after core was updated, everything work on Platformio.
|
Could you provide more support, i could make working LEDs and buttons on my board with ESP32C3 with CH422 and library. #include <Arduino.h>
#include <esp_io_expander.hpp>
#define EXAMPLE_I2C_SDA_PIN (10)
#define EXAMPLE_I2C_SCL_PIN (4)
#define EXAMPLE_I2C_ADDR (ESP_IO_EXPANDER_I2C_CH422G_ADDRESS) // default 0x24
esp_expander::CH422G *expander = NULL;
// Pin definitions for buttons
#define BUTTON_PIN_1 8
#define BUTTON_PIN_2 2
#define BUTTON_PIN_3 7
#define BUTTON_PIN_4 6
#define BUTTON_PIN_5 5
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("Test begin");
expander = new esp_expander::CH422G(EXAMPLE_I2C_SCL_PIN, EXAMPLE_I2C_SDA_PIN, EXAMPLE_I2C_ADDR);
expander->init();
expander->begin();
// Set all pins 0-7 as outputs for LEDs
expander->enableAllIO_Output();
// Set button pins as inputs with pull-up resistors
pinMode(BUTTON_PIN_1, INPUT_PULLUP);
pinMode(BUTTON_PIN_2, INPUT_PULLUP);
pinMode(BUTTON_PIN_3, INPUT_PULLUP);
pinMode(BUTTON_PIN_4, INPUT_PULLUP);
pinMode(BUTTON_PIN_5, INPUT_PULLUP);
// All LEDs are off by default (HIGH)
expander->digitalWrite(0, HIGH); // Turn off LED on pin IO0
expander->digitalWrite(2, HIGH); // Turn off LED on pin IO2
expander->digitalWrite(4, HIGH); // Turn off LED on pin IO4
expander->digitalWrite(6, HIGH); // Turn off LED on pin IO6
expander->digitalWrite(8, HIGH); // Turn off LED on pin OC0
expander->digitalWrite(1, HIGH); // Turn off LED on pin IO1
expander->digitalWrite(3, HIGH); // Turn off LED on pin IO3
expander->digitalWrite(5, HIGH); // Turn off LED on pin IO5
expander->digitalWrite(7, HIGH); // Turn off LED on pin IO7
expander->digitalWrite(9, HIGH); // Turn off LED on pin OC1
Serial.println("LEDs on IO0, IO2, IO4, IO6, and OC0 are set to output mode.");
}
void loop() {
// Check the button states and turn on corresponding LEDs
if (digitalRead(BUTTON_PIN_1) == LOW) { // Button 1 pressed (LOW is active)
expander->digitalWrite(1, LOW); // Turn on LED on pin IO0
Serial.println("Button 1 pressed, LED IO0 ON");
} else {
expander->digitalWrite(1, HIGH); // Turn off LED on pin IO0
}
if (digitalRead(BUTTON_PIN_2) == LOW) { // Button 2 pressed
expander->digitalWrite(3, LOW); // Turn on LED on pin IO2
Serial.println("Button 2 pressed, LED IO2 ON");
} else {
expander->digitalWrite(3, HIGH); // Turn off LED on pin IO2
}
if (digitalRead(BUTTON_PIN_3) == LOW) { // Button 3 pressed
expander->digitalWrite(5, LOW); // Turn on LED on pin IO4
Serial.println("Button 3 pressed, LED IO4 ON");
} else {
expander->digitalWrite(5, HIGH); // Turn off LED on pin IO4
}
if (digitalRead(BUTTON_PIN_4) == LOW) { // Button 4 pressed
expander->digitalWrite(7, LOW); // Turn on LED on pin IO6
Serial.println("Button 4 pressed, LED IO6 ON");
} else {
expander->digitalWrite(7, HIGH); // Turn off LED on pin IO6
}
if (digitalRead(BUTTON_PIN_5) == LOW) { // Button 5 pressed
expander->digitalWrite(9, LOW); // Turn on LED on pin OC0
Serial.println("Button 5 pressed, LED OC0 ON");
} else {
expander->digitalWrite(9, HIGH); // Turn off LED on pin OC0
}
delay(100); // Delay to prevent button debounce
} Scan I2C found this address:
Looks like all belong to CH422G, But I also have OLED display on this board that using I2C with same SDA and SCL on address 0x3C. So my question is: How put CH422G to SLEEP mode using library? |
Hi @bubulgum, CH422G currently does not support entering sleep mode. I have added this feature in the feat/ch422g_support_sleep branch, please give it a try. |
Hi. please make library for Platformio with CH422G. thx
The text was updated successfully, but these errors were encountered: