Blink on Arduino nano

Hi,

I’m completely new to PlatformIO and just try uploading the classic Blink example to my Arduino nano board. The project seems to compile just fine, but cant upload. This code works without any issue in the ArduinoIDE but not under PlatformIO. I’m new and the options are overwhelming, so can you help me out with this?

(I tried to use all the possible nano options in the board selector without any success. Also - and thats just a guess - I thought that when I select a board the platformio.ini file will change but it doesnt. Not sure if this is a problem)

Using VSCode on Windows7.

Thanks.

1 Like

Try (in platformio.ini):

board = nanoatmega328

(instead of nanoatmega328new)

There are Arduino Nano boards out with two different bootloaders and this change uses the other one.

2 Likes

This is it. After changing the platformio.ini it works fine. The question rises though that how should I be able to figure this out on my own? I mean where can I get the knowledge? What if next time I’d like to upload the code an uno? How should I change the .ini file?

thx

image

1 Like

Unless the seller provides the information, you cannot distinguish between the Arduino Nano with the older and the newer bootloader. It’s just a software difference. So nanoatmega328 vs. nanoatmega328new is trial and error. Fortunately, it’s the only board with this problem (at least as far as I know).

If you have an additional board like the Arduino Uno, go to Quick Access / Boards and search for it, i.e. search for uno.

In the result list, click on Arduino and then on the ID to copy the board ID. In this simple case, it’s simply uno.

You can add several board definitions at once to your platformio.ini, eg.:

[env]
platform = atmelavr
framework = arduino

[env:nanoatmega328]
board = nanoatmega328

[env:uno]
board = uno

In the project tasks you will then find tasks for building and/or uploading both boards and tasks for building/uploading just a specific board.

2 Likes

The underlying reason is that the baud rate of the bootloader of older Arduino Nano boards uses 57600 baud while they changed it in never versions to 115200 baud. In older Arduino IDE versions, you only had “ATMega328P” as the chip option for the Arduino Nano which is 57600 baud, but in newer ones they give you “ATMega328P” (now 115200 baud) and “ATMega328P (old bootloader)” (57600 baud). So if you used a recent Arduino IDE version you would have noticed the same error too and would have maybe found this baud rate mismatch issue. But yeah, asking here on the PIO forum gave you a quick answer, too :slight_smile:

References

3 Likes

Thx!
this trick works for my Arduino Nano likes from Banggood!

1 Like