Arduino IDE fails on upload

Hey everybody

My IDE isn't able to upload any code to the MKR WiFi 1010 I'm using. I'm also using a MKR485 shield attached to the Arduino.
Most of the time the IDE is stuck during upload, but sometimes it displays this error message:

Arduino: 1.8.13 (Windows 10), Board: "Arduino MKR WiFi 1010"

Sketch uses 12240 bytes (4%) of program storage space. Maximum is 262144 bytes.

Global variables use 2952 bytes (9%) of dynamic memory, leaving 29816 bytes for local variables. Maximum is 32768 bytes.

Forcing reset using 1200bps open/close on port COM4

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

PORTS {COM1, COM4, } / {COM1, COM4, } => {}

Uploading using selected port: COM4

C:\Users\lezai\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0-arduino3/bossac.exe -i -d --port=COM4 -U true -i -e -w -v C:\Users\lezai\AppData\Local\Temp\arduino_build_811093/sketch_jan25a.ino.bin -R

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Here's the code I'm using. It's still a work in progress so it doesn't work 100% yet.

#include <ArduinoRS485.h>
#include <ArduinoModbus.h>

void setup()
{
  Serial.begin(9600);                                               //Setup Serial port
  while (!Serial);                                                  //wait for serial port to connect
  Serial.println("Modbus conductivity Sensor");
  // start the Modbus RTU client, Works!
  if (!ModbusRTUClient.begin(38400, SERIAL_8N1))                               //Checks if Modbus RTU client started properly
  {
    Serial.println("Failed to start Modbus RTU Client!  ");         //returns message if Modbus RTU Client didn't start properly
    while (1);
  }
}

void loop()
{
  

  float con = ModbusRTUClient.holdingRegisterRead(247, 504);           //first value
  Serial.println(con);
  float con2 = ModbusRTUClient.holdingRegisterRead(247, 1003);           //second value
  Serial.println(con2);

  // send a Holding register read request to (slave) id 247, for 2 registers  (requestFrom(id, type, address, nb);)
  if (0 == ModbusRTUClient.requestFrom(247, HOLDING_REGISTERS, 0x01002, 5))
  {
    Serial.print("Failed to read registers!");                      //returns error code if read fails
    Serial.println(ModbusRTUClient.lastError());
  }
  else
  {
    // If the request succeeds, the sensor sends the readings, that are
    // stored in the holding registers. The read() method can be used to
    // get the conductivity values
    float conductivity2 = ModbusRTUClient.read();
    Serial.println(conductivity2);
  }
  delay(5000);
}

Hope you can help me!!!

I got a new error code!!!

Arduino: 1.8.13 (Windows 10), Board: "Arduino MKR WiFi 1010"

Sketch uses 43776 bytes (16%) of program storage space. Maximum is 262144 bytes.

Global variables use 3536 bytes (10%) of dynamic memory, leaving 29232 bytes for local variables. Maximum is 32768 bytes.

Forcing reset using 1200bps open/close on port COM4

processing.app.debug.RunnerException

at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:152)

at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)

at processing.app.SketchController.upload(SketchController.java:732)

at processing.app.SketchController.exportApplet(SketchController.java:703)

at processing.app.Editor$UploadHandler.run(Editor.java:2055)

at java.lang.Thread.run(Thread.java:748)

Caused by: processing.app.SerialException: Error touching serial port 'COM4'.

at processing.app.Serial.touchForCDCReset(Serial.java:107)

at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:136)

... 5 more

Caused by: jssc.SerialPortException: Port name - COM4; Method name - openPort(); Exception type - Port busy.

at jssc.SerialPort.openPort(SerialPort.java:164)

at processing.app.Serial.touchForCDCReset(Serial.java:101)

... 6 more

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

 COM4; Method name - openPort(); Exception type - Port busy.

Pleas verify if this is proper COM4 port number and any other device isin't connected to it

I checked the Device-Manager, COM4 isn't occupied by anything other then the Arduino.

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