scanner-i2c.ino
The ESP32-S3 strength: I2C routes to any pin thanks to the GPIO matrix. This scanner explicitly declares SDA=D6/SCL=D5 of the Nano ESP32 then enumerates devices — the reflex before using a sensor with a doubtful address.
Hardware
An Arduino Nano ESP32 (dual-core ESP32-S3, 2.4 GHz Wi-Fi + Bluetooth Low Energy, Nano-compatible physical pinout, native USB, 3.3 V pins only). Nano ESP32, one or several I2C modules (address 0x76, 0x3C, 0x68...), pull-ups on a home-made bus.
Wiring
SDA→D6, SCL→D5 (the board default Wire pinout), VCC/GND per module.
How it works
Wire.begin(sda, scl) routes the I2C controller onto the requested pins. endTransmission() tests ACK address by address, from 0x08 to 0x77.
Running it
Install the Arduino ESP32 Boards package (or follow the official Nano ESP32 guide), select Arduino Nano ESP32, upload. Pins are 3.3 V: never feed 5 V into an input. The serial monitor uses native USB.
Variants
Create two buses Wire(0) and Wire(1) to isolate two sensitive sensors, or change pinning if it clashes with an SPI peripheral.
scanner-i2c.ino
// Sur l'ESP32-S3, I2C est sur la matrice de broches : on choisit SDA/SCL.
// La Nano ESP32 expose Wire sur D6 (SDA) / D5 (SCL) par defaut.
#include <Wire.h>
const int SDA = 6;
const int SCL = 5;
void setup() {
Serial.begin(115200);
Wire.begin(SDA, SCL); // brochage explicite : pas de surprise
Serial.println(F("Scan I2C 0x08-0x77..."));
int trouves = 0;
for (byte a = 0x08; a <= 0x77; a++) {
Wire.beginTransmission(a);
if (Wire.endTransmission() == 0) {
Serial.print(F("repond a 0x"));
Serial.println(a, HEX);
trouves++;
}
}
if (!trouves) Serial.println(F("aucun peripherique"));
// Poursuite : ouvrir le bus avec les memes broches partout ailleurs
}
void loop() { delay(1000); }