Search code examples
python-2.7raspberry-pipicuart

how to show UART received data (on PIN 10, RX) of Raspberry pi on Tkinter Window


I have a slave pic which will transmit some data to Raspberry pi depending on switch pressed(connected to pic) using UART. I want to show the message which is coming on RX pin of raspberry pi to Tkinter window. what is the procedure to do so??


Solution

  • import serial, time, struct
    
    ser = serial.Serial("/dev/ttyAMA0", 9600)
    
    
    
    while True:
    
        count = 0
        AValue = []
        for ch in ser.read():
            if ch == "\n":
                AValue = []
                time.sleep(0.1)
    
        while count < 4:
            for ch in ser.read():
                AValue.append(ch)
                count += 1
    

    im using this code to recive four bytes of code (float) from pic. you can go from there