TOI - Things on Internet
Published © GPL3+

Python on ESP32 for Industrial LoRaWAN Applications

How to send data from a 4zerobox (based on ESP32 and Python programmable using Zerynth) to The Things Network via a Microchip LoRa module

BeginnerFull instructions provided1 hour4,780
Python on ESP32 for Industrial LoRaWAN Applications

Things used in this project

Hardware components

4zerobox
×1
Mikroelektronika LoRa Click
×1
ESP32S
Espressif ESP32S
×1
AAEON LoRa Gateway
×1

Software apps and online services

Zerynth Studio
Zerynth Studio
The Things Network
The Things Network

Story

Read more

Schematics

4zerobox features

Code

4zerobox - LoRa Test

Python
import streams
from microchip.rn2483 import rn2483 # import lora driver

streams.serial()

# LoRa module on Mikrobus Slot 1
ser_LORA = SERIAL2
rst_LORA = D4

# TTN appeui and appkey
appeui = 'appeui'
appkey = 'appkey'

i = 0
while True:
    i += 1
    print("joining 4ZeroBox TTN Demo App")
    print("attempt ", i, "...")
    
    try:
        res = False
        res = rn2483.init(ser_LORA, appeui, appkey, rst_LORA)
    except Exception as e:
        print(e)
    
    if not res:
        print("... failed :(")
        sleep(1000)
    else:
        print("... succeded !")
        break

cnt = 0
while True:
    msg = '4ZB'+str(cnt)
    print("sending '",msg,"' to TTN")
    try:
        res = rn2483.tx_cnf('4ZB'+str(cnt))
    except Exception as e:
        print(e)
    if res:
        print("response :'",res,"'")
    else:
        print("no response received")
    cnt += 1
    cnt %= 256
    print(cnt)
    sleep(4000)

Credits

TOI - Things on Internet

TOI - Things on Internet

4 projects • 18 followers
TOI is the creator of 4zerobox: the Industrial Toolkit for IoT Solution Providers. Live now on Kickstarter: https://bit.ly/get-4zerobox

Comments