The AVRPi-328 is an Atmel ATmega328p add on board for the Raspberry Pi A+, B+ and 2B. It runs on 3.3V at 8, 12 or 16 MHz (or any other speed you want of course).
All software is easy installable navigating a simple menu. Choose 'install everything in 1 easy step', and 'burn fuses for your board'. That's all it takes to get you started.
The ATmega328p can be programmed in the Arduino IDE, but also using the Arduino library and a Makefile, or straight C or assembly. All software that is used on the Pi and the ATmega328 is open source with the source code provided.
AVRPi boards use the latest avrdude-6.1 with the built-in linuxgpio interface.
The repository with all installation scripts is here: https://github.com/onandoffables/avrpi-tools.
cd git clone https://github.com/onandoffables/avrpi-tools cd avrpi-tools ./setup
- Option 'e' installs everything in 1 easy step.
- Don't forget to set the fuses the first time! (option 'f')
Frequently asked questions
So... this is an Arduino?
No. It's an ATmega328p and ATmega32U4 addon/breakout board. That's the same chip as used on the Arduino Uno or Leonardo so it's perfectly capable of running firmware that's compiled against the Arduino libraries. All boards that have these chips can do this. The AVRPi boards are no exception.
But I can use the Arduino IDE?
Yes. If you really must. It works out of the box, but there's a saying "friends don't let friends use the Arduino IDE". People say that for a reason.
The Arduino library itself is pretty useful though. Try the 'Arduino Makefile' project. It uses the same Arduino source code to compile the libraries, but you can use your favorite text editor and a very simple Makefile. Type 'make ispload' to compile and upload your firmware.
Why not run it full speed on 5V?
Most modern sensors and chips you'll want to attach to the ATmega328 or ATmega32U4 are probably 3.3V. Having everything (including the GPIO pins of the Pi) run on 3.3V will save you a lot of headaches. Some older sensors and chips that still want 5V are sometimes also happy enough with 3.3V. If they don't, you'll only have a headache in those specific situations in stead of having voltage level conversion going on most of the time.
The 'slower' speed is a trade-off for convenience or precision. If you want speed and precision, have look at the ARMinARM board on this website.
I can choose other boards in the software. What's up with that?
All boards for the Raspberry Pi that use Gordon Henderson's 'gpio' avrdude-5.10, can use avrdude-6.1 with the 'linuxgpio' programmer. They use the same pins, so it was trivial to add them to Arduino's 'boards.txt' file.
That means if you have a Gertboard, Gertduino[*], RasPiO duino or you soldered something up yourself you can also use this software setup. Yay for choice!
[*] Gertduino needs extra scripts to handle the reset pin.
Why mention the different speeds (8,12,16 MHz)?
The AVRPi-328 kit comes with a crystal with one of these 3 frequencies. Here are some things to take into consideration when choosing which crystal to solder onto your board.
- 8 MHz: The most Arduino compatible speed while still being safe. Many Arduinos run on 8 MHz, and you will encounter no problems. All Arduino libraries should be compatible.
- 12 MHz: A nice round number that is close to the maximum speed (13.3 MHz) the ATmega328p can safely run on 3.3V, according to the datasheet. You can't use Arduino's "software serial" at 12 MHz, and possibly some specific libraries will yell at you, but for the most part Arduino works fine.
- 16 MHz: Technically overclocking, but fully Arduino compatible. There are many reports that everything still works fine, but you're advised to use this speed for experimentation only. Don't use it in a real project. The USART may skip a beat once in a while, an ADC reading be off by x values, or the EEPROM messes up a write command. Anything can happen. Nobody knows (it's probably fine, but consider yourself warned).
- Other speeds: If you're going to ignore the Arduino library, it may make sense to choose another speed. For example with an 11.0592 MHz crystal, a 0.0% error rate on the USART can be achieved (if that's important to you) while staying within the max speed limit. Or you may choose a speed that gives you the best control over the timers you want to use.
The default fuse setting is to run (without a crystal) off the internal 8MHz oscillater, with ckdiv8 enabled. Without setting the fuses, the AVR will run on 1MHz. You can change that in the setup menu (option 'f: set fuses for your board').