-
-
Save projectweekend/1fae5a8cf2a5b9282f3d to your computer and use it in GitHub Desktop.
import serial | |
# this port address is for the serial tx/rx pins on the GPIO header | |
SERIAL_PORT = '/dev/ttyAMA0' | |
# be sure to set this to the same rate used on the Arduino | |
SERIAL_RATE = 9600 | |
def main(): | |
ser = serial.Serial(SERIAL_PORT, SERIAL_RATE) | |
while True: | |
# using ser.readline() assumes each line contains a single reading | |
# sent using Serial.println() on the Arduino | |
reading = ser.readline().decode('utf-8') | |
# reading is a string...do whatever you want from here | |
print(reading) | |
if __name__ == "__main__": | |
main() |
Thanks!
Thanks a lot!
Did the job! thanks!
Nice
Thank you so much.
boa
Thank You so much
It is a nice code. I have added few more lines to let the users input the desired device location and baud rate. Feel free to update the same from my fork. happy coding!
Thank you
Thank you!
Thank you very much.
I am trying to read data from Emlid RS2+ via RS232 port baudrate = 115200. My code just gets stuck in "ser.readlines()" line.
I am using Jetson Orin. Any suggestions?
import serial
Serialport = '/dev/ttyACM0'
#Serialport = '/dev/serial/by-id/usb-Emlid_ReachRS2_8243D27C83B34ACE-if02'
ser_rate = 115200
def main():
ser = serial.Serial(Serialport,ser_rate)
while True:
reading = ser.readlines().decode('utf-8')
print(reading)
if name == "main":
main()
I can also provide further details on it if needed.
Helpful!