Install Arduino on Raspberry Pi  Step by Step Guide ▷ 2021

While it is about two different platforms, the truth is that both technologies They are excellent options to develop any DIY project. Is that these devices share many positive aspects, they are of low cost and easy to program.

But it doesn’t make sense to always place them on opposite paths. This is because they can be used together, which optimizes the operation of both, using the best aspects of each.

Although the Arduino and Raspberry boards are quite simple to use with some experience, using them together requires a guide like the one we will offer you below.

What are the benefits of combining Arduino and Raspberry Pi?

What are the benefits of combining Arduino and Raspberry Pi?

The benefits of combining Arduino with Raspberry Pi are several. It is only necessary to name the positive aspects of each of them, since they do not counteract each other.

Which we show you below:

  • The two cards share portability of its dimensions. In other words, they are much smaller and lighter than any laptop.
  • If only Arduino has open hardware, both projects have open source software to control the plates.
  • From the combination of both we can obtain a greater computing power, offered by the microcomputers of Raspberry, with a great versatility of uses such as microcontrollers of Arduino.
  • Using both platforms together, it is possible to do without a laptop or desktop. This is because current Raspberry boards have sufficient connections for peripherals such as keyboards and monitors. In addition to the possibility of connecting to a WiFi network in an integrated way.
  • Another advantage of using both plates in a complementary way is the amount of tools available in terms of programming codes. This is due to the great support and community members who use them together. Added to this is the number of accessories and projects already created to practice and imagine your own ideas.
  • For its part, Arduino boards provide better and more varied use of sensors and chips. But above all, if you are just starting in the world of programming, Arduino IDE is a great first step, as it is easier to use than Linux.

Learn step by step how to install Arduino on a Raspberry Pi from scratch

Learn step by step how to install Arduino on a Raspberry Pi from scratch

The main items you will need to start installing Arduino IDE in a raspberry board are just these. But it is also necessary to have a USB data cable and one Internet connection. You must bear in mind that the latter can be replaced with the Arduino driver installer downloaded to an external storage device.

The necessary software is found on the official Arduino page, so you will have to do this step by step:

  • Open your browser and type in the URL address bar Then find the download option for Linux operating systems version processor-based 32-bit ARM.
  • Once the programming environment has been downloaded, you will have to connect both boards through the USB cable and do the same with the power supplies.
  • Then, already from the Raspberry interface you unzip the file into a new folder.
  • You run the file in the terminal “”.

In the case of using a remote connection to Raspberry, generally if you don’t have a dedicated monitor, you need to connect the board via the SSH terminal or with VNC Viewer.

Either way, you run the following commands to update the list of programs in the repository:

  • sudo apt-get update
  • sudo apt-get upgrade

Next, install Arduino through the command and wait for the process to finish, for this, you will have to write:

  • sudo apt-get install arduino arduino-core

Once done, you can find the software through the menu “Programming”. It’s time to check if the installation of both software and hardware they were correct.

To do this you will use the command:

If yes, you should get the answer:

It only remains to check the operation of both panels with any project available on the network, for example, you can use these programming codes for an Internet access point:

-apt-get install lshw

lshw -C network


Supported interface modes:







mesh point

apt-get install hostapd

iface wlan0 inet static




# First we configure the interface we'll be listening on

interface=wlan0 # The interface to listen on


# The driver that is being used by the WiFi adapter, this could be different for everyone


ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon runs.

# Now onto the important WiFi configuration


# First up, the SSID or Network name. This is what other devices will see when they try to connect.


# I'm setting this to Wireless G mode. A, B, and G are available here.


# This is setting the channel that the WiFi is on, valid channels are from 1-11, or 1-14 depending on location.

# Wifi Security Settings

wpa=2 # This sets the security settings to WPA2


# The line above sets the wpa passphrase to "raspiwlan", this is obtained via the wpa_passphrase command.

# However, you can also set a passphrase like the line below.





# I've set these to WPA-PSK to indicate that we are using a Pre-Shared Key with CCMP encryption.

# Otherwise, hostapd also has a built in RADIUS server that we can use for authentcation

# But I'll leave that to another post.

# Other settings

beacon_int=100 # This sets how often the WiFi will send a beacon out.



List of the best projects with Arduino and Raspberry Pi that you should know

With these projects you will achieve independence from a computer and you will take portability to another level, let’s see some of the projects you can work on:


It is an open source software that is mainly used to control 3D printers. Incidentally, most of them are built or based on Arduino boards. However, the higher-cost commercial machines have tools like remote control and wireless connection that the most basic ones don’t. That is why adding a Raspberry Pi board to the control system is one of the most used projects by makers.

This allows manage prints wirelessly via web. In addition to this, it is possible to control a printer farm (several machines in one place) from a single computer. Raspberry offers the possibility of connect webcams that monitor manufacturing line work. You can find the codes and all the necessary additional information on the official OctoPrint site.

Surveillance camera with motion sensor

Home security systems are often very expensive to purchase. We must add to this the monthly maintenance expenses. But thanks to Arduino and Raspberry it is possible to create your own low cost circuit.

We have seen that it is possible connect a webcam to a Raspberry board. Also that there are additional adapters to use several of them at the same time. But this is very basic. What happens if you add an element that will enhance the safety circuit even more? For example, motion sensors connected to an Arduino. This way you can tell a specific camera to activate when it detects movement in a certain place. In turn, it sends an alert signal to your mobile when you are not at home.

Look at these codes that you can practice:

rom picamera import PiCamera

import time

import cv2

# Inicializamos la cámara con resolución 640x480

camera = PiCamera()

resolution = (640, 480)

framerate = 32

rawCapture = PiRGBArray(camera, size=(640, 480))

# Tiempo de espera para que la cámara arranque


# Inicializamos el primer frame a vacío.

# Nos servirá para obtener el fondo

fondo = None

# Capturamos frame a frame de la cámara

for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):

# Obtenemos el array en formato NumPy

image = frame.array

# Convertimos a escala de grises

gris = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Aplicamos suavizado para eliminar ruido

gris = cv2.GaussianBlur(gris, (21, 21), 0)

# Si todavía no hemos obtenido el fondo, lo obtenemos

# Será el primer frame que obtengamos

if fondo is None:

fondo = gris

# Calculo de la diferencia entre el fondo y el frame actual

resta = cv2.absdiff(fondo, gris)

# Aplicamos un umbral

umbral = cv2.threshold(resta, 25, 255, cv2.THRESH_BINARY)[1]

# Dilatamos el umbral para tapar agujeros

umbral = cv2.dilate(umbral, None, iterations=2)

# Copiamos el umbral para detectar los contornos

contornosimg = umbral.copy()

# Buscamos contorno en la imagen

contornos, hierarchy = cv2.findContours(contornosimg,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

# Recorremos todos los contornos encontrados

for c in contornos:

# Eliminamos los contornos más pequeños

if cv2.contourArea(c) < 500:


# Obtenemos el bounds del contorno, el rectángulo mayor que engloba al contorno

(x, y, w, h) = cv2.boundingRect(c)

# Dibujamos el rectángulo del bounds

rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)

# Mostramos las diferentes capturas

imshow("Imagen Movimiento", image)

imshow("Umbral", umbral)

imshow("Resta", resta)

imshow("Contornos", contornosimg)

key = cv2.waitKey(1) & 0xFF

# Reseteamos el archivo raw para la siguiente captura


# Con la letra s salimos de la aplicación

if key == ord("s"):


Jostick Arduino to play on Raspberry Pi via Scratch

Is about a very playful way to practice your programming and put it to the test, especially if you are interested in video games. Thanks to Scratch which is a programming language designed for the development of skills in this aspect in children and adolescents who are just starting out.

Via a more didactic and visual interface, it’s possible create simple codes and even complete games. Using Raspberry Pi as the physical platform where the game will run, connected to an Arduino-based joystick. Due to the low cost of accessories such as modules, it is a great alternative to start in this world.

Write these codes:

f#include <Joystick.h>


Joystick_ joystick;

void setup() {




// Para usar el joystick, pines analógicos del eje X y el Y del Joystick y mediante Joystick.h

void loop() {

joystickDerX = analogRead(A0);

joystick setRxAxis(joystickDerX);

joystickDerY = analogRead(A1);

joystick setRyAxis(joystickDerY);


for(int i = 2; i<=botones; i++) {

if(digitalRead(i) == LOW) {



else {





If you have any questions, leave them in the comments, we will answer you as soon as possible, and it will also be of great help to more members of the community. Thanks! 😉

Felix Bathrobe

Author: Félix Albornoz

I have been working in the technology sector for more than 20 years helping companies and users to develop and train in this field. Always learning new things.

You may be interested:

Rate this post

Leave a Comment