I want to do an experiment using Rpi and Arduino. Basically Arduino will send a digital data to Rpi's GPIO. This question says how to do it using USB.
I want to read it and display in the console.
As an example, arduino will send 100 as a value and Rpi should read and display 100.
Is this possible to do?? I am new for Rpi field. So please provide me some details. I had looked many web sites for a help before posting here.
Thanks in advance.
1 Answer 1
I am surprised your search did not find any solutions. How do you think computers communicate?
The simplest solution is to use a serial link. For Arduino to Pi connect the Arduino's TX pin to the Pi's RX pin (pin 10, GPIO 15, RXD). For Pi to Arduino connect the Pi's TX pin (pin 8, GPIO 14, TXD) to the Arduino's RX pin.
Note that the Pi's GPIO are 3V3 and typically the Arduino's are 5V. You should not connect a 5V output to a 3V3 input, so use a voltage divider to drop the Arduino 5V to a Pi safe 3V3 in the Arduino to Pi direction.
The Pi to Arduino direction should be fine (3V3 output to a 5V input will not cause damage).
Of course you also need to connect a Pi ground and an Arduino ground.
The software side of transmitting and receiving is widely documented (as an example).
Install serial
sudo apt-get install python-serial
example python code
import serial
port = serial.Serial("/dev/ttyAMA0", baudrate=115200, timeout=3.0)
while True:
port.write("\r\nSay something:")
rcv = port.read(10)
port.write("\r\nYou sent:" + repr(rcv))
Explore related questions
See similar questions with these tags.