RPi Node-Red: BME280

Parts List:

BME280

Getting Started:

Setting up the Hardware

Setting up Node-Red

1) Start Node-Red and navigate to 127.0.0.1:1880.

If your Raspberry Pi does not have the node-red-contrib-bme280 palette, follow the instructions located here.

2) After installing the BME280 palette, place the Bme280 node onto the workflow.

3) What the Bme280 node does is read sensor data from the Bme280, and delivers that data as a payload.

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>
  }
}

 

As you can see, the payload contains attributes we will graph, including temperature, humidity, etc.

4) After seeing what the BME280 sensor sends to the Raspberry Pi, we are going to format it as a graph using Node-Red and Dashboard. Start by placing a change node from the functions section onto the workflow. The change node specifies the data field from the Bme280 node, in this case it is the temperature field.

5) Double-click on the change node to open the node configuration menu. Under Rules, you will see a field for payload and under that, another blank field. Click on the drop down button and select msg.

6) Now that we have specified the type to msg., we want to type in “payload.temperature_C”. If you look at the BME280 payload again, you can see that the field we typed in refers to that payload. Click Done once completed.

7) Drag and drop the chart node from the dashboard section onto the workflow.

8) Double click the chart node to edit the node. On the group field, click on the pencil button.

8.1) On the Tab field, click on the pencil button again.

8.2) From there, click on the Update button to return to the previous menu, then again to return to the original menu. This is to confirm the dashboard view settings. On the original menu, we can adjust the graph’s design, color, label, etc. Let’s proceed with labeling our chart “Temperature in C”. Click Done once completed.

9) To have the BME280 send data at an interval, place an inject node from the input tab onto the workflow.

9.1) Set the payload to number and enter 1 (means ‘on’ for the computer) in the field. Set Repeat to interval and set the interval time to any desired time (good to start at 5 seconds). Click Done once completed.

10) With all the nodes configured, connect all the nodes and hit Deploy.

11) Navigate to the Dashboard page to view your graph(s): 127.0.0.1:1880/ui/#/0

Node-RED Palette Installation (node-red-contrib-bme280)

1) Click on the menu icon in the top-right corner of the window and select Manage palette.

2) Navigate to the Install tab.

3) In the search modules bar, type in node-red-contrib-bme280 and click install.

4) An installation window will pop-up. Click install.

 

Next Steps:

 

image_pdfGenerate PDFimage_printPrint
Posted in Node-Red, Raspberry Pi.

Leave a Reply