Hi everyone, everytime I try uploading something to my brand new MKR 1010 WiFi, It disconnect and reconnect from my pc while uploading and sometimes it works and others I had to hard reset the board by pressing the button 2 times. Any advice?
Thanks in advance
P.s. I tried Arduino IDE 1.8 and 2.0, but I had the same result
Your board supports native USB as far as I know. THE IDE first issues a software reset (opening and closing the serial port with a baudrate of 1200) to activate the boot loader and next does the actual upload. So the disconnect/connect is normal.
If you're a Windows user, you can observe the process in Windows device manager
It will show
A normal port (e.g. COM4); it will probably also state "MKR 1010 WiFi".
The upload port (e.g. COM7) after the reset; it will probably also state "MKR 1010 WiFi upload".
The normal port (e.g. COM4) again once the upload is finished.
Does this happen with any sketch that you upload? E.g. upload blink (try it repeatedly); if no, you might have a bug in your sketch that causes your board not to recognise the reset command.
Part of the code that is uploaded is responsible for the board detection as well as the detection of the reset; a bug in your code can cause corruption of variables used by that specific part of the code.
Blink doesn't have any problem also uploaded repeatedly.
My code make the board disconnecting forever (I had to force reset pressing reset button 2 times quickly), but I can't recognise the error (I'm quite new and I've never used mkr board.
Can I share the code here for just a fast check by you?
ecg.ino (4.2 KB)
Here you are the code.
It simply acquire some data from a module connected to pin A0 and the pin 10 and 11 are simply check pin to check if connection with module is fine
The strange part is that the code seems to not have any error while verifying, but the arduino get stuck immediately (I tried putting a Serial.println("1"); at the beginning of void loop and It doesn't even print it
Most here(including me) will not download that because of the chance of malware.
Please follow the guide for posting code here: How to get the best out of this forum
Also please post the error message.
Well Thanks to @sterretje I've uploaded your code and it runs and prints the exclamation mark as it should. I'm not getting any error's.
I added more print statements and connected a button. @sterretje nailed it. As soon as the button is pushed and the code enters the code section that @sterretje posted it runs it once then on the second time thru it locks up the IDE until the WIFI1010 is unplugged.
I changed the code so that it prevents writing outside the bounds of your array. When it tries to go below 0 it is redirected to the last array member instead. It functions well now but I don't know if that is the behavior you wanted.
Here is how I changed one of them: