Hello all.
Here’s the situation I have and would like to see if you guys can help:
Goal:
- Display letters typed in an I2C qwerty mini keyboard (m5stack CardKB) onto the built-in display SSD1306 of the Heltec ESP32 LoRa v2 board.
Issue:
- Display works fine, keyboard works fine too, but when using the two in the same sketch I can’t read the keyboard.
Scenario:
- I connected the mini keyboard to the Heltec board via the following pins: SDA to pin 21, and SCL to pin 22. I confirmed the keyboard is properly wired and working, as I created a test sketch just for testing the keyboard and printing to the Serial, and I can read the keyboard fine. Address for the keyboard is 0x5F.
- As an aside, I tested the display on a separate sketch and it works fine. The address for the display is 0x3c. I’m using the u8g2 library.
- When I move the keyboard logic to my main sketch, which has logic to read the keyboard and print characters on the screen, the display works fine but I can’t read the keyboard. If I comment all the display functions, the keyboard comes back to life and I can read it and print to the serial just fine.
- Adding a I2C scanning function to the main sketch, it finds the display fine (0x3C) but the keyboard returns error 2 (0x5F). See below.
-> Testing device at address: 0x3C
-> Response: 0
-> Testing device at address: 0x5F
-> Response: 2
- The code in the scanning function is
Wire.beginTransmission(address); error = Wire.endTransmission();
- Now, if I run a I2C scanner in a separate sketch (without initializing/using nor the display or the keyboard), then it produces an inverted result (what?!). It can find the keyboard but not the display.
-> Testing device at address: 0x3C
-> Response: 2
-> Testing device at address: 0x5F
-> Response: 0
I suppose it might be some sort of I2C conflict. As a beginner I’m looking for ideas of where to look. Does anyone have some ideas of what to try next? How to make the main sketch be able to find and read the keyboard?
Thanks very much!