We were trying the LoRa shield for our project, but it never managed to complete a LoRa Join procedure. Seeing the firmware version was this old, we suspected it to be the reason for this faulty behaviour.
SetupWe used a nucleo-f401re's st-link programmer to reprogram the shield. Since the LoRa shield's embedded processor contains some unique identification data that must be saved before upgrading the firmware, we also connected the st-link's UART port to the shield. In order to avoid conflicts on the uart pins, we held the main nucleo MCU's reset pin low with a wire.
BackupFollowing the instructions on the firmware repo, the first step was to backup the identification data stored on the board. The repository provides a custom openocd build and some windows-only scripts, so we spun up a Windows virtual machine to complete the process.
sm42_backup.bat 3
Getting to this point took a while; in fact, we debugged for a few hours on both the uart and swd links before getting it right.
Firmware upgradesm42_update.bat 3 sm42_monolithix_v4.0.2.hex
With the firmware upgraded, we could now fully test the functionality of the shield and complete some LoRa packet exchanges. The following is a test script to use the shield via a USB to serial adapter from a computer.
import serial
ser = serial.Serial('/dev/ttyUSB0', baudrate=115200, timeout=1)
def cmd(line):
if type(line) == str:
line = line.encode()
print(f'[+] Sending {line}')
ser.write(line + b'\r\n')
# print(ser.readline())
while True:
x = ser.readline()
if x == b'':
break
print(x)
# Device identification
appeui = [...]
ak = [...]
cmd("ATZ")
cmd("AT+DC=0")
cmd("AT+DR=3")
cmd("AT+RX2DR=3")
cmd("AT+APPEUI=" + appeui)
cmd("AT+AK=" + ak)
cmd("AT+JOIN=1")
while True:
cmd(input())
With this code, we could send a LoRa packet and receive it over on TTN:
Comments
Please log in or sign up to comment.