RP2040 Connect fails for Arduino IoT, works for non-IoT sketches

Hello - I can't get my RP2040 Connect to work with an Arduino IoT Cloud sketch.

I set up a simple test IOT cloud sketch to set a single variable and increment it over time (with a 10-second delay in void loop() ). It compiles and uploads to the RP2040, but then my Macbook starts complaining about the USB connection every ~10 seconds that "the disk you attached was not readable by this computer". The RP2040 seems to not be executing the sketch, as far as I can tell. Some observations:

  • The RP2040 is correctly associated with the Thing.
  • The IoT Cloud doesn't seem to think the RP2040 is sending any data, but since this is my first attempt to use a dashboard, I could be doing something else wrong there.
  • I copied a built-in LED flashing from blink.ino into void loop() of the IoT sketch, but I never see the LED flash. However, I think I saw that somehow the frequency of the MacBook "disk" error matches the delay I put in loop().
  • I've done a few factory resets, but the result is always the same.
  • I tried commenting out the default call to ArduinoCloud::printDebugInfo in void setup(), but it made no difference.
  • I downloaded the IoT sketch and uploaded it using the IDE (Arduino 1.8.19), and got the same problem as using the web interface.
  • I've tried going to boot loader mode and copying the .elf.uf2, to the same effect as above.
  • I can upload and run other (non-IoT) sketches I've written on my Macbook using Arduino IDE 1.8.19 onto this same RP2040 Connect, and they work fine as intended, with no complaint from the MacBook about the USB connection. I get data back on the serial link just fine, I can make LEDs blink, etc. However, as soon as the upload is complete, the MacBook does announce that I unplugged a "disk" without ejecting it. (And then the sketch works fine.). This message does not happen when I upload to my Uno Wifi Rev2 or Nano Every.
  • The Duo Wifi 2 is in use elsewhere, so I haven't tried the IoT sketch with it. (The Every has no wifi.)

Any suggestions on how to debug this would be most appreciated.

Thank you,
Peter

Factory reset your board following the steps at https://support.arduino.cc/hc/en-us/articles/4404168794514-Nano-RP2040-Connect-not-being-detected-on-USB-port and then use this example https://docs.arduino.cc/tutorials/nano-rp2040-connect/rp2040-iot-cloud to connect it to the IoT cloud.

Note: Make sure that you have create agent intalled with admin rights.

I've noticed this as well on my own RP2040 Connect, also with a Macbook. Same issue from what I can tell. I haven't worked it out 100% yet, but I did notice that there's a watchdog that seems to be causing the aggressive reboot on the board. Generally, this is helpful, but the timing seems to be too quick before cloud functionality kicks in for this particular case.

You can try disabling the watchdog by passing false as an additional parameter to the ArduinoCloud.begin function in your setup. In my case this resolved the repeated reboots, but I noticed some issues on my end connecting to the cloud service -- however this could be unrelated.

My setup looks like so, for reference:

void setup() {
    ...
    // Connect to Arduino IoT Cloud, disabling watchdog
    ArduinoCloud.begin(ArduinoIoTPreferredConnection, false);
    ...
}

Hopefully this helps!

Thank you, Dozie. I have tried many factory resets, and the create agent was installed with admin rights. I have also tried temporarily disabling the Mac firewall, to no effect.

Thank you, Mernok! I will give this a try this weekend.

Whether or not it works, it's great to hear that someone else has experienced the same issue, and perhaps I am not nuts!

Many thanks,
Peter

No problem! I wanted to follow up that once I had the watchdog disabled, I was able to find that the underlying issue for me being unable to connect to the IoT Cloud was waiting on the serial port to connect for my given sketch, via while (!Serial);. Only noticed it once I saw opening up the serial monitor caused the board to become responsive at the same time. That didn't make too much sense, given I wasn't planning to have the serial port connected while running the board remotely :laughing:. Removing this check made the board nice and responsive on boot, and I've had no problems connecting to the IoT Cloud since that.

I haven't tried it yet, but I still wanted to see if reinstating the watchdog now behaves as expected. It would be nice to have in case the board hangs for any reason down the road.

OK, so I did yet another factory reset, deleted the Thing and Device, and started over with my own sketch. I also had the MacBook firewall off. Something was different right away. I did get one "can't read this device/ignore/eject/retry", but it didn't keep repeating every 10 seconds like before.

I can't think of anything I did differently in the code, but maybe there was some bug that got deleted when I started over. Unless there was an update to a library that fixed something.

Thank you, and @mernok again for your help!