Help to decode Netvox R711 data

Hi All,

got a Netvox R711 which was provided with a payload format document that it sends in.

But unfortunately it means nothing to me when I try to make that into a payload decoder.

I get a payload like this

01 01 01 20 0B DD 0B FE 00 00 00

The information given is

01 - protocalversion
01 - Device type (=R711)
01 - report type
20 - Battery(1 Byte,unit:0.1V)
0B DD - Temperature(Signed 2 Bytes,unit:0.01°C)
0B FE - Humidity( 2 Bytes,unit:0.01%)
00 00 00 - reserved

So any help to get this decoded into a temp/humidity/battery readings would be much appreciated

thanks
Paul

1 Like

Paul, have no experience with the particular device but looking at the bytes it is similar to what i’m doing. See if this works

var BatteryVolts = (byte[4] / 10);
var Temperature = ((bytes[5] << 8) | bytes[6]) / 100);
var Humidity = ((bytes[7] << 8) | bytes[8]) / 100);

Opps, should have included a bit more detail. the decoder in full may look like this.

Still bumbling along myself, but this works for my nodes and they send data very similar to what you are doing

function Decoder(bytes, port) {
  var BatteryVolts = (byte[4] / 10);
  var Temperature = ((bytes[5] << 8) | bytes[6]) / 100);
  var Humidity = ((bytes[7] << 8) | bytes[8]) / 100);
  return {
    BatteryVolts: BatteryVolts,
    Temperature : Temperature,
    Humidity: Humidity,
  }
}
2 Likes

Almost perfect. :slight_smile:

The bytes array is zero-indexed, so the first byte has index 0. So all indexes are 1 too high; 4 for the battery should read 3, and so on.

Temperatures are signed values, which need 4 bytes in JavaScript; see Negative Temperature. So:

// Sign-extend to 32 bits to support negative values, by shifting 24 bits
// (16 too far) to the left, followed by a sign-propagating right shift:
var Temperature = (bytes[4]<<24>>16 | bytes[5]) / 100;

You’re right about decoding the unsigned humidity, but I really doubt the sensor is really that accurate. But it confirms to the documentation.

Finally, one might want to take the first 3 bytes into account as well for other uplink types. Or, lacking any details about that, fail when they don’t match:

if (bytes[0] === 0x01 && bytes[1] === 0x01 && bytes[2] === 0x01) {
  // decode as shown in earlier post
  return {
    ...
  };
}
// Maybe one could also return null, or throw an error, to make TTN fail
return {
  error: "unsupported version, device type or report type"
};
1 Like

Thanks @arjanvanb, made a mistake converting from my code and forget to count from zero.

1 Like

Thanks @TonySmith and @arjanvanb, looks great.

I will do some more testing tomorrow but this looks like it has solved my question

cheers
Paul

@arjanvanb, For the record. I don’t think i’ve ever experienced a negative temperature, have no idea what that is. :thinking: Temps this week will be peaking to 40C and anything lower than 10C is considered unbearable. :grin:

This sensor is in Western Queensland, Australia, it will see anywhere between -5 and 45 most years

1 Like

6 posts were split to a new topic: Decoding Smart Waste Bin Detector DF702 payload

Hey Paul,

Did you get the decoder working for the R711. If so, could you share the final code?

Thanks!

Here is the working formatter for a R712, which is just a 711 in outdoor clothing, should work the same.

function Decoder(bytes, port) {
var BatteryVolts = bytes[3] / 10;
var Temperature = (bytes[4]<<24>>16 | bytes[5]) / 100;
var Humidity = ((bytes[6] << 8) | bytes[7]) / 100;

return {
    Volts: BatteryVolts,
    Temperature : Temperature,
    Humidity: Humidity
    };
}
1 Like