BME 680 support: payload converters addes
This commit is contained in:
1 parent
2b96f6e0bf
commit
ddd5764a8b
8 files changed
+72
-23
No files matched your search
@@ -41,6 +41,11 @@ function Decoder(bytes, port) {
|
||||
return decode(bytes, [uint8, uint8], ['rssi', 'beacon']);
|
||||
}
|
||||
|
||||
if (port === 7) {
|
||||
// BME680 sensor data
|
||||
return decode(bytes, [temperature, uint16, humidity, uint16, uint16], ['temperature', 'pressure', 'humidity', 'gas', 'altitude']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +137,7 @@ var temperature = function (bytes) {
|
||||
if (isNegative) {
|
||||
t = -t;
|
||||
}
|
||||
return t / 1e2;
|
||||
return +(t / 100).toFixed(1);
|
||||
};
|
||||
temperature.BYTES = 2;
|
||||
|
||||
@@ -142,7 +147,7 @@ var humidity = function (bytes) {
|
||||
}
|
||||
|
||||
var h = bytesToInt(bytes);
|
||||
return h / 1e2;
|
||||
return +(h / 100).toFixed(1);
|
||||
};
|
||||
humidity.BYTES = 2;
|
||||
|
||||
|
||||
@@ -40,6 +40,15 @@ function Decoder(bytes, port) {
|
||||
decoded.rssi = bytes[i++];
|
||||
decoded.beacon = bytes[i++];
|
||||
}
|
||||
|
||||
if (port === 7) {
|
||||
var i = 0;
|
||||
decoded.temperature = ((bytes[i++] << 8) | bytes[i++]);
|
||||
decoded.pressure = ((bytes[i++] << 8) | bytes[i++]);
|
||||
decoded.humidity = ((bytes[i++] << 8) | bytes[i++]);
|
||||
decoded.gas = ((bytes[i++] << 8) | bytes[i++]);
|
||||
decoded.altitude = ((bytes[i++] << 8) | bytes[i++]);
|
||||
}
|
||||
|
||||
return decoded;
|
||||
|
||||
|
||||
Reference in new issue
Block a user