A LoRaWAN enabled Energy Meter using TTGO ESP32 board and PZEM-004T Energy Monitoring module.
The Energy Meter data is sent to TTN as raw bytes and decoded in TTN using the following piece of code in decoder in Payyload Format,
function Decoder(bytes, port) {
var decoded = {};
var voltage = (bytes[0] << 8) + bytes[1] +(bytes[2] / 10.0);
var power = (bytes[3] << 8) + bytes[4];
var energy = (bytes[5] << 16) + (bytes[6] << 8) + bytes[7];
decoded.voltage = voltage;
decoded.current = voltage > 0 ? power / voltage : 0;
decoded.power = power;
decoded.energy = energy;
return decoded;
}
}