Send data from PC to LoPy4 via USB(Ex. Board v3)



  • Hey guys :)

    I try to send via UART data(LoRa Msg/payload) from PC to LoPY.
    It seems i can't send data via USB to LoPy. I am right?

    Tried to debug it manually:

    from machine import UART
    import binascii
    import pycom
    uart = UART(1, 115200)
    uart.init(115200, bits=8, parity=None, stop=1)
    pycom.heartbeat(False)
    i=0
    le=100
    u=1
    while i<le:
        u=uart.read(1)
        if u:                 #Always None
            pycom.rgbled(0xff00)
        print(i)
        i=i+1
    
    

    I have to use the Pins, right?

    Thanks :)

    Kind regards
    Milad



  • @robert-hh Ah, Thanks !!



  • @sadtex The default pins for UART 1 are P3(TX) and P4(RX). If you want to use the USB/UART on expansion board 3, you must select UART 0.
    Instead of using the UART module, you can also use sys.stdin.read() for receiving and sys.stdout.write() for sending.
    Be aware that using UART0 is not fully transparent. It may still react on Control signals like Ctrl-C (abort) and Ctrl-F(safe boot). In order to deactivate this, call micropython.kbd_intr(-1).


Log in to reply
 

Pycom on Twitter