Hi, I’m new to this board and my project uses the I2C bus. I use the default GPIO pins IO21-SDA and IO22-SCL.
When I run my program stripped down with no graphics or touch screen the program runs fine on the board and communications with my I2C peripheral works perfectly. When I modify a working graphics-touchscreen program to include I2C by adding I2C the program run on the same board, it compiles but then hangs when I add Wire.begin(); The graphics will load but the touchscreen stuff quits working. I tweaked a bit with trying to reassign SDA and SCL, but that didn’t seem to help. The documentation isn’t the greatest and there are limited GPIO pins available to use.
Any help would be greatly appreciated
Thanks!
Hi.
If you have a CYD board like ours, GPIO 21 is used to control the backlight of the display. So, I don’t recommend using that GPIO for I2C communication.
You can learn more about the pinout of the board here: https://randomnerdtutorials.com/esp32-cheap-yellow-display-cyd-pinout-esp32-2432s028r/
Instead, I recommend using GPIOs 22 and 27.
SDA – GPIO 27
SCL – GPIO 22
So, you need to set a custom I2C bus on those pins.
An example is this tutorial, in which we connect a BME280 sensor. Take a look at the code and see how we used the custom pins for I2C communication:https://randomnerdtutorials.com/esp32-cyd-lvgl-display-bme280-data-table/
I hope this helps.
Let me know if you can fix the issue.
Regards,
Sara