2 months ago

Arduino and Raspberry Pi: using a microcontroller in your projects

If you want your next project to break beyond the limits of code and screens, you might want to consider adding an Arduino board to your Raspberry Pi. These simple, cheap controllers come in all shapes and sizes and allow you to easily measure, monitor, and manipulate the physical world.

Arduinos are microcontrollers that make physical computing projects quick and easy to build. Whether you’re flashing LEDs, activating motors, or sensing changes in the real world, an Arduino is worth considering as part of your project.

In issue 61 of The MagPi, we take you through the first steps of using an Arduino, and provide examples of fun and useful projects to make. Whether you’re building a weather station, constructing a robot, making an alarm for your bedroom, or planning an automatic watering system for the greenhouse, Arduino and Raspberry Pi make a powerful tag team.

This article first appeared in The MagPi 61. Click here to download your free copy.

Looking at the Arduino Uno

The Arduino Uno looks like a smaller Raspberry Pi board, but works differently. While the Raspberry Pi is a versatile computer, the Arduino board is a highly focused microcontroller.

Arduino Uno

Digital I/O

The Arduino has 14 digital input/output pins (female header) of which six can be used as PWM (pulse-width modulation) outputs to control devices such as servos, RGB light levels, and other devices that need precision.

Microcontroller chip

An ATmega328P microcontroller is used to control the hardware on the Arduino board. It is programmed using the Arduino IDE (accessed via the Raspberry Pi).

Reset Button

On one corner of the Arduino board sits a reset button. When you reset an Arduino it reboots and immediately starts running the same program.

Analogue Inputs

On the lower half of the Arduino Uno are six analogue input pins (female header). These can be used to read information from devices such as potentiometers and photoresistors.

USB Type B

The larger USB Type B connector on the Arduino is used to draw power, and provides a connection between the Raspberry Pi and Arduino. Programs are created on the Raspberry Pi using the Arduino IDE and uploaded via USB to the Arduino board.

Quartz Crystal

A 16MHz quartz crystal chip is included on the board. This helps the Arduino control devices with precision.

  • Jeffery Howard

    Wow I wonder if I could try this on a build I might be doing before to long

  • Gary Yohe

    I’ve had a Raspberry Pi connected to a Arduino Nano on an I2C network with some other I2C sensors for a year. Have yet to get anything to communicate. Wish there was a really simple package of Arduino & Python shareware code to test the connection with one word to read and to write back and forth. None of the open source stuff seems to work for me. Have a good instruction on setting up the Raspberry Pi system for I2C tho.

  • Anders Jackson

    And they can be programmed from/in a Raspberry Pi connected to it.

  • Anders Jackson

    What do you want to do?
    Serial communication works fine. Do you want to talk with the Arduino from RPi with some other protocol, like I²C?

  • Gary Yohe

    Looking to setup a Raspberry Pi as I2C master, with a I2C barometer sensor, 3 axis accelerometer, PixyCam, 2X24 LED display, and an Arduino nano network on the same I2C network to cookbook the I2C mapping and setup, and as a demo & teaching tool at a Raspberry Jam. Can read the device drop numbers on the I2C, but not able to get data back and forth.