Page 1 of 1

Wrong data from Arduino

Posted: Tue Apr 03, 2018 6:52 am
by freddus
Hello.

I'am working on a project where i'am to recieve data from a arduino mega to my raspberry pi 3 using Uart.

I have established a working link between the two devices. However, the data received from the arduino is just garbage, when i'am printing the data on my terminal it just gives me all sort of wierd signs.

The TTL levels for both devices should be right.

The code i'am using to receive the data is very simple.

Code: Select all

import time
import serial
ser=serial.Serial(
port='//dev/ttyAMA0',
baudrate=9600,
timeout=1
)

while 1:
	if ser.in_waiting>0:
             x=ser.readline()
             print x



On the arduino side i'am using Serial.print('....')

I should add that i'am a beginner, if that wasn't obvious. So everything you got might help.

Re: Wrong data from Arduino

Posted: Tue Apr 03, 2018 9:02 am
by scotty101
The two common problems are; Incorrect baud rate selected at either end, no ground connection between devices.

Check both of those and report back.

Re: Wrong data from Arduino

Posted: Tue Apr 03, 2018 9:28 am
by B.Goode
The TTL levels for both devices should be right.
Maybe you think they should, but have you checked that they are?

Does the Arduino have a ttl-level serial interface, or might it be rs232, which uses different signal levels?

Re: Wrong data from Arduino

Posted: Tue Apr 03, 2018 11:16 am
by davidcoton
B.Goode wrote:
Tue Apr 03, 2018 9:28 am
The TTL levels for both devices should be right.
Maybe you think they should, but have you checked that they are?

Does the Arduino have a ttl-level serial interface, or might it be rs232, which uses different signal levels?
Further to that, the Pi uart on the GPIO connector is actually not TTL levels, it is 3V3. You need extra hardware to convert that unless your Arduino is also 3V3. You can damage your Pi if you connect TTL (5V) or RS232 signals directly.

Re: Wrong data from Arduino

Posted: Tue Apr 03, 2018 11:22 am
by SurferTim
I use usb for my mega to RPi interface. Mine shows up as /dev/ttyACM0.

Re: Wrong data from Arduino

Posted: Tue Apr 03, 2018 11:55 am
by freddus
Hello.

I have solved my problem now. Thanks for the replies.

kind regards Freddus

Re: Wrong data from Arduino

Posted: Tue Apr 03, 2018 11:59 am
by B.Goode
freddus wrote:
Tue Apr 03, 2018 11:55 am
Hello.

I have solved my problem now. Thanks for the replies.

kind regards Freddus
For benefit of other forum readers who may encounter the same issue in the future it would be a nice gesture to say briefly what you found the problem to be and how you resolved it...