Upload is inconsistent due to bug in Arduino code?

I've been working on some code for an Arduino Nano 33 BLE which has multiple I2C devices connected to different pins. I tried to add another one, but the code hung while initializing communications with the new device. I thought the error might be in the code, so I tried to change the code and reupload, and... I couldn't. I tried several times (restarting the IDE, disconnecting/reconnecting the board, etc) and I got a variety of errors, such as timeouts and once even "already connected".

Eventually I found the most consistent way to get the upload to work is to click "upload" in the IDE, wait for it to compile, and then press the physical reset button on the board.

Is my suspicion that problematic code prevented the upload feasible? I suppose it's also possible that I have a faulty USB cable, but the timing with which it stopped working seemed a bit too coincidental. If that is the case, how do I prevent the Arduino from getting stuck in the future?

It sounds like you have too many devices for the power supply - are you powering off the Arduino ?

Have a look at the forum guidelines - you really need to put your code and wiring diagram on here , otherwise it’s guess work .

The line of code that freezes is _connected = _gps.begin(_theI2C);, so I don't suspect the code will be overly useful. The new device that doesn't work is powered with an external battery, not the Arduino itself, I just tied the grounds together.

I'll also note that it still freezes and fails to upload if I use the same code but completely disconnect the I2C device.

As per my post ……without knowing what you have , it could be caused by fairies at the bottom of the garden.

As I said earlier, the device is not connected. I shouldn't have to provide a schematic for two devices that are not connected to each other.

The function that freezes up is this library function. It's possible that it's a library bug, but I shouldn't be able to lock up the board by uploading buggy code -- hence why I ask if that suspicion is even feasible.

Who would know?
You have provided next to nothing in information......show a drawing of the circuit (no fritzing)
Show the code.......include whatever you are using to power the system.

I think a photograph will work better than a drawing to illustrate what I mean by "not connected":

I'm working on getting a MWE for the code (the full code is several hundred lines split across four files) but it's difficult to test when the problem it causes is failure to upload code.

Put up the error message when it “ won’t up load “, that tells you the problem ( or tells us)
Does it compile ?
What freezes ?
What have you tried to fix it ( eg run simplified code just for the gps) ?
Are you using compatable libraries
What is this code supposed to be ?


//The line of code that freezes is _

connected = _gps.begin(_theI2C);

Maybe it needs the gps in circuit ? Addresses wrong?

Need more info !!

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