Incomplete Serial communication between Raspberry and Arduino

Hello Everyone!

I have an issue with serial communication between a Raspberry and an Arduino Uno.

The arduino is connected to a set of sensors and sends various messages to the raspberry depending on many conditions. But the raspberry doesn't always get the message, or sometimes it is truncated and lack some characters.

Sometimes, the raspberry even seem to stop listening completely for serial communication.

These failures occur randomly, and after hours of testing, we have found no direct cause...

Every message is sent correctly by the arduino, because when it's connected to a computer, we can read them all perfectly.

I already use the fastest Baud rate available.

Every message is sent with the Serial.print function, and none with Strings.

Thank you very much for your help :slight_smile: !

Are you level shifting to deal with the 5V/3V3 issue?

Try a slower baud rate.

Goblotron:
I already use the fastest Baud rate available.

Normally when you have serial communication issues, you would try to switch to lower baud rates, to see if it cures the problems.

Thank you for your answers!

So, we tried to go back to 9600 Baud, and after loads of tests it seems like it didn't changed anything. Some characters are still missing.

I tried powering the arduino with a dedicated power supply, because i read that the raspberry power chip cannot supply enough power for all my sensors.

I also tried to flush the serial port after each communications, on the arduino and on the raspi.

None of these changes made a difference sadly!

About the 5V/3V3 logic voltage issue, since we use the USB port for serial communication, i thought we don't need the level shifting circuit?

Thank you very much for your help!

I was thinking about using the RX/TX pins serial (with a voltage divider) rather than using the USB port: could it be more reliable?

Perhaps the problem is the Linux serial port software you are using. Try a reliable Linux terminal program such as minicom, picocom, or screen. All can be installed from repos.

This Simple Python - Arduino demo may help.

I usually use 500,000 baud for my PC communication and have never had a problem. I'm using Linux Mint.

...R

Thank you again for your hints :slight_smile:

I installed minicom, and managed to read the serial from it, but I can't manage to use it in a python script, do you have any idea how to do that? i can't find anything on the internet about using minicom off its own environement.

About the Simple Python solution, from my understanding i should redo all my communication differently if i choose this new communication method?

Have a nice day :slight_smile:

minicom can log incoming serial data to a file but is not a programming language. It cannot, for example, reformat the data and insert a record into a database.

Python is a programming language with lots of library support so it can receive the serial data and do many, many things with the data. pySerial includes an example of a terminal program (miniterm) in python. The source code is included with the library so you might be able modify it to do whatever processing you need on the incoming data without changing on the Arduino side.

https://pyserial.readthedocs.io/en/latest/examples.html