Nano 33 IoT and Arduino Cloud doesn't connect on external power

I'm using a free Arduino Cloud account with a Nano 33 IoT to control some devices and log data. My problem is:

  • if I run the Nano from a laptop/USB, it works fine
  • if I start it connected to a laptop with USB, it will then carry on working on external power
  • if I start it just with external power, it never sends any data to the cloud
    Debugging this is a bit tricky - I suspect some Serial issues, so plugging a laptop in to see what's happening seems to fix the problem. I've added a bunch of status LEDs so I can see what state the device is in, and they tell me that:
  • the device is running otherwise as normal, even though no data is being sent
  • WiFi.status() is returning WL_CONNECTED
  • ArduinoCloud.getConnection()->check() is returning CONNECTED and ArduinoCloud.connected() is returning true.

I have tried making sure the watchdog is disabled (ArduinoCloud.begin(ArduinoIoTPreferredConnection, false);), but otherwise, I'm out of ideas. I'll try a minimal working example next, but I thought I'd see if anyone has run into something similar?

No experience with your board or the cloud. Your board has, as far as I know, native USB. In which case you can use the Rx/Tx pins and a serial-to-usb adapter for debugging on Serial1.

Any chance that you have a while(!Serial) in your code? Without a computer connection, your code will hang there forever.

Thanks! Serial1 could well be worth a go for investigation.

There is a while(!Serial) but it's got a timeout on it (while(!Serial && millis() < 2000 ) {}), and I know it's getting past that step - I can see all the functions working normally, and I have an indicator light that continually changes so I can tell that it's running - it just doesn't send any data to the Arduino Cloud, despite appearing to be connected.