GithubHelp home page GithubHelp logo

ludiazv / node-red-contrib-bme280 Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 8.0 22 KB

Node RED BME280/BMP280 sensor node

License: Other

HTML 34.89% JavaScript 62.03% Shell 3.08%
node-red sensor raspberry-pi orangepi bme280 temperature barometer humidity

node-red-contrib-bme280's Introduction

node-red-contrib-bme280

A node-red custom node wrapper for the nodejs bme280-sensor. by @skylarstein . This library uses the outstanding package i2c-bus that enable the communication with I2C devices in most common Linux SBCs. Raspberry Pi, C.H.I.P., BeagleBone, Orange Pi, or Intel Edison are supported by this package.

The package provide a single custom node Bme280 that can be used directly in your flow.

Installation

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

npm install node-red-contrib-bme280

Node palette can be used as well to install the node.

After restarting node-red the "Bme280" node should be available in "input" category.

Prerequisites

Wire your sensor the I2C/TWI of the SBCs. Only four wires are needed. two for power (VCC 3.3V & GND) and two for actual I2C transmission (SLC & SDA).

I2C interface need to be enabled in in your linux distribution.

Caveat: Check your permissions to the /dev/i2c-xx devices. The user running node-red need access to writing and reading. Refer to i2c-bus to find how to grant access to your user to the /dev/i2c-xx device files

Usage

Configuration & deployment

After installation place your Bme280 node in any of your flow and configure the following parameters:

  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 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.
  5. Extra: Check box to indicate the node to compute extra information each time a read is requested.
  6. Sea Preasure: If extra information provided this parameter is used for correction. The value is in hPa.

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. 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 = {
  _msgid: <node-red msg_id>,
  topic: <defined topic>,
  payload: {
    model: "BME280"  or  "BMP280",
    temperature_C: <float in celsius>,
    humidity: <float in %>, // Only present if model == "BME280"
    pressure_hPa: <float in hPa>
  }
}

// the node node is configured to send extra information payload will contain also

payload: {
     ....
     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, heatIndex & dewPoint_C will not be present in the payload.

Notes

This node has been tested on Raspberry Pi 3, Raspberry Pi Zero & Orange Pi Zero. Running recent versions of node-red.

BPM280 & BME280 has been tested using different breakout from cheap providers. Original Adafruit's sensor is not required.

Change log

  • 1.1.0 Stable version

    • Added max init retries to avoid continous use of I2C bus
    • Added message bypass in case of error.
    • Added parameter for sea level presasure to calculate properly altitude.
  • 1.0.0 Stable version

    • Sensor init is done also in input trigger for better stability.
  • 0.0.5

    • Fix #2 for nodejs >=13 compatibility
  • 0.0.4

    • Improve node status messages.
  • 0.0.3

    • Custom Icon
    • 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

node-red-contrib-bme280's People

Contributors

ludiazv avatar maga-1 avatar nrbrt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-red-contrib-bme280's Issues

Your module apparently causes the i2c scan to slow down signficantly if the sensor disappears or another sensor is added after the bme280 sensor disappears?

Your module appears to cause the i2c scan to slow down significantly if the sensor was found, but later is not found. This should not happen, if the sensor is missing or disappears, the scan should still be quick. You can recreate this issue by adding a different sensor to the i2c bus, in place of the bme280, say a SHT3X sensor, but leave the BME280 flow in node red as is. Then run i2cdetect -y 1 and the detect scan will be horribly slow. Removing all sensors, i.e. SHT3X sensor, the scan returns to normal speed. This again can be illustrated by direct i2cdetect -y 1 from the command line. As long as your module is in an active flow, the slow down occurs, when the bme280 disappears or another sensor is on the bus other than the bme280.

Request that node test for presence of sensor before attempt to initialize same

Request that node test for presence of sensor before attempt to initialize same. Is sensor not found do not attempt to initialize sensor. Do not endlessly attempt to initialize sensor if not found as well. Suggest allow operator set the number of times node should try to initialize sensor. Suggest allow operator to select action to be taken if sensor disappears after once present, such as only search bus to rediscover sensor, or just report sensor missing.

does not compile on buster with node.js 13.3.0 and node-red 1.0.3

gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:219:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
gyp ERR! System Linux 4.19.75-v7+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/.node-red/node_modules/bme280-sensor/node_modules/i2c-bus
gyp ERR! node -v v13.3.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-07T17_12_40_774Z-debug.log

Incorrect altitude calculation.

In order to calculate the altitude the sea level pressure is needed.
your algorithm considers the pressure at sea level = 0 which is wrong.
Maybe it should be a parameter we can pass in so we can change that.

Address validation error

Hi

the BME280 shows me an address validation error. NaN is not defined, despite the number being filled (0x76).

Any idea? Tried deleting the node and putting in a new one, but the issue persists.

Connection BME280 to PC(Windows)

Hello,

im looking for a way to connect a BME280 via USB-I2C to my PC (Windows).
My idea was to use something like this :
https://www.amazon.de/I2C-MP-USB-I%C2%B2C-USB-Adapter-Evaluations-Board-SMD/dp/B07VSMW6P6/ref=pd_lpo_2?pd_rd_i=B07VSMW6P6&psc=1

BME280 -> I2C-USB-Adapter -> PC -> Node-Red -> node-red-contrib-bme280

Did someone tried something like this already?
I dont need a controller since the node provides the code right?
Could this work out the way i described the idea?

best regards

Parameter error I2C-Address

NR 3.0 (Node.js 16.0) fires a parameter error I2C-Address. Reason is the wrong Statement isNan() in the html-File (package node-red-contrib-bme280).
Correctly the statement is isNaN().
Nevertheless the node is working fine
Hope, it will help and please update the Code

Is payload empty or null or never sent on error?

Just need to clarify something, if the node reports "Sensor Init failed ->Error: , Remote I/O error" it appears the payload is never forwarded? How does on then handle errors? Looks like node only reports errors to the debug stream?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.