Reading BMP085 in Node-Red

443 views
Skip to first unread message

Greg Hunt

unread,
Jan 5, 2018, 7:59:19 AM1/5/18
to Node-RED
Hi All,

Looking for a bit of guidance - managed to setup my BMP085 Temp and Humidity senors on my Raspi 3 and read the output using a simple Python script I downloaded...

Temp = 16.00 *C
Pressure = 98039.00 Pa
Altitude = 276.81 m
Sealevel Pressure = 98041.00 Pa


However, I'm keen to integrate the readings of the sensor using Node-Red. Anyone point me in the right direction on how to do this? Longer term I want to be able to graph readings over time, using the Dashboard Flows etc.

Thanks,
G

Garry Hayne

unread,
Jan 5, 2018, 8:05:05 AM1/5/18
to Node-RED
Have a look at the Exec node, you can run system commands and return values.

Garry

Colin Law

unread,
Jan 5, 2018, 8:34:01 AM1/5/18
to node...@googlegroups.com
Is this of any help [1]? Found by searching for BMP085 on flows.nodered.ord

[1] https://flows.nodered.org/node/node-red-contrib-bmp085

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/0c8478e5-c1ef-4df5-a284-41b3f178a742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Greg Hunt

unread,
Jan 5, 2018, 8:41:57 AM1/5/18
to Node-RED
Thanks for reply Colin - I did have a look at that earlier, but the node install fails :-( 

I've managed to use the Exec Node to run the Python script - just now need to work out how I connect the Graph Node to map the data over time.


On Friday, January 5, 2018 at 1:34:01 PM UTC, Colin Law wrote:
Is this of any help [1]? Found by searching for BMP085 on flows.nodered.ord

[1] https://flows.nodered.org/node/node-red-contrib-bmp085

Colin
On 5 January 2018 at 12:59, Greg Hunt <greg....@gmail.com> wrote:
Hi All,

Looking for a bit of guidance - managed to setup my BMP085 Temp and Humidity senors on my Raspi 3 and read the output using a simple Python script I downloaded...

Temp = 16.00 *C
Pressure = 98039.00 Pa
Altitude = 276.81 m
Sealevel Pressure = 98041.00 Pa


However, I'm keen to integrate the readings of the sensor using Node-Red. Anyone point me in the right direction on how to do this? Longer term I want to be able to graph readings over time, using the Dashboard Flows etc.

Thanks,
G

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Garry Hayne

unread,
Jan 5, 2018, 1:31:41 PM1/5/18
to Node-RED
It wouldn't install here either Greg.

I have just set up  a BMP180 using the Raspberry pi Device Tree on Raspbian Stretch. Have a look here:

The BMP085 is supported too. Works a treat, you can read sensor values directly from file system using the Exec node.

If you like I will put a mini tutorial together.

Garry

Greg Hunt

unread,
Jan 6, 2018, 3:37:29 AM1/6/18
to node...@googlegroups.com
Garry - that would be a huge help. Thank you!

You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/FyxAgaFAfrY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Garry Hayne

unread,
Jan 6, 2018, 6:22:10 AM1/6/18
to Node-RED
Here you go Greg:

for the BMP085

1. add dtoverlay=i2c-sensor,bmp085 to the end of /boot/config.txt
2. reboot
3. the sensor values on my system, bearing in mind that I am using a BMP180 are:

Temperature - /sys/devices/platform/soc/20804000.i2c/i2c-1/1-0077/iio:device0/in_temp_input
Pressure      - /sys/devices/platform/soc/20804000.i2c/i2c-1/1-0077/iio:device0/in_pressure_input

The directories in red will probably be different in your system, if they are please post them. You will probably have to poke around a bit but the scheme should be similar.

In Node red I have two exec nodes:

1
cat /sys/devices/platform/soc/20804000.i2c/i2c-1/1-0077/iio:device0/in_temp_input
followed by a function node with:
msg.payload = parseFloat(msg.payload) / 1000;
return msg;
to return the actual temperature.

2
cat /sys/devices/platform/soc/20804000.i2c/i2c-1/1-0077/iio:device0/in_pressure_input
followed by a function node with:
msg.payload = parseFloat(msg.payload) * 10;
to return the actual pressure

followed by a function node with:
var sea = msg.payload * Math.pow((1.0 - (0.0065 * 175.0) / (16.0 + 0.0065 * 175.0 + 273.15)), -5.257);
msg.sea = sea;
return msg;
to convert the raw pressure to sea level pressure, which is what you see in weather reports.

I am still working on all of this, the blue numbers in the formula are height in meters for your location.
The red number is the temperature. I will be  rewriting this to use the sensor temperature and put everything in one function node and then into an array which could then be fed directly into a graph node.

Personally, I will be inserting everything into an Influxdb database and using Grafana for the graphs. I can thoroughly recommend this way of graphing data.

Here again is the link to the Device Tree documentation, with information how to configure a multitude of sensors:

This is also available on the Raspberry Pi in the file  /boot/overlays/README

Garry

Greg Hunt

unread,
Jan 6, 2018, 7:36:33 AM1/6/18
to node...@googlegroups.com
Brilliant - thanks for this Garry. I'll have a play later this afternoon and report back. 

At the moment I managed to create an Exec node to retrieve the temp and pressure using a Python script I downloaded from Github - which seems to be working pretty well. The payload is then routed to a standard Dashboard Graph to trend the temperature readings every minute, over a 24 hour period. However, the temp/pressure data is not being logged into a Database, so when I restart my Node-Red instance I lose all my historic data :-(

As recommended - I'm keen to insert everything into a Database and then pull and graph the data on my Dashboard. I need to do some more research on how to achieve this and not sure whether I can pull temp/pressure readings from a database and display using the standard Dashboard Graph flow.

Screenshot of my current dashboard - https://imgur.com/mPijNLs 

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/FyxAgaFAfrY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Dave C-J

unread,
Jan 6, 2018, 8:15:08 AM1/6/18
to node...@googlegroups.com
The top port on the chart node gives you the current state of the chart. You can save this however you wish.  Then reload it on start.  See https://github.com/node-red/node-red-dashboard/blob/master/Charts.md for some more info. And https://flows.nodered.org/flow/92920b4fd450bf92a3035e061947daa0 for an example
--
Sent from phone.
Message has been deleted

steve rickus

unread,
Jan 6, 2018, 11:20:21 AM1/6/18
to Node-RED
Garry, is there a particular reason for using an exec node to "cat" the file, instead of just using a file in node to get the contents?
I've not tried it, but I guess I'm just wondering if takes special techniques to read device/proc/system files...

Garry Hayne

unread,
Jan 6, 2018, 11:40:58 AM1/6/18
to Node-RED
Steve, to be honest I haven't tried it! ......................................just did, it works!
probably the better option, thank you!

Garry

Greg Hunt

unread,
Jan 6, 2018, 2:34:41 PM1/6/18
to node...@googlegroups.com
Thanks Dave - however this has been driving me mad all afternoon!! I managed to get the example flow working, but I tried to adapt the example to cater to my requirements i.e. temperature data is automatically saved to a .tmp file without the need to click a 'Save' button. Once the system is rebooted, I click a button to restore the data from the .tmp file.

Any ideas how I might achieve this!? If I had any hair, I'd have pulled it all out!!! :-)


 



--
Sent from phone.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/FyxAgaFAfrY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Greg Hunt

unread,
Jan 6, 2018, 3:09:21 PM1/6/18
to node...@googlegroups.com
Might help if I share a screenshot of my flow...


On 6 January 2018 at 13:14, Dave C-J <dce...@gmail.com> wrote:
--
Sent from phone.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/FyxAgaFAfrY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Greg Hunt

unread,
Jan 7, 2018, 10:52:06 AM1/7/18
to node...@googlegroups.com
Hi Garry,

I've made some progress over the last day or so - I've now managed to output the temperatures values to a data file and automatically populate the line graph, with historical data, when the Node-Red server is restarted.

I've installed SQLite and trying to figure out how to push the temp and time stamps into a table. I might park this and take a look at influxdb/grafana before I get too far down the SQLite road...

Thanks,
Greg



On 6 January 2018 at 15:18, Garry Hayne <garry...@gmail.com> wrote:
Hi Greg,

Lots of examples here on how to extract and display database values.

If you do decide to later move to influxdb/grafana here is an example of what is possible:

To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/c88aa2c2-4d9b-4000-8454-ddfd5b33b9d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/FyxAgaFAfrY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Greg Hunt

unread,
Jan 7, 2018, 12:36:12 PM1/7/18
to node...@googlegroups.com
@Garry - can you point me to a tutorial which details the install of InfluxDB and Grafana? The one I'm using errors on the first command!!

On 6 January 2018 at 15:18, Garry Hayne <garry...@gmail.com> wrote:
Hi Greg,

Lots of examples here on how to extract and display database values.

If you do decide to later move to influxdb/grafana here is an example of what is possible:

To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/c88aa2c2-4d9b-4000-8454-ddfd5b33b9d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/FyxAgaFAfrY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Greg Hunt

unread,
Jan 7, 2018, 12:41:33 PM1/7/18
to node...@googlegroups.com
ignore my last message - found this, which seems to be working so far!! https://gist.github.com/boseji/bb71910d43283a1b84ab200bcce43c26

Colin Law

unread,
Jan 7, 2018, 12:43:23 PM1/7/18
to node...@googlegroups.com
To install them you should just be able to do
sudo apt-get install influxdb grafana

Colin

On 7 January 2018 at 17:36, Greg Hunt <greg....@gmail.com> wrote:
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Garry Hayne

unread,
Jan 7, 2018, 12:46:09 PM1/7/18
to Node-RED

Greg Hunt

unread,
Jan 7, 2018, 1:09:07 PM1/7/18
to node...@googlegroups.com
Thanks Garry/Colin - looks like everything has successfully installed and I can connect Grafana to the InfluxDB. Next step - push data from Node-Red into the InfluxDB, then publish to a dashboard in Grafana...watch this space :-)

To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Julian Knight

unread,
Jan 8, 2018, 4:01:50 AM1/8/18
to Node-RED
Pushing data to InfluxDB is easy once you get your head around the structure of the data. It provides a REST interface so you can simply use the http-request node. There is a helper node but I don't use it personally.

If you are running on a Pi, you need to make sure you control the amount of data in your databases. While InfluxDB is better behaved on a 32bit OS with 1GB or less of RAM than MongoDB is, it will eventually keel over. I keep my detailed sensor data - 1/2 dozen or so devices with 3-4 sensors, updating every 50-60 sec - for 7 days. I use a continuous query to trim the details db and to accumulate hourly avg/max/min data. I've kept the summary data for a couple of years now and it is just now reaching some limit or another because I'm now seeing InfluxDB maxing out 1 core every few seconds. Time for a tidy out probably.

Graphana is amazing and you can do some incredible stuff with it - check out some of the addins that came in with the last major release.

Greg Hunt

unread,
Jan 11, 2018, 12:28:54 PM1/11/18
to Node-RED
So I've now got data being pushed from node-red -> Influxdb -> Granfana...hooray and thank you to all those who helped.

I'm still trying to get my head around the structure of the data and I would welcome some advice from the community on the best way to structure the data in InfluxDB. 

At them moment I have a number of Raspberry Pis around the house (Kitchen, Lounge, Garage, Hall, Bedroom) collecting the temperature from each room every 60 seconds, via an MQTT Broker/Server. Within Grafana I want to be able to chart the data of each room on a single graph, create Min/Max/Mean temps using the single stat option etc etc. Hopefully nothing too complex there!

Now, if I've understood it - there are two ways I can structure and collect this data in InfluxDB...see below. 

Any guidance on which the best approach would be appreciated...or possibly a solution 3 :-)

Solution 1:-

Database Name: TemperatureData
Measurement: Lounge
Value: 19.2

Database Name: TemperatureData
Measurement: Kitchen
Value: 19.2

Database Name: TemperatureData
Measurement: Hall
Value: 19.2

...

Solution 2:

Database Name: TemperatureData
Measurement: RoomTemperature
Tag: Lounge
Value: 19.2

Database Name: TemperatureData
Measurement: RoomTemperature
Tag: Kitchen
Value: 19.2

Database Name: TemperatureData
Measurement: RoomTemperature
Tag: Hall
Value: 19.2

...

steve rickus

unread,
Jan 11, 2018, 12:49:26 PM1/11/18
to Node-RED
I would want all my temperature readings in the same group of measurements, with tags like "building=House,floor=1,room=Kitchen" to differentiate when necessary. This way, I can aggregate readings across multiple levels (e.g. by floor or building).

Garry Hayne

unread,
Jan 11, 2018, 1:11:52 PM1/11/18
to Node-RED
The structure of my weather Database looks like this:

As all readings are being taken at the same time is makes sense to put them in one place. using a measurement for each value makes queries more complicated than they should be. Always aim to remove any redundant fields.

Garry

Greg Hunt

unread,
Jan 11, 2018, 2:13:39 PM1/11/18
to Node-RED
Thanks Garry and Steve. To keep things simple (for now) I've opted for Time | Room | Temperature ... i.e. RoomTemperature,Room={{topic}} Temperature={{payload}}
Reply all
Reply to author
Forward
0 new messages