Nano serial port busy, can't upload new software--Solved

I can't believe I did this, but I put a one-wire port on pin 0 and another on pin 1 (Nano with 328). RX and TX are now doing their one-wire handshakes and the USB port can't reset the Nano into the bootloader. One-wire is talking to DS18B20 temperature sensors. I disconnected the sensors, hoping that would allow the reset, but it didn't work.

The error message is "processing.app.SerialException: Serial port 'COM36' already in use. Try quiting any programs that may be using it." The previously uploaded software has several operations during setup that take about 4 seconds, so the one-wire handshake doesn't start right away. I've attempted to hold the Nano in reset and let go just prior to the start of the upload, hoping to get the upload the upload to start during that 4 second window. Either I'm not timing the release close enough or the technique isn't working.

Is there any way to kill the uploaded software without killing the bootloader at the same time? If not, is there a way to erase the chip and reload the bootloader? Thanks.

Dr. Quark

Yes, there is a way to force an upload when you have an existing sketch messing with the pins 0 and 1 that the bootloader uses. It may take a few time to get the timing just right, but here are the steps:

  1. Remove any wiring that you have connected to pins 0 and 1 on your board.
  2. Plug the board into your PC.
  3. Press and hold down the reset switch, this may take more hands then you have but deal with it. :wink:
  4. Start the arduino IDE, select the proper board type, com channel, and load the sketch you want to upload or even
    the example blink sketch.
  5. Press upload on the IDE, and only when you see the uploading message in the IDE do you release the reset button.

Again you might have to play with the exact timing needed for this 'well timed manual reset' but it will work if there is no damage on your board.

Let us know how it turns out for you.

Lefty

BTW, I've maxed out my digital pins, so I need to use the RX and TX lines for one-wire (or I could add another Nano and let them talk). Anyway, if I put a delay in the software so the one-wire isn't constantly polling the ports, would that allow the Environment to upload new versions?

thanks

Lefty, thanks for confirming that the manual reset might work. I was editing my post as you were writing. I'll keep trying will report back.

I don't ever see an "uploading" message. The IDE immediately reports and error as soon as it's done compiling

Here's the code, down to where the loop starts. I don't see anything in the setup code that would be tickling the RX or TX pins:

// Load Libraries
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

// Load Libraries for DS1820 and OneWire
#include <OneWire.h>
#include <DallasTemperature.h>
 
// Define variables LDCD: 
#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

// Data wire is plugged into pin 12 on the Arduino
#define T_bus_0 0  // Usually pin 4
#define T_bus_1 1
 
// Setup oneWire instance to communicate with devices
OneWire oneWire0(T_bus_0);
OneWire oneWire1(T_bus_1);
 
// Pass oneWire reference to Dallas Temperature.
DallasTemperature sensor0(&oneWire0);
DallasTemperature sensor1(&oneWire1);

int n = 1;

//Initialise the LCD
LiquidCrystal_I2C   lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); 

float intempf = 74.3 ;
float outtempf = 65.7 ;
float tanktempf = 68.4 ;
float refertempf = 25.1;
float battf = 12.7;
float ampsf = -3.2 ;

int intemp = 74 ;
int outtemp = 68 ;
int tanktemp = 47 ;
int refertemp = 28 ;
int batt ;
int amps ;
int inmax = 30;
int inmin = 90;
int outmax = 30;
int outmin = 90;
int tankmin =32;
int tankmax = 70;
int refermax = 10;
int refermin = 32;

// associate output pins with LEDs
int freshlow = 11 ;
int freshmid = 2 ;
int freshfull = 3 ;
int blacklowest = 4 ;
int blacklow = 5 ;
int blackmid = 6 ;
int blackfull = 7 ;
int graylow = 8 ;
int graymid = 9 ;
int grayfull = 10 ;

int pause = 500 ;

char degree = B11011111 ;

// Up arrow
byte uparrow[8] = {
  B00100,
  B01010,
  B10101,
  B00100,
  B00100,
  B00100,
  B00100,
  B00100 } ;
// Down arrow
byte downarrow[8] = {
  B00100,
  B00100,
  B00100,
  B00100,
  B00100, 
  B10101,
  B01010,
  B00100 } ;
  

// ----------------------Setup------------------------
void setup() {
// Define LCD as 20 column x 4 rows
   lcd.begin (20,4);
  
// Switch on the backlight
   lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
   lcd.setBacklight(HIGH);
   
// assignes each segment a write number
  lcd.createChar(1,uparrow);
  lcd.createChar(2,downarrow);
  
  lcd.setCursor ( 0, 0 );
  lcd.print("Ver: Monitor 1.0.1") ;
  delay(2000) ;
  lcd.setCursor ( 0, 0 );  
  lcd.print("                  ") ;  
  
// set ouput pins
  pinMode(2, OUTPUT) ;
  pinMode(3, OUTPUT) ;
  pinMode(4, OUTPUT) ;
  pinMode(5, OUTPUT) ;
  pinMode(6, OUTPUT) ;
  pinMode(7, OUTPUT) ;
  pinMode(8, OUTPUT) ;
  pinMode(9, OUTPUT) ;
  pinMode(10, OUTPUT) ;
  pinMode(11, OUTPUT) ;
  
  digitalWrite(2, HIGH) ;
  digitalWrite(3, HIGH) ;
  digitalWrite(4, HIGH) ;
  digitalWrite(5, HIGH) ;
  digitalWrite(6, HIGH) ;
  digitalWrite(7, HIGH) ;
  digitalWrite(8, HIGH) ;
  digitalWrite(9, HIGH) ;
  digitalWrite(10, HIGH) ;
  digitalWrite(11, HIGH) ;
  
// Test output pins and LEDs
  digitalWrite(11, LOW) ;
  delay(pause) ;
  digitalWrite(2, LOW) ;
  delay(pause) ;
  digitalWrite(3, LOW) ;
  delay(pause) ;
  digitalWrite(4, LOW) ;
  delay(pause) ;
  digitalWrite(5, LOW) ;
  delay(pause) ;
  digitalWrite(6, LOW) ;
  delay(pause) ;
  digitalWrite(7, LOW) ;
  delay(pause) ;
  digitalWrite(8, LOW) ;
  delay(pause) ;
  digitalWrite(9, LOW) ;
  delay(pause) ;
  digitalWrite(10, LOW) ;
  delay(pause) ;
 
  digitalWrite(2, HIGH) ;
  digitalWrite(3, HIGH) ;
  digitalWrite(4, HIGH) ;
  digitalWrite(5, HIGH) ;
  digitalWrite(6, HIGH) ;
  digitalWrite(7, HIGH) ;
  digitalWrite(8, HIGH) ;
  digitalWrite(9, HIGH) ;
  digitalWrite(10, HIGH) ;
  digitalWrite(11, HIGH) ;
  
  
 // digitalWrite(freshlow, LOW) ;
 // digitalWrite(freshmid, LOW) ;
  
  digitalWrite(blacklowest, LOW) ; 
}
  
// ----------------- Start the Loop --------------------- 
void loop() {
...

I disconnected the Nano and I still get the serial port busy error message. Evidently the PC is maintaining COM36 as busy, even with nothing connected. I closed all open instances of the IDE, then reopened this particular app, but I still get the com port busy error.

Anyone know how to kill this connection in the PC so I can reestablish it? I thought unplugging the USB connection was a fail-safe way to do this.

Dr_Quark:
I disconnected the Nano and I still get the serial port busy error message. Evidently the PC is maintaining COM36 as busy, even with nothing connected. I closed all open instances of the IDE, then reopened this particular app, but I still get the com port busy error.

Anyone know how to kill this connection in the PC so I can reestablish it? I thought unplugging the USB connection was a fail-safe way to do this.

Any bluetooth stuff on your PC? It definitely is a PC side problem where something has grabed that com port number and the OS won't let any other application (like the arduino IDE) from gaining permission to use it. I assume you have tried restarting your PC?

Restarted the PC and was able to upload by holding reset on the Nano until the IDE was almost ready to call the bootloader.

thanks all.

BTW, I've maxed out my digital pins,

The analog pins can be used for digital also.
A0 to A5 are D14 to D19.