This is an old revision of the document!
Table of Contents
Paper-Duino-Hat
This is the latest version of the Paper-Duino-Pi. It is an Arduino Hat for the Raspberry Pi.
It has an Reset-Button (GPIO 22) and a GPIO LED (GPIO 27) on the board. The Serial connection is made over the serial GPIO pins, plus GPIO 18 for the Reset.
It works on the Raspberry Pi B+, 2 and 3.
Installing the Arduino IDE
based on the code from: https://github.com/mharizanov/avrdude-rpi
Before starting make an update:
$ sudo apt-get update $ sudo apt-get upgrade
Install the Arduino IDE:
$ sudo apt-get install arduino
In:
$ sudo raspi-config
Enable “shell and kernel messages on the serial connection” in Advanced Options/Serial.
Make a new folder:
$ mkdir paper-duino-pi $ cd paper-duino-pi
Download and unpack the files:
$ wget http://dernulleffekt.de/programme/paperduinopi_v05/paper-duino-pi_Pi2_Jessy.tar.gz $ tar -xvf paper-duino-pi_Pi2_Jessy.tar.gz
Run the setup:
$ sudo chmod 755 setup $ sudo ./setup
Test the Serial connection:
$ ls -lh /dev
It should look like that:
crw-rw-rw- 1 root dialout 204, 64 Jul 10 20:24 ttyAMA0 lrwxrwxrwx 1 root root 7 Jul 10 20:08 ttyS0 -> ttyAMA0
Start the arduino IDE.
$ arduino
Upload your code with Arduino-Uno on the port: ttyS0.
Install the Shutdown Button and the LED
Go to your Paper-Duino-Pi folder
$ cd /home/pi/paper-duino-pi
Download and unzip the Python script, one for the button:
$ wget http://www.dernulleffekt.de/programme/shutdownbutton_02.py.tar $ tar xf shutdownbutton.py.tar.gz
And one for the LED:
$ wget http://www.dernulleffekt.de/programme/blink_22.py.tar.gz $ tar xf blink_22.py.tar.gz
Change owner & rights
$ sudo chown root:root shutdownbutton_02.py $ sudo chown root:root blink_22.py $ sudo chmod 755 shutdownbutton_02.py $ sudo chmod 755 blink_22.py
Create the autostart:
$ sudo nano /etc/rc.local
Write before “exit 0”:
# run reset and shutdown script printf "Starting shutdown aund reset button on GPIO 27\n" /home/pi/paper-duino-pi/shutdownbutton_02.py & # blink an LED printf "Starting blinking LED on GPIO 27\n" /home/pi/paper-duino-pi/blink_27.py &
To save and leave press: CTRL+O, Enter, CTRL+X
Reboot:
$ sudo reboot
Burning the Boatloader
To burn the Boatloader on the Atmega328p chip on has to wire up the Raspberry Pi and the Paper-Duino-Pi like that:
Raspberry Pi | Arduino ====================================== MOSI (GPIO 10) | MOSI (pin 11) MISO (GPIO 9) | MISO (pin 12) SCLK (GPIO 11) | SCK (pin 13) RST (GPIO 25) | Reset GND | GND 3.3V | 3,3V
Run on the following commands:
Run the configuration menue:
$ sudo raspi-config
Enable SPI in Advanced Options/SPI, if necessary reboot the Pi.
Now there should be an SPI device in /dev: spidev0.0 and/or spidev0.1.
$ ls /dev
Go to:
$ cd /usr/share/arduino/hardware/arduino/bootloaders/optiboot
Erase the chip (some chips need that):
$ sudo avrdude -p m328p -c linuxspi -P /dev/spidev0.0 -e -F
Burn the Bootloader:
$ sudo avrdude -p m328p -c linuxspi -P /dev/spidev0.0 -U flash:w:optiboot_atmega328.hex:i