From Projects -
Jump to: navigation, search


Warning: if you make a mistake in using this device, it can kill your Raspberry Pi, like anything you connect to it. Be careful especially with 5V lines, because they are good at killing (parts of) the Pi. I hereby disclaim myself from any trouble you may have, either from mistakes made by you and mistakes made by me.

Also be careful about selecting the correct GPIO. The exposed GPIO number has changed sometimes. Furthermore, the pin configuration also has changed... Mine works for model B revision 2, AFAIK.


When looking for a way to extend the capabilities of the Raspberry Pi for use in my Coffee Machine v2, I was thinking: if the Raspberry Pi has SPI, and many Atmel Microcontrollers have, why can't I use that for programming and communication? This way I would be able to upgrade the firmware of my coffee machine entirely from remote. Looking around on the internet, I found a few attempts of either programming, or communication, but not in an integrated solution. I did integrate things, and thought it would be useful for others who wanted the same. Shamelessly stealing the name of the popular GertBoard, I decided to call mine, the RonaldBoard.


The aim of this project is:

  • To be able to have a very basic expansion board for the Pi to do stuff the Pi isn't that good at itself (strict PWM, ADC)
  • ...and that is updateable by the Pi itself without physical intervention (e.g. pressing buttons)
  • For me to learn stuff about SPI/I2C
  • To (finally) give something back to the open source community...


I'm a bit of a nostalgist sometimes. When I am cooking, I want to use plain and simple ingredients, of which I can understand their origins. When doing embedded stuff, I want things as plain and simple as possible, using elementary components. I don't like prefab boards when I know I do it simpler, having more 'connection' with the bare metal stuff. That's why I don't like the Arduino when I can use a bare ATtiny or Atmega with plain C (but hey, that's just my weird view on things ;-)). Okay, I do like the Raspberry Pi - because an embedded computer of this power cannot be made by myself. (if only they would not have banned the efforts for making a fair trade version...)

Anyway, the design is: an ATtiny45 (or for that matter ATTiny2313, or any I2C capable AVR), a capacitor and a resistor. For demonstration purposes two LEDs are added - of which only one is used in the example code. An old floppy cable connector is used for the connection. That's it. And here's the schematic:


Note! While the pin numbering is okay, the GPIO numbering is wrong! Check [1] for correct info

  • The /RESET pin is connected to pin 22 of the GPIO-header
  • PB0 doubles as SDA (I2C communication) and MOSI (ISP) pin
  • PB1 is connected to MOSI, and can be used with care to drive something else when not in programming mode (an LED in this example)
  • PB2 doubles as SCL (I2C communication) and SCK (ISP) pin
  • PB3 is connected to an LED

Note that because PB1 used by the Pi when programming the ATTiny, it probably shouldn't be used to e.g. drive a Servo using PWM.

Set up

Be sure you have the following:

  • Raspberry Pi connected to the RonaldBoard
  • The pigpio library installed
  • avrdude (patched version)
  • /etc/avrdude.conf configured with the pgio programmer on the correct pins:

  id    = "gpio2";
  desc  = "Use sysfs interface to bitbang GPIO lines";
  type  = gpio;
  reset = 25;
  sck = 3;
  mosi = 2;
  miso  = 9;


Before the first run after boot, be sure pigpiod is running and you have the i2c module loaded. I made the following script:

sudo ./modprobes

After all is set up, flash the RonaldBoard:

sudo make fuse
sudo make flash

The Makefile makes sure the GPIO's for I2C communication are set to read again, using pigs-commands.

Then test it:


You should see something like this in your terminal window:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- 26 -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
test in getting the value of register 0x42:
testing ADC read:
testing PWM.

Furthermore, the LED should turn off and then shine brighter and brighter.

Used work

Eagle libs for the ATTiny & Pi (both modified afterwards in Inkscape, but very useful for the basic symbol):



And now of course, the source: