// PicoI2Cscanner.ino
//
// This sketch is for:
// https://forum.arduino.cc/t/connect-a-arduino-pro-micro-with-a-raspberry-pi-pico/949404/
//
// Version 1, 20 January 2022, by Koepel, Public Domain
//
// Using the common I2C scanner.
//
// Raspberry Pi Pico in Arduino mode (on top of Mbed).
// SDA = GP6
// SCL = GP7
//
// Notes:
// In Real Life, there must be a I2C level shifter for a 5V LCD display.
// The Wokwi simulation uses Serial1 at this moment.
//
#include <Wire.h> //include Wire.h library
void setup()
{
Serial1.begin( 115200);
while( !Serial1)
{
delay( 10); // wait for serial port to connect. Needed for native USB
}
Serial1.println( "I2C Scanner");
Wire.begin();
}
void loop()
{
byte error, address;
int nDevices;
Serial1.println( "Scanning...");
nDevices = 0;
for( address = 1; address < 127; address++ )
{
Wire.beginTransmission( address);
error = Wire.endTransmission();
if( error == 0)
{
Serial1.print( " I2C device found at address 0x");
if( address < 16)
Serial1.print( "0");
Serial1.println( address, HEX);
nDevices++;
}
}
if( nDevices == 0)
Serial1.println( "No I2C devices found\n");
else
Serial1.println( "done\n");
delay( 5000);
}
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL
rtc1:GND
rtc1:5V
rtc1:SDA
rtc1:SCL
rtc1:SQW
imu1:INT
imu1:AD0
imu1:XCL
imu1:XDA
imu1:SDA
imu1:SCL
imu1:GND
imu1:VCC
oled1:DATA
oled1:CLK
oled1:DC
oled1:RST
oled1:CS
oled1:3V3
oled1:VIN
oled1:GND