DocBohn / CowPi_documentation

Datasheet and Construction Instructions for Cow Pi hardware and libraries
Creative Commons Attribution 4.0 International
0 stars 0 forks source link

"Arduino Nano upload error in 'Arduino IDE 2.1.1': 'avrdude: ser_open(): can't set com-state for "\\.\COM4". #1

Closed willyliu93 closed 10 months ago

willyliu93 commented 10 months ago

I have tried the following methods in Arduino IDE 2.1.1, but I still cannot upload the code successfully every time:

  1. Re-download the latest CH340 driver.
  2. Try the processor options "ATmega328P" and "ATmega328P (Old Bootloader)".
  3. Replace the transmission line and slot.
  4. Try uploading on a different computer.

This error message appears every time:

The project uses 3218 bytes (10%) of program memory. The maximum value is 30720 bytes. global variables use 242 bytes (11%) of dynamic memory, leaving 1806 bytes for local variables. The maximum value is 2048 bytes. avrdude: ser_open(): can't set com-state for "\.\COM4" Upload failed: Upload error: exit status 1

'Arduino Nano' code I uploaded:

include

include "RF24.h"

RF24 rf24(7, 8); // CE pin, CSN pin

const byte addr[] = "1Node"; const byte pipe = 1; //Specify channel number

void setup() { Serial.begin(9600); rf24.begin(); rf24.setChannel(83); //Set channel number rf24.setPALevel(RF24_PA_MIN); rf24.setDataRate(RF24_250KBPS); rf24.openReadingPipe(pipe, addr); //Open channel and address rf24.startListening(); // Start listening to wireless broadcasts Serial.println("nRF24L01 ready!"); }

void loop() { if (rf24.available(&pipe)) { char msg[32] = ""; rf24.read(&msg, sizeof(msg)); Serial.println(msg); // Display message content } }

other:

I can successfully transmit this code to 'arduino uno r3'

DocBohn commented 10 months ago

An easy suggestion is to try upgrading to the latest Arduino IDE (the current version is 2.2.1). I don't recommend pinning your hopes on that solving the problem, though.

It seems that some Nano clones use the ATmega328PB microcontroller instead of the ATmega328P. The discussion toward the end of this thread includes some links to deal with that problem.