Arduino to Rpi communication on Serial

Hi, I have bought an Arduino Expansion Shield for RPi and trying to send data on a serial from Arduino to Rpi. But I am not able to do that. Can you let me know Arduino which serial is connected to RPi serial?

Which particular expansion board do you have?

Inbuilt serial could be /dev/ttyS0, /dev/tty1,…

USB Serial is often /dev/ttyACM0 but I’ve seen /dev/ttyUSB0, /dev/ttyUSB1,…

The board name : Arduino Expansion Shield for Raspberry Pi B+.
I am able to upload code on port /dev/ttyAMA0 from Rpi to arduino. The code I have written is sending serial data. Then I am using Arduino Serial Monitor and cant see any data send to it on both /dev/ttyAMA0 and /dev/ttyS0.

The instructions at DFRobot show it as connecting over /dev/ttyACM0:

One issue might be that you don’t have permission to access the serial /dev/ttyACM0. Type the command below:

groups

At the command prompt and see if your account is in the dialout group. If you don’t see the dialout group run the following command (assuming your account is pi):

sudo usermod -a -G dialout pi

If you follow those instructions and it still doesn’t work please run the following command and post the result up. It will list all of your serial devices:

ls /dev/tty*
1 Like

reply for ls /dev/tty*
image
Arduino Code:


Python Code : Tried for both Port ttyS0 and ttyAMA0
image

I can’t see anything obvious with your setup. It looks OK to me.
I’ll have another look when I’m home from work tonight.

I can’t see anything wrong with the code

The only thing I can think of is that the serial switch is connected to the Xbee adaptor rather than the Pi. Everything I can see on this says the serial should be showing up as ttyACM0 which isn’t in your list of serial devices.

The ttyACM0 is the RPi serial port, not the Arduino.

Unplug the USB between the RPi and the Arduino hat, and then plug it back in again. Run the command

dmesg | tail

to find out what serial port is created. Use that in the python code to talk with the Arduino. This should be the same port you used to upload the program to the Arduino.

2 Likes

Thanks, for the help I found the issue in the USB cable. Its working now.

2 Likes