SenseCAP LoRaWAN Starter Kit displaying measurements in Chirpstack

Dear pros,
I’ve bought the SenseCAP LoRaWan starter kit. I set a new appkey in the E5 module and connected the device with the gateway which is connected to the local Chirpstack server. Lorawan messages from the device (and it’s 3 sensors) are coming in nicely. Now I need the correct Java codec code to decode the payload and the required entries for the device profile measurements page.
Can somebody help me please?
Thanks a lot
Michael

Hi,
Maybe in github → Seeed-Solution → SenseCAP-Decoder
List all the payload decoder.
Cobalt

2 Likes

SenseCAP sensors use a standard payload format, and Seeed Studio provides decoder scripts that work well in ChirpStack. Below is a general-purpose decoder for the SenseCAP LoRa-E5-based sensors:

JavaScript Codec (for ChirpStack):

Go to your Device Profile > Codec tab, and paste this into the “Decode uplink” field:

function Decode(fPort, bytes) {
  var decoded = {};

  for (var i = 0; i < bytes.length;) {
    var channel = bytes[i++];
    var type = bytes[i++];

    // Temperature (0x67), 2 bytes, °C
    if (type === 0x67) {
      var temp = (bytes[i] << 8) | bytes[i + 1];
      if (temp & 0x8000) temp |= 0xFFFF0000; // Convert to signed
      decoded.temperature = temp / 10.0;
      i += 2;
    }

    // Humidity (0x68), 1 byte, %
    else if (type === 0x68) {
      decoded.humidity = bytes[i++] / 2.0;
    }

    // CO2 (0x7D), 2 bytes, ppm
    else if (type === 0x7D) {
      decoded.co2 = (bytes[i] << 8) | bytes[i + 1];
      i += 2;
    }

    // Light Intensity (0x65), 2 bytes, lux
    else if (type === 0x65) {
      decoded.illuminance = (bytes[i] << 8) | bytes[i + 1];
      i += 2;
    }

    // Soil Moisture (0x75), 1 byte, %
    else if (type === 0x75) {
      decoded.soil_moisture = bytes[i++];
    }

    // Battery (0x01, channel 0xFF), 2 bytes, mV
    else if (channel === 0xFF && type === 0x01) {
      decoded.battery = ((bytes[i] << 8) | bytes[i + 1]) / 1000.0;
      i += 2;
    }

    // Add more types here if needed
    else {
      break; // Unknown type
    }
  }

  return decoded;
}

This handles typical sensors like temperature, humidity, CO2, illuminance, soil moisture, and battery.

1 Like

Thank you for your generous sharing.