Skip to content

Commit

Permalink
0.0.3 fix & examples
Browse files Browse the repository at this point in the history
  • Loading branch information
L Diaz committed Apr 21, 2018
1 parent f1035d8 commit 5c6d71e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The package provide a single custom node __Bme280__ that can be used directly in

## Installation

Under your node-red working directory.
Under your node-red (typically ``$HOME/.node-red``) working directory.

``
npm install node-red-contrib-bme280
Expand Down Expand Up @@ -35,25 +35,25 @@ After installation place your Bme280 node in any of your flow and configure the
1. __Name:__ Select the name of your sensor for easy identification.
2. __Bus ID:__ Select the I2C bus to which the sensor is connected. Depending on your wiring and SBC can be different.
3. __I2C address:__ I2C address (7-bit) hexdecimal address(0x##). BMP/BME280 sensor have fixed 0x77 or 0x76. You can check your sensor id by using i2c-tools typing ``i2cdetect -y <busnum>``
4. __Topic:__ Topic field set on the input message. If this field is empty topic will not be included in the output msg. By configuring the node this input msg topic will be reused.
4. __Topic:__ Topic field set on the output message. If this field is empty, topic will not be included in the output msg. By configuring the node this way input msg topic will be reused.
4. __Extra:__ Check box to indicate the node to compute extra information each time a read is requested.


After configuration and deployment the node will init the sensor and will identify if BME280 or BMP280 variant is detected.

### Reading Sensor Data
As in other node-red nodes the actual measurement of sensor data require that an input msg arrive to the node. The input called __Trigger__ will start the reading of sensor data will send the data in the node's output.
As in other node-red nodes the actual measurement of sensor data require that an input msg arrive to the node. The input called __Trigger__ will start the reading of sensor data will send the data in the node's output. The input __msg is reused__ so any property on the input msg (with the exception of payload and topic if set) will be redirected without modification to the output.

The __output__ will have the following format:

```
msg = {
_id: <node-red msg_id>,
_msgid: <node-red msg_id>,
topic: <defined topic>,
payload: {
model: "BME280" or "BMP280",
temperature_C: <float in celsius>,
humidity: <float in %>,
humidity: <float in %>, // Only present if model == "BME280"
pressure_hPa: <float in hPa>
}
}
Expand All @@ -62,15 +62,15 @@ msg = {
payload: {
....
heatIndex: <float in celsius>,
dewPoint_C= <float in celsius>,
heatIndex: <float in celsius>, // Only present if model == "BME280"
dewPoint_C= <float in celsius>, // Only present if model == "BME280"
altitude_M= <float in Meters>,
temperature_F=<float in fahrenheit>
pressure_Hg=<float in mm of mercury>
}
```
__Note__: BMP280 version __WILL NOT__ report humidity information the sensor do not provide this information. humidity will be always be read as __0__.
__Note__: BMP280 version __WILL NOT__ report humidity information the sensor do not provide this information. humidity, heatIndex & dewPoint_C will not be __present__ in the payload.


## Notes
Expand All @@ -87,5 +87,7 @@ BPM280 & BME280 has been tested using different breakout from cheap providers. O
- Topic configurable to help MQTT integration
- Input msg will be reused to enable better HTTP node integration.
- Documentation improvements
- Added some examples.

* 0.0.2 Solved npm repository name.
* 0.0.1 First version
2 changes: 1 addition & 1 deletion bme280.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
return this.name ? this.name : "Bme280";
},
labelStyle: function() { return this.name ? "node_label_italic" : "";},
outputLabels: ["Incoming Payloads"],
outputLabels: ["Sensor reads"],
inputLabels: ["Trigger"]
});
</script>
Expand Down
9 changes: 6 additions & 3 deletions bme280.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ module.exports = function(RED) {
//var msg={_msgid:RED.util.generateId(),topic:"bme280",payload:data};
_msg.payload=data;
data.model=node.type;
if(node.type != "BME280" && _msg.payload.humidity !== undefined) delete _msg.payload.humidity;
if(node.topic !== undefined && node.topic != "") _msg.topic=node.topic;
if(node.extra) {
var pl=msg.payload;
pl.heatIndex=BME280.calculateHeatIndexCelcius(data.temperature_C,data.humidity);
pl.dewPoint_C=BME280.calculateDewPointCelcius(data.temperature_C,data.humidity);
var pl=_msg.payload;
if(node.type == "BME280") {
pl.heatIndex=BME280.calculateHeatIndexCelcius(data.temperature_C,data.humidity);
pl.dewPoint_C=BME280.calculateDewPointCelcius(data.temperature_C,data.humidity);
}
pl.altitude_M=BME280.calculateAltitudeMeters(data.pressure_hPa,0);
pl.temperature_F=BME280.convertCelciusToFahrenheit(data.temperature_C);
pl.pressure_Hg=BME280.convertHectopascalToInchesOfMercury(data.pressure_hPa);
Expand Down
1 change: 1 addition & 0 deletions examples/http_html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"17646079.863cc","type":"http in","z":"9b546cc2.584d9","name":"","url":"bme280","method":"get","upload":false,"swaggerDoc":"","x":90,"y":860,"wires":[["56ddef05.a245c"]]},{"id":"12587b55.d46e65","type":"http response","z":"9b546cc2.584d9","name":"","statusCode":"200","headers":{},"x":600,"y":860,"wires":[]},{"id":"2a13956c.f3379a","type":"template","z":"9b546cc2.584d9","name":"メインHTML","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"BME280 DATA: <BR>\n<HR>\nTEMPERATURE: {{payload.temperature_C}}<BR>\nPRESSURE: {{payload.pressure_hPa}}<BR>\nHUMIDITY: {{payload.humidity}}<BR>\n<HR>","output":"str","x":430,"y":860,"wires":[["12587b55.d46e65"]]},{"id":"56ddef05.a245c","type":"Bme280","z":"9b546cc2.584d9","name":"","bus":"1","address":"0x76","topic":"bme280","extra":false,"x":260,"y":860,"wires":[["2a13956c.f3379a"]]}]
1 change: 1 addition & 0 deletions examples/http_json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"17646079.863cc","type":"http in","z":"9b546cc2.584d9","name":"","url":"bme280json","method":"get","upload":false,"swaggerDoc":"","x":110,"y":860,"wires":[["56ddef05.a245c"]]},{"id":"12587b55.d46e65","type":"http response","z":"9b546cc2.584d9","name":"","statusCode":"200","headers":{},"x":720,"y":860,"wires":[]},{"id":"56ddef05.a245c","type":"Bme280","z":"9b546cc2.584d9","name":"","bus":"1","address":"0x76","topic":"bme280","extra":false,"x":280,"y":860,"wires":[["46a48ddd.381ca4"]]},{"id":"46a48ddd.381ca4","type":"json","z":"9b546cc2.584d9","name":"","property":"payload","action":"","pretty":false,"x":410,"y":860,"wires":[["7dc41cd6.f34034"]]},{"id":"7dc41cd6.f34034","type":"template","z":"9b546cc2.584d9","name":"plain json","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}","output":"str","x":560,"y":860,"wires":[["12587b55.d46e65"]]}]

0 comments on commit 5c6d71e

Please sign in to comment.