Tuesday, 22 October 2013

Raspberry Pi and Arduino

I am putting together a data logger for the biogas generator.

I would like it networked so I don't have to go out in the cold, so will use a raspberry pi.   To make interfacing the sensors easy I will connect the Pi to an Arduino microcontroller.   This is a bit over the top as I should be able to do everything I need using the Pi's GPIO pins, but Arduino has a lot of libraries to save me programming....

To get it working I installed the following packages using:
apt-get install gcc-avr avr-libc avrdude arduino-core arduino-mk

To test it, copy the Blink.ino sketch from /usr/share/arduino/examples/01.Basics/Blink/ to a user directory.
Then create a Makefile in the same directory that has the following contents:
ARDUINO_DIR  = /usr/share/arduino
TARGET       = Blink
ARDUINO_LIBS =
BOARD_TAG    = uno
ARDUINO_PORT = /dev/ttyACM0
include /usr/share/arduino/Arduino.mk
Then just do 'make' to compile it, then upload to the arduino (in this case a Uno) using:
avrdude -F -V -p ATMEGA328P -c arduino -P/dev/ttyACM0  -U build-cli/Blink.hex
The LED on the Arduino Uno starts to blink - success!

Post a Comment