Identifying the Atmel device in Arduino Nano compatible board
I bought some Arduino Nano compatible boards from a Chinese supplier and these were tested and installed with blinking LED code. However, I could not immediately connect them up to the Arduino IDE software.
The first problem to spot was that the serial communication chip is different from the original Nano. It uses a CH340 which Windows 10 was happily able to detect and install a suitable driver.
In Windows Device Manager on my computer, USB-SERIAL CH340 (COM4) shows up under Ports.
Now this port may be selected in the Tools menu of the Arduino IDE. And after selecting the Board as an Arduino Nano I tried to Upload a Sketch. But it failed to load with an error saying that the wrong device signature was received. This means that an unexpected device is connected.
So we need to use the AVRDude utility from the command line. I could not read the markings on the microcontroller chip and did not have a Data Sheet for the board so I needed to firstly identify the device.
To talk to the device we need to use an In-system Programmer which connects to the ISP interface. This directly connects to pins of the microcontroller.
I didn’t have one, so made one using an Arduino Uno board and the Open Source ArduinoISP sketch.
The AVRDude utility is found in the
arduino\hardware\tools\avr\bin folder. I added this path to the Windows Environment system PATH variable and rebooted my computer.
Since AVRDude takes many parameters I decided to create batch files to store commands such as for programming the Boot Loader. But first let’s discover what device we are using.
Here is a command to probe the device:
avrdude -p m168 -c avrisp -P com4 -v -C etc/avrdude.conf -b 19200
I ran this from the avr folder so that the configuration file is found.
The device should respond with a report of its device signature which identifies the type of device. In my case the value was 0x1e940b which corresponds to the ATMEGA168PA Since this appeared to be compatible with the supported ATMEGA168 I decided to go ahead and program in the Arduino Nano Boot Loader for the ATMEGA168 (ATmegaBOOT_168_diecimila.hex).
Here is the command line that I saved into a .bat file:
avrdude -p m168p -c avrisp -P com4 -v -C etc/avrdude.conf -b 19200 -U flash:w:C:\arduino\arduino-1.6.11\hardware\arduino\avr\bootloaders\atmega\ATmegaBOOT_168_diecimila.hex:i
After programming the chip with the Boot Loader the device responded with a new ID matching the ATMEGA168 (0x1e9406) which is supported by the Arduino IDE.
Now sketches could be uploaded to the Nano from the IDE.