L01 deep-sleep and LoRa transmission



  • I spent a lot of time troubleshooting weird behavior of LoRa transmission in combination with (proper) deep-sleep of L01. The weird symptom was byte errors in received messages especially in case the transmitting device was placed in colder environment. I was suspecting poor voltage regulator performance on my custom PCB, then issues with signal path between LoRa antenna pad and antenna itself. Then I checked the behavior on Pycom OEM baseboard with L01 solder on it and behaved similarly. As a next step I simplified the code:

    Transmitter

    from network import WLAN, LoRa
    import socket
    import machine
    import time
    
    wlan = WLAN()
    wlan.deinit()
    
    lora = LoRa(mode=LoRa.LORA, frequency=864000000, tx_power=14, bandwidth=LoRa.BW_500KHZ, sf=10, coding_rate=LoRa.CODING_4_5, tx_iq=True)
    
    lora_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    lora_sock.setblocking(False)
    
    sample = bytearray(b'TEST1234')
    
    lora_sock.send(sample)
    print("LoRa message sent (%s)" % (sample))
    machine.deepsleep(5000)
    

    Receiver

    from network import WLAN, LoRa
    import socket
    import machine
    import time
    
    lora = LoRa(mode=LoRa.LORA, frequency=864000000, tx_power=14, bandwidth=LoRa.BW_500KHZ, sf=10, coding_rate=LoRa.CODING_4_5, rx_iq=True)
    
    lora_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    lora_sock.setblocking(False)
    
    while True:
        recv_pkg = lora_sock.recv(512)
        if len(recv_pkg)>0:
            print(recv_pkg)
    

    Receiver output:

    b'TE\x93\x94\xbd\xba\xcf"'
    b'T\x85\x9b\xd4\xbd6\xcfd'
    b'TE\x1d\x9e\xf9\xb6\x0f1'
    b'T\xc5?\x9e\xdf\x12\x9b\xce'
    b'T%\x93\xdes\x18\x19\x95'
    

    Note: some messages were not received at all

    After some experiments i tried to call lora.power_mode(LoRa.SLEEP) before machine.deepsleep():

    from network import WLAN, LoRa
    import socket
    import machine
    import time
    
    wlan = WLAN()
    wlan.deinit()
    
    lora = LoRa(mode=LoRa.LORA, frequency=864000000, tx_power=14, bandwidth=LoRa.BW_500KHZ, sf=10, coding_rate=LoRa.CODING_4_5, tx_iq=True)
    
    lora_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    lora_sock.setblocking(False)
    
    sample = bytearray(b'TEST1234')
    
    lora_sock.send(sample)
    print("LoRa message sent (%s)" % (sample))
    lora.power_mode(LoRa.SLEEP)
    machine.deepsleep(5000)
    

    And it did help - receiver output:

    b'TEST1234'
    b'TEST1234'
    b'TEST1234'
    b'TEST1234'
    b'TEST1234'
    

    Note: tested on 1.7.5.b2 because of WiFi issues with later releases running on L01:
    https://forum.pycom.io/topic/2009/l01-instability

    My opinion is that the cause are floating SPI pins after ESP32 enters deep-sleep.

    Now the question is if lora.power_mode(LoRa.SLEEP) should be called internally within machine.deepsleep() or is it developer's responsibility to do so?

    I spent two days solving this issue and still do not understand coherence with lower environment temperature.



  • @jcaron
    I did not try those modifications as calling lora.power_mode(LoRa.SLEEP) before machine.deepsleep() made transmission reliable.

    On the other hand it may be possible that without this precaution ESP32 enters deep-sleep before transmission is finished.



  • @danielm Does adding a call to time.sleep() (for 500 ms for instance) between the sendand the deepsleep change anything?

    Does setting the socket to blocking change anything as well?



  • @danielm thanks for reporting this. We will investigate it.


Log in to reply
 

Pycom on Twitter