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?
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.
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'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?