freddus
Posts: 5
Joined: Mon Apr 02, 2018 2:25 pm

Wrong data from Arduino

Tue Apr 03, 2018 6:52 am

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.

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Wrong data from Arduino

Tue Apr 03, 2018 9:02 am

The two common problems are; Incorrect baud rate selected at either end, no ground connection between devices.

Check both of those and report back.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Wrong data from Arduino

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?

User avatar
davidcoton
Posts: 5084
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Wrong data from Arduino

Tue Apr 03, 2018 11:16 am

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.
Signature retired

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Wrong data from Arduino

Tue Apr 03, 2018 11:22 am

I use usb for my mega to RPi interface. Mine shows up as /dev/ttyACM0.

freddus
Posts: 5
Joined: Mon Apr 02, 2018 2:25 pm

Re: Wrong data from Arduino

Tue Apr 03, 2018 11:55 am

Hello.

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

kind regards Freddus

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Wrong data from Arduino

Tue Apr 03, 2018 11:59 am

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...

Return to “Troubleshooting”