Upload Arduino sketch to Atmega328

From lechacal
Jump to navigation Jump to search


This is a guide to upgrade a sketch on atmel atmega328 chip.

Involved product are RPICT8, RPICT7V1, RPCT4V3.


Required hardware is the Nanoprog.

The board hosting the Atmega328 chip will have an ISP connector (In System Programmer). This is a 6 pin connector as 3x2.

Required software is the Arduino IDE.

Download the desired sketch to upload. Each product page will have a link to the latest sketch.



Connect the Nanoprog to the circuit board to program using the 6 pin ribbon cable.



This might be optional if you are uploading to a minor version change (e.g. 2.5.4. to 2.5.5). For major version upgrade the eeprom will most certainly need to be erased before uploading.

Get the eeprom erase sketch. eeprom_erase_v1_0.ino

Open this sketch with the Arduino IDE.

Then select Sketch | Upload Using Programmer.

Let the sketch being uploaded. Once the upload completed the eeprom will be erased.


Open the new sketch to upload with the Arduino IDE. Then select Sketch | Upload Using Programmer.


Disconnect the circuit board from the Nanoprog. The configuration will be blank and need to be uploaded again.

Get the default configuration from the configuration guide. At time of writing the latest is this following page here. Over_Serial_Configuration_-_Sketch_2.8#Restore_Default_Config.

Use the lcl-rpict-config.py tool to upload the new configuration.


Test the new sketch using the linux cat command. Stop all program using the serial port (emonhub, gateways etc...)

Run these two commands below. The data will be displayed. Stop the cat command with a Ctrl ^C.

stty -echo -F /dev/ttyAMA0 raw speed 38400
cat /dev/ttyAMA0


Getting the uploaded sketch version in use

Run the cat command as explained above. Remove the board from Raspberripy and re-insert it again. The first line coming out of the cat command will show the current version.