Tutorial 38: Use an Arduino as a Slave with Python (Nanpy)

I wanted to use an Arduino as a slave with my Raspberry Pi for a project I was working on. The Arduino provides great digital and PWM outputs and has a built in analog-digital-converter allowing me to measure analog sensors. Although there are work-arounds using other ICs, the Arduino was a clean solution for me.

Interfacing the Raspberry Pi and Arduino for a custom solution can be quite a bit of work and requires you to know how to program in C++, the language of the Arduino. Fortunately I found Nanpy, a program solution made by Andrea Stagi that allows you to communicate with the Arduino using just Python scripts. A great tool for a beginner!

How to install and use the software can be a little challenging, so I thought it would be good to put together a tutorial on how to use it! Enjoy!

What you need…


  • Raspberry Pi
  • 5V DC Micro USB Power Supply
  • Arduino Uno
  • USB A-B Cable
  • LED
  • Push Button
  • 10,000 ohm Resistor
  • 220 – 1,000 ohm Resistor
  • Breadboard
  • Breadboard compatible Wires
Difficulty
MODERATE
Raspberry Pi Experience
SOME
PYTHON PROGRAMMING
MODERATE
About
0
Minutes

You will also have to download packages from:
https://github.com/nanpy/nanpy

https://github.com/nanpy/nanpy-firmware