















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to the ArduPi library, which allows Raspberry Pi users to write programs as if they were using an Arduino. The library includes conversion functions for serial port communications, I2C and SPI protocols, and GPIO pin control. The document also covers the connection bridge, its drawbacks, and how to install and use the library.
Typology: Exams
Uploaded on 05/23/2020
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Introduction
ArduPi is a C++ library that lets you write programs for
Raspberry Pi as if you were writing an arduino program.
The library provides several conversion functions which
allows to use Raspberry Pi with the same code used in
Arduino:
Serial Port Communications
I2C Protocol
SPI Protocol
GPIO pin control
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Connection Bridge
The idea behind the Raspberry Pi to Arduino shields
connection bridge is to allow to use any of the shields, boards
and modules designed for Arduino in Raspberry Pi.
The connection bridge is developed by
www.cooking-hacks.com
It includes also the possibility of connecting digital and
analog sensors, using the same pinout of Arduino but with
the power and capabilities of Raspberry.
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Drawback
The ArduPi library was prepared for a Connection Bridge which
allows Arduino Shields to be used directly with Raspberry Pi.
Problem?
The Connection Bridge is not available with the Raspberry Pi
Raspberry Pi does not have ADC pins (needs extra interfacing)
The GPIO numbering is according to Connection Bridge
Solution?
Prepare a PinMap according to the Connection Bridge
Enjoy the library without using Analog Commands.
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Conversion Pin Map
Arduino Pin RasPi Pin
0 10
1 8
2 12
3 16
4 18
5 22
6 7
7 11
Arduino Pin RasPi Pin
8 13
9 15
10 24
11 19
12 21
13 23
SCL 5
SDA 3
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
How to Install Library Files?
Once Raspbian is installed, download and install arduPi library in a
new folder.
Ex: “home/pi/ardupi”
Once downloaded, the library needs to be compiled.
Download Links:
For Raspberry Pi
For Raspberry Pi 2
Installation Steps:
§ unzip raspberrypi2.zip
§ cd raspberrypi_2.
§ chmod +x compile_rpi
§ ./compile_rpi
§ cd ..
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Template Code
Arduino Code
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Steps to Enable UART port
By default Raspberry Pi uses UART as serial console. If we
want it for Serial Communication, we need to change this
default configuration.
Steps:
Raspberry Pi through SSH.
$ sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
$ sudo nano /boot/cmdline.txt
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Steps to Enable UART port,
SPI and I2C
$ sudo reboot
To enable SPI and I2C following these steps:
$ sudo raspi-config
“Ok” to all.
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Compile the Program
Once the code is prepared using the arduPi_template.cpp
It needs to be compiled in-order to execute it.
First copy the arduPi_template.cpp as test.cpp
Then compile the test.cpp file as:
$ g++ -lrt -lpthread test.cpp arduPi.o -o test
Note:
Accessing GPIO
Demonstration #
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Code
Accessing Serial Port
Demonstration #
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
15 December 2016
Prof. Jignesh Patoliya (CHARUSAT)
Code