serial communication issue

Dear forum members. Please help me. I googled a lot, and here my last opportunity.

At my arduino due there are 3 rx/tx group of pins for serial communication. When I'm using Serial read and write in IDE, I have no issue with sending data through the cable connected to usb programmable port.

But when trying to send data to raspberry connected with it's rx to arduino tx and vice versa, of cause having common ground, I cannot read anything from raspberry.

In my mouse sensor project http://forum.arduino.cc/index.php?topic=284799.0 I finished with i2c communication between arduino and rpi.

I'm curious, how to send/read data from rx1/tx1 rx2/tx2. Different pins should be differentiated somehow in the code.

I'm newbie with all this stuff, but have grand plans in mind. So sorry for stupid question.

Solved. However, when I'm reading serial from python raspberry and sending "hello" sent to serial from arduino, sometimes some symbols are lost, like "ello" or "He lo" Is anybody knows what is wrong? Thanks

Hi
Could be noise disrupting the data transfer either at the tx or rx side or maybe cable/quality/length etc etc.

Essef :8)

Check to make sure you have the same communication parameters for both Arduino and RPi, same baud, same stop bits so on.

Make sure you are using same voltage levels, is your Arduino 5V and your RPi 3v3?

Like Essef says, check the cable between the Arduino and RPi, how long is it, you give no details at all.

Check you have a common ground connection between your RPi and Arduino with your power supply? Check the quality of your power supplies to both boards.

If all that is good, then you need to look at your code and see that you are writing good code, of which we can not tell, as again you do not give details.

Why do people not give all the details when asking questions, I never can understand.


Paul

Thanks Paul & Essef. I'm using arduino due, so both devices have 3.3 V level. The wires are about 20 cm. The power supply to arduino is from PC usb. To RPi separate power supply from DC converter.

The code for arduino is extremily simple:

void setup() { Serial3.begin(9600);

}

void loop() { Serial3.println("Hello");

}

Python

import serial ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)

while 1 : print ser.readline()

I've added delay(200) after sending Serial3.println("Hello") and all issues are gone. It is correct solution?

Yes, putting a small delay in your Arduino main loop(..) should have your program working better.

As you develop your program, try not to use any delays with the delay(x) command, rather, look at checking for elapsed time and trigger functions after preset time. Your code will then be much more manageable as it grows.

Good luck.


Paul

Thanks, Paul!