This i2c code breaks the raspberry pi pico

I am testing a very very simple i2c wire code for the raspberry pi pico using the arduino IDE, This simple code breaks the pico and after uploading it, it will make the pico into an unrecognized usb device.

#include <Wire.h>

void setup() {
  Wire.begin(0x53);        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output

void loop() {
  Wire.requestFrom(0x53, 6);    // request 6 bytes from slave device #8

  while (Wire.available()) { // slave may send less than requested
    char c =; // receive a byte as character
    Serial.print(c);         // print the character


Something to note, the led indicator is blinking in an irregular pattern.

What makes it weird is i have uploaded successfuly i2c code that doesnt break , for example this i2c sniffer

#include <Wire.h> //include Wire.h library

void setup()
  Wire.begin(); // Wire communication begin
  Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
  while (!Serial); // Waiting for Serial Monitor
  Serial.println("\nI2C Scanner");

void loop()
  byte error, address; //variable for error and I2C address
  int nDevices;


  nDevices = 0;
  for (address = 1; address < 127; address++ )
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = Wire.endTransmission();

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

  delay(5000); // wait 5 seconds for the next I2C scan

Luckily i can revert it by pressig the bootsel and upload a known working code like fo example the blink sketch.

No wonder! How shall the Pico request data from himself?

I see the problem in the code. :rofl:

But then again it shouldnt make the device not recognisable to usb, i would understand that i would get trash data or the i2c would lock up.

Right, that's annoying. Perhaps the Pico is locked in the (missing) interrupt handler that should provide the data.

Now you can start a thesis about this problem or fix your code :wink:

Remember that PICO has no USB/Serial interface chip! USB is built-in to Pico. I don't see any problem in this case. I think you will need to study the PICO firmware to find your problem. One solution: plug a USB/Serial interface module into the PICO's serial port and you should get communication. Do it.

Post moved out of the ridiculous place you put it. This is an Arduino forum so why ask about the Pico here? In a section devoted to the setting up of the Arduino system and NOT your project.

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