Next step was in understanding how to use it with micropython. Because we love Python and therefore we love Micropython ❤. We found out that there is exists an SX127x driver for ESP8266, ESP32 and Raspberry Pi. And a clean version for ESP32 named uPyLora.

import time



from lora.sx127x import SX127x

from lora.controller_esp32 import ESP32Controller





controller = ESP32Controller()

lora = controller.add_transceiver(

SX127x(name='LoRa'),

pin_id_ss=ESP32Controller.PIN_ID_FOR_LORA_SS,

pin_id_RxDone=ESP32Controller.PIN_ID_FOR_LORA_DIO0

)



counter = 0

print("LoRa Sender")



while True:

payload = 'Hello ({0})'.format(counter)

print("Sending packet:

{}

".format(payload))



lora.println(payload)



counter += 1

time.sleep(1)

Picocom output

And with ESP32 it worked well.

But unfortunately, on ESP8266 that code throws memory error. The simplest way was to slightly optimize that driver by removing constant variables that were used only once and placing their values straight into the code.

Unfortunately, we have only one antenna that was included with ESP32 we ordered. That test was done on a low range, I tried to move away with module without antenna — and maximal communication range was around 1.5–2 meters. So make sure to order one for each module or check that there will be pin to attach at least a simple wire.