[HELP] I2C on ESP32-S2: No Devices Found with PCA Board

Hi all,

I'm currently trying to establish an I2C connection between my ESP32-S2 and a PCA board, but I'm running into issues. The serial monitor keeps saying, "No I2C devices found," and I can't figure out why.

Here’s my setup.


Wiring:

  • GND on PCA → G on ESP32-S2
  • VCC on PCA → 5V power on ESP32-S2
  • SDA on PCA → GPIO21 on ESP32-S2
  • SCL on PCA → GPIO18 on ESP32-S2 (I know GPIO22 is the usual SCL pin, but the ESP32-S2 doesn’t have GPIO22, so I specified GPIO18 in my code.)

Code:

#include <Wire.h>
#define I2C_SDA 21
#define I2C_SCL 18


void setup()
{
  Wire.begin();

  Serial.begin(9600);
  while (!Serial);             
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);  
}

Serial monitor output
Scanning ....
No I2C devices found.

Does anyone have ideas on what might be wrong? Could it be a wiring issue, a problem with the code, or something specific to the ESP32-S2? Any help is greatly appreciated!

Had you put your sketch in a <CODE/> block and not in a screen shot, as requested in How to get the best out of this forum, it would have been possible to search your code for where you passed I2C_SDA and I2C_SCL to the Wire object to inform it that you wanted to use alternate pins.

However, since you didn't see fit to include your sketch in a <CODE/> block, no such search is possible. And I'm not eyeballing every line in the screen shots.

are you sure you have the correct I2C pins?
have a look at ESP32 SPI Communication: Set Pins, Multiple SPI Bus Interfaces, and Peripherals
try running the program in Finding your ESP32 Board’s Default SPI Pins
I don't have an ESP32S2 but running the code on a ESP32-S3-DevKitC-1 I get

MOSI: 11
MISO: 13
SCK: 12
SS: 10
SDA: 8
SCL: 9

looking at the pinout in esp32-s2-pinout-specs-and-arduino-ide-configuration it shows SDA as GPIO8 and SCL as GPIO9
what specific ESP32S2 board do you have?

Thanks for letting me know, sorry about that! Just fixed.

Thank you for doing that, and now that you have it took all of 5 seconds to search and discover that you didn't in fact use I2C_SDA or I2C_SCL anywhere in your sketch after #define ing them.

So think about that for a moment; how would Wire know to use your specific pins if you haven't told it about them?

Use 3.3V. Using 5V will pull up SDA and SCL to 5V which is too high for the ESP32S2. I would also disconnect all other wires for the I2C test. If you have other wires plugged in backwards or wrong voltages it may prevent the board from working. Debug the I2C interface before connecting more wires.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.