Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Pressure + temperature

Lobaro Pressure and Temperature Sensor

To read out the pressure & temperature probe, the Hybrid Modbus Gateway must be configured as follows:

ParameterValueComment
PlFmt5Sets the payload to a short format.
MbCmd0 0/5 * * * *:R,9600,8N1:010300160002,010300260002Reads the Registers 22-23 and 34-35. The CRON Expressions can be adjusted to set time of sensor reading.
PowerOnDelay1500Battery variant only. Sets time (in ms) between activating sensor power and reading value (time for sensor to be ready).

Data Uplink (Port 20)

Bytes | 0 .    | 1 . 2 . 3 . 4 . | 5 . 6 . 7 . 8 . |
------+--------+-----------------+-----------------+
Field | Header | Pressure | Temperature |
FieldTypeValue
Headeruint80x00 on success, 0x80 if an error occurred
Pressurefloat32Pressure in mH2O, ffffffff on error.
Temperaturefloat32

Temperature in °C, ffffffff on error.

Example

Code Block
# Example of a successful measurement
'003d94ce4541b7a512'
  '00'       -> Successful readout
  '3d94ce45' -> 0.073 mH2O
  '41b7a512' -> 22.96 °C

# Example
'80ffffffffffffffff'
  '80'       -> An error occurred.
  'ffffffff' -> Pressure could not be read.
  'ffffffff' -> Temperature could not be read.

Reference Parser

see below

Lobaro Pressure Sensor

Reading from the Lobaro Pressure Sensor using the Hybrid Gateway can be done by setting the following parameters in the configuration:

ParamterParameterValueComment
PlFmt5Sets the payload to a short format.
MbCmd0 0/5 * * * *:R,9600,8N1:010300020003Reads the Registers 2 to 4, the cron can be changed, for more info see CRON Expressions

Sample upload from the Gateway:

...

. The CRON Expressions can be adjusted to set time of sensor reading.
PowerOnDelay1500Battery variant only. Sets time (in ms) between activating sensor power and reading value (time for sensor to be ready).

Data Uplink (Port 20)

Bytes | 0 .    | 1 . 2 . | 5 . 6 .   | 7 . 8    |
------+--------+---------+-----------+----------+
Field | Header | Unit | Precision | Pressure |
FieldTypeValue
Headeruint80x00 on success, 0x80 if an error occurred
Unituint16BE0x0007 = mH2O
Precisionuint16BE0x0003 = 3 decimals
Pressureint16BE

Pressure in mH2O

Example

Code Block
# Example of a successful measurement
'00000700030211'
  '00'       -> Successful readout
  '0007' -> 0.073 mH2O
  '0003' -> 22.96 °C
  '0211' -> 529 -> 0.529 mH2O

Reference

The Value is transmitted as 16 bit signed int in Big Endian format with 3 decimals presicion.

The sample hex value of 0x0211 translates to 529 decimal. Considering the 3 decimals precision the value is 0,529 mH2O.

...

Parser

Code Block
languagejs
titleSample Pressure Probe Parser
linenumberstrue
/**
 * Parser for Lobaro Pressure Probe via LoRaWAN (hybrid gateway).
 * Usable for Pressure Probe as or with Presure+Temperature Probe.
 * Works with TTN, ChirpStack, or the Lobaro Platform.
 */
function signed(val, bits) {
    // max positive value possible for signed int with bits:
    var mx = Math.pow(2, bits-1);
    if (val < mx) {
        // is positive value, just return
        return val;
    } else {
        // is negative value, convert to neg:
        return val - (2 * mx);
    }
}

function int16_BE(bytes, idx) {
    bytes = bytes.slice(idx || 0);
    return signed(bytes[0] << 8 | bytes[1] << 0, 2*8);
}

function uint16_BE(bytes, idx) {
    bytes = bytes.slice(idx || 0);
    return bytes[0] << 8 | bytes[1] << 0;
}
function uint32_BE(bytes, idx) {
    bytes = bytes.slice(idx || 0);
    return bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3] << 0;
}
function float32FromInt(asInt) {
    var sign = (asInt & 0x80000000) ? -1 : 1;
    var exponent = ((asInt >> 23) & 0xFF) - 127;
    var significand = (asInt & ~(-1 << 23));
    if (exponent === 128)
        return null;
        // return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);
    if (exponent === -127) {
        if (significand === 0) return sign * 0.0;
        exponent = -126;
        significand /= (1 << 22);
    } else significand = (significand | (1 << 23)) / (1 << 23);
    return sign * significand * Math.pow(2, exponent);
}
function float32_BE(bytes, idx) { return float32FromInt(uint32_BE(bytes, idx)); }

/**
 * TTN decoder function.
 */
function Decoder(bytes, port) {
    var vals = {};
    if( port == 20 ){
		        if (bytes.length==7) {
          // Pressure Probe without temperature sensor
          // make sure that unit is mH2O and precision is 3 decimals
          if( (uint16_BE(bytes, 1)==7) && (uint16_BE(bytes, 3)==3)){
            vals["error"] = if( !!(bytes[0]&0x80);
            vals["pressure"] = int16_BE(bytes, 5)/10 < 0)1000;
          }
          else{
             vals["mH2Oerror"] = "Err" // Most propably not under water true;
            vals["pressure"] = null;
          }
        } else if  else(bytes.length==9) {
            vals["mH2Oerror"] = int16_BE!!(bytes, 5)/1000[0]&0x80);
          }// pressure in mH2O
        }
  vals["pressure"] = float32_BE(bytes, 1);
          else{// temperature in Degree Celsius
          vals["mH2Otemperature"] = "Invalid configuration"float32_BE(bytes, 5);
        }
    }  
    return vals;
}
 
/**
 * TTN V3 Wrapper
 */
function decodeUplink(input) {
   return {
    data: {
      values: Decoder(input.bytes, input.fPort)
    },
    warnings: [],
    errors: []
  };
} 
 

/**
 * LoRaServerChirpStack decoder function.
 */
function Decode(fPort, bytes) {
    // wrap TTN Decoder:
    return Decoder(bytes, fPort);
}
 
/**
 * Lobaro Platform decoder function.
 */
function Parse(input) {
    var data = bytes(atob(input.data));
    var port = input.fPort;
   
    return Decoder(data, port);
}

...