Raspberry Pi Tutorial 38 - Use an Arduino as a Slave with Python (Nanpy)

preview_player
Показать описание
Arduinos are great. The Raspberry Pi is pretty cool too. Together, they're spectacular. However writing separate codes in different languages to have the two units works together is a bit of a hassle. In this tutorial I show you how to stream commands from the Raspberry Pi to the Arduino using UART serial communication. The package is Nanpy, allowing you to run Arduino commands in a Python script.

Download links:
Рекомендации по теме
Комментарии
Автор

Thanks a lot for this video ! Detailed explanations along with visual support, well done.

I've actually been trying to do serial communication between my arduinos and raspberry pis for days now and this is a lifesaver !

maximemanseau
Автор

Sorry I didn't watch the video long enough to get my answer... This can totally be used in a bi-directional manner, can't it!?? This is going to be great! My Pi ports are tied up because the Pi is using a python driven touchscreen GUI, the physical buttons I want to add have some of the same functions that are built into the GUI. This looks like the perfect solution to have the physical world connected into the GUI. I have subscribed, awesome work!

joshuanulton
Автор

Raspberry Pi and Arduino should team up and create Raspuino!

Aerox
Автор

I did enjoy this. thank you for taking the time doing it

YveDev
Автор

For anyone who has the problem with nanpy-firware when the Arduino is not excepting it"ignoring bad library name". I fixed it by removing the dash("-") from the nanpy-firmware because arduino forbits them.Simply go into the sketchbook directory and rename the nanpy-firmware library. That worked for me

wavyrenac
Автор

Thank you for the tutorial!

Could you show how to controll a servo instead of a button?
I would really appreciate that. :)

chrxs_
Автор

This is fantastic!
Might just be what i need for a project i am doing.
I plan on controlling two Servos using Hardware PWM and i was thinking to use an Arduino Nano to do that for me, as the Pi only has one Hardware PWM capable pin.

This might be the way to go.

Thanks for sharing!

evil_in_your_closet
Автор

Using python 2. It throws the exception " 'a' is not defined" not really sure what is going on. Is it the try statement? Shouldn't it be " try: except: finally: " ?

seanlovesjobo
Автор

İt fails to connect
I am using a Raspberry pi 3 b

GoldenHat
Автор

How can i communicate with 2 or more arduino... how can i define the com port for the arduino... and can i do this by using etherne port/ cable??

shakyaikesh
Автор

This is a great intro. Just getting into this, wanting to control stepper or DC motors, need Arduino to provide more capable IO pins, and analog voltages.

jerrygrimes
Автор

Hi in the section cp -avr nanpy-firmware/ ~/sketchbook/libraries I'm getting a cannot create directory /home/pi/sketchbook/libraries no such file or directory could you tell me where I have gone wrong thanks

Tuftyonthetube
Автор

Thank you so much. It worked perfectly for me!

kevinvanrensburg
Автор

Thank you Alexander Baran-Harper
It is very useful video and very clear to flow,
thank you very much

ibrahimammar
Автор

when i open ide says( The Library "nanpy-firmware" cannot be used. Library names must contain only basic letters and numbers. (ASCII only and no spaces, and it cannot start with a number)


why this is happening, double copys on the libraries folder??? i continue and check that i have the nanpy on the sketchbook - libraries-nanpy i try to upload it and says that serial port Com 1 not found

TheMdbProductions
Автор

What about the Hardware connections..?

How is the arduino connected to the Pi, normally plugged in to the USB of the Pi or the serial pins(Tx, Rx) of the arduino are hooked up to the Pi's Tx, Rx?

abhishekchopade
Автор

Hi Alexander! I just wanted to say I've thoroughly enjoyed your guides - especially you one on the MCP3008 ADC which I've used to build a heliostat that tracks the sun's position by monitoring voltages on differently orientated mini PV panels (I switched relays using logic-level mosfets rather than BJTs - I'm not an elec eng so I found sizing them easier based off of Vgd vs. Rsd curves as I could only source rather beefy 12V relays, maybe other people will too? Approximate Beta values for the BJTs at different currents added ambiguity I wasnt very comfortable with, I found the mosfets far more sensible from a first iteration design point of view).

Maybe for future projects you could do something more geeky/esoteric like using a Pi as a mobile wifi NAS, a mobile https over wifi based text/binary encryption/decryption mechanism or a car dashcam?

Keep it up! Can't wait for the next videos!

agentrfr
Автор

I have a raspberry pi, but can i use PC/laptop VGA I²C DDC port to do this? I want to connect arduino with PC directly without rs232, using the computer's I²C bus

putraadriansyah
Автор

Hi Alex, great video! Just one question, would nanpy work with windows at all? or does it only work with linux and raspberry pi?

SirJackyMan
Автор

thx for you tutorial it is very helpful i try it with a.analogRead but it does not work can you help me how read an analog input to raspberry using arduino as ADC

roboticscenter