UART: I cannot get any reading from GPS



  • Hi,
    I connected GPS module to GPy and tried to read some data from it using UART. No success despite many attempts. Reading is always None. GPS module works perfectly as I have connected it to my computer and sends data.

    
    from machine import UART
    
    uart = UART(1, 9600)
    uart.init(9600, bits=8, parity=None, stop=1, pins=('P3','P4'))
    
    print (uart.readline())
    
    while True:
        if (uart.any()>0):
                print ('Yra')
    

    Any help appreciated!

    Used items:
    Exp. board 3.0
    (sysname='GPy', nodename='GPy', release='1.18.0.r1', version='v1.8.6-849-9569a73 on 2018-07-20', machine='GPy with ESP32', pybytes='0.9.0')
    GPS: GP-20U7



  • @robert-hh

    Hooray! I've got it!
    Signal wire was broken between pin and GPS. Thanks.



  • Hi,

    I tried your code, same result.

    How can I test somehow if UART on GPy is working?



  • @andrejpekarcik how about swapping P3 and P4, either the wires or the arguments?

    from machine import UART
    
    uart = UART(1, 9600)
    uart.init(9600, bits=8, parity=None, stop=1, pins=('P3','P4'))
    
    while True:
        if (uart.any()>0):
                print (uart.readline())
    

    or better:

    from machine import UART
    import sys
    
    uart = UART(1, 9600)
    uart.init(9600, bits=8, parity=None, stop=1, pins=('P3','P4'), timeout_chars = 10)
    
    while True:
        if (uart.any()>0):
            sys.stdout.write(uart.read().decode())
    


Pycom on Twitter