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