How to use UART?



  • How can I connect an external device (GPS receiver) to LoPy and setup, configure and read in program?



  • Hi

    did someone managed to make it work with an external GPS module
    I have the data coming in but when i tried to use the lib micrpyGPS it failed since it wasn't able to allocat memory
    so before starting re writing everything to convert the sentance if someone had any sketchup

    >>> from micropyGPS import MicropyGPS
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    MemoryError: memory allocation failed, allocating 136 bytes
    
    
    >>> com = UART(1,pins=("P3","P4"))
    >>> com.readline()
    b'$GPVTG,,,,,,,,,N*30\r\n'
    >>> com.readline()
    b'$GPG$GPRMC,12$GPVTG,,,,,,,,,N*30\r\n'
    >>> com.readline()
    b'$GPGGA,123243.00,,,,,0,0$GPRMC,123244.00,V,,,,,,,210217,,,N*78\r\n'
    


  • @LoneTech Ok thanks



  • Tip: for code formatting, use four spaces indentation. The REPL prompt >>> will otherwise make a nested folding quote block.

    import os
    os.uname()
    (sysname='LoPy', nodename='LoPy', release='0.9.1.b1', version='a78d0fa on 2016-10-21', machine='LoPy with ESP32')
    
    
    from machine import UART
    com = UART(1,pins=("G23","G24")) #USE P2 P3 , keep UART 0 for usb connection
    com.readline()
    b'$GPVTG,318.32,T,,M,0.03,N,0.06,K,N*3C\r\n'


  • You need last firmware

    import os
    os.uname()
    (sysname='LoPy', nodename='LoPy', release='0.9.1.b1', version='a78d0fa on 2016-10-21', machine='LoPy with ESP32')
    
    from machine import UART
    com = UART(1,pins=("G23","G24")) #USE P2 P3 , keep UART 0 for usb connection 
    com.readline()
    b'$GPVTG,318.32,T,,M,0.03,N,0.06,K,N*3C\r\n'
    ```

Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.