LoRaWan Decoders~
LoRaWan end devices transmit packets containing raw Payload Data. The Tasmota LoRaWan Bridge feature normally passes the raw Payload Data onto an MQTT server.
{
"LwReceived": {
"0xAE3D": {
"Node": 1,
"Device": "0xAE3D",
"RSSI": -14,
"SNR": 8.8,
"Decoder": "LHT52",
"DevEUIh": "A840414E",
"DevEUIl": "4F5CAE3D",
"FPort": 2,
"Payload": [9,230,2,48,127,255,1,104,33,178,172]
}
}
}
Adding Payload Data Decoding~
There are no industry standards on the format or content of the raw data send by each sensor; every manufacturer/device is different. There are public databases of decoder scripts for many devices; e.g. TTN decoder script database
The Tasmota LoRaWAN Decoder feature: - is optional
- is implemented in Berry - does not require any custom builds - the elements are: - a Berry script LwDecode.be
that: - subscribes to the tele/xxxx/SENSOR MQTT messages, looking for the LwReceived
packets sent by the Tasmota LoRaWAN Bridge. - dynamically loads (once only) Device Decoder Files from the Tasmota file system, if they exist. - asks a Device Decoder File to decode the raw Data Payload - reports the result via MQTT - Device Decoder Files: - are written in Berry - closely modelled on the TTN decoder script database.
Example LwDecoded MQTT message~
{
"LwDecoded": {
"0xAE3D": {
"TempC_Internal": 25.34,
"Ext_SensorType": 1,
"Systimestamp": 1747038892,
"Device": "Dragino LHT52",
"Ext_SensorConnected": false,
"Hum_Internal": 56
}
}
}
Files~
These files are available from the Tasmota Github Repository
- LwDecoder.be
- Device Decoder Files (indexed by Vendor/Model)
How to use the Device Decoder feature~
- Download to your local PC, then upload to the Tasmota File System
- LwDecode.be
- the Device Decoder File(s) for your End Device(s), or write your own (see below)
- Add this line to
autoexec.be
in the Tasmota File System (create if necessary)
load("LwDecode.be")
- Execute these Tasmota Console commands:
LoRaWanAppKey<x> yyyyyyyy
where<x>
is the Tasmota LoRaWAN node number. Joins an End Device to the LoRaWan Bridge. See LoRaWan Commands.LoRaWanDecoder<x> <decoderfile>
where<x>
is the Tasmota LoRaWan node number. Sets the name of the Decoder File for each end device.
e.g.LoRaWanDecoder1 LHT52
associates node 1 with theLHT52.be
decoder fileBrRestart
to restart Berry
Write your own Device Decoder file~
- Find the JavaScript (*.js) decoder file for your device from TTN Device Decoder database
Alternatively, find the manufacturer's datasheet/User Guide/User Manual/etc. to learn the syntax of the Raw Data Payload - Edit LwDecoderSample.be to decode the Raw Data Payload
- Rename
LwDecoderSample.be
to<DeviceName>.be
where<DeviceName>
matches your device name. - Copy
<DeviceName>.be
to the Tasmota File System. -
Test
load("<DeviceName>.be")
from the Berry Scripting Console, looking for any reported errors.- Execute this Tasmota console command:
LoRaWanDecoder<x> <DeviceName>
- Execute this Tasmota console command:
- Wait for your device to send raw Data Payloads to your Tasmota installation, and confirm
LwDecoded
MQTT messages are received, and the values are correct:
-
Submit a PR to share your new decoder with the Tasmota community.