Integration between Raspberry Pi and Arduino

Is it possible to do all the things that related with Arduino board on the raspberry-pi instead? Well, the answer is not possible but it can do it, and someone from already done it. They called it “connection board”, pretty interesting board and I have tried it. It was nicely done and run smoothly. All my Arduino’s shield can apply on to it and talk with the raspberry-pi board. Please the find the picture of connection board it self ( the one with black colour ) below.


And here the picture when they both set.


If you can see the connection board ( black colour ) above, it has the same pins location and number with the Arduino’s board. These guys from was did pretty good job. The details information about the board, you can find in this link Inside board has a translation connector from raspberry-pi’s GPIO pins to their “arduino” pins, and they also provide the xbee connector so that we can communicate the raspberry-pi board thru zigbee, bluetooth, or wifi protocol.

Ok, now back to the code. After done with hardware setup, and the pi became like arduino, so how we can run the program on to it? Pretty simple actually, all you have to do is install the arduino package and arduPi library inside the raspberry-pi board.

Screen Shot 2013-03-23 at 8.08.49 AM

My raspberry-pi was run under debian “wheezy” , I just done the installation thru their package, they already provide it, even tough not the latest version, but still be ok.

Screen Shot 2013-03-23 at 8.27.12 AM

After done the package installation, you can see in here that there was java jdk installation involved. It does make sense since the Arduino IDE that we installed was run under java environment, in this case they provide with openjdk version 6. Cool! For the raspbian wheezy distro, we need some tips to enable the UART port, please see below :

1. Make a backup of the /boot/cmdline.txt file.
$ sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
2. Edit /boot/cmdline.txt file:
$ sudo vi /boot/cmdline.txt
This file contains:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 $
Remove the parameters that reference the UART serial port (ttyAMA0):
dwc_otg.lpm_enable=0 console=tty1 $
3. Comment next line in /etc/inittab:
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
4. Reboot Raspberry Pi
$ sudo reboot

We can continue with the arduPi library installation, this library is provided by team. This library will help to support the connection board to run properly. For the installation steps, I will create folder named “arduPi” and download the source tar gz file from with link like below. The last version that I got was arduPi_1-4, and they don’t separate the library based on raspberry-pi board A or B, all into one file, good.

Screen Shot 2013-03-23 at 8.59.08 AM

After I done to extract the source file of arduPi, I will do the compilation of the one, that’s why I need the G++ compiler since they are using C/C++ files, and please find the steps installation below.

Screen Shot 2013-03-23 at 9.16.06 AM

Screen Shot 2013-03-23 at 9.19.29 AM

Now, every things run smoothly. The compiler is ready to perform, and here for testing purpose I will use the example blink.cpp from arduino’s sketches example like below. Please remember, this is not a arduino board so the behaviour slightly different, because it’s run under g++ library and it likes running the code from scratch. We must put the main() function inside the code like below.

[gist /]

To run the program, I will save it as blink.cpp file and compile it with the steps below.

Screen Shot 2013-03-23 at 9.46.20 AM

On the board it self, I put the red led and put into the pin 13 just based on the blink.cpp file coded, and it was run perfectly well. Nice!

2013-03-23 09.45.41