Answer the question
In order to leave comments, you need to log in
How to configure UART on Raspberry pi?
Good afternoon.
Connected Rasberry PI and Arduino via UART via USB cable.
But for some reason it doesn't work the way it should. When sending data from raspberry, it is clear that the data is coming to the arduino (the built-in RX and TX LEDs are blinking), but the arduino program does not process the input data correctly.
On arduino, a simple program (essence):
...
if ((String)buffer_in == "777"){
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
}
...
Answer the question
In order to leave comments, you need to log in
Your Arduino is trying to receive at a speed of 9600, this is the minimum speed and the UART should work without problems, so they poke it into all the sketches and you drew it. The Raspberry thing is cooler and the default UART settings are cooler. Data transmission is synchronous, i.e. the speeds must match, when you change the speed on the raspberry under the Arduino, then everything becomes normal.
You can try to change UART speed on Arduino under Raspberry
Set the speed and mode of the port from the RPi side to the same as expected by the arduino, for example, by calling stty with the necessary parameters.
An interesting moment was discovered
If you call two console windows and write
>>> python
>>> import serial
>>> ser = serial.Serial("/dev/ttyACM0", 9600)
import serial
ser = serial.Serial("/dev/ttyACM0", 9600)
ser.open()
ser.write("777,led,add")
ser.close()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question