Bog Standard BME

Hi folks,
I’m looking for basic, bog standard, no internet connection no bluetooth or wi-fi data logger for the BME680 pimoroni breakout board. Save as a text file .csv, anything really
I’d be delighted if someone could explain to me how to achieve this.
ta

Thats one thing I haven’t done is save my readings in a data base. So I’ll tag along and see what gets posted. So far I’ve been content with knowing what the current actuals are. If there was one thing I’d like to track its barometric pressure to see if its rising or falling.

Great, it seems to be very low on everybodies wish list! can’t find anything anywhere and don’t have the know how to resolve!

Yeah, I just show mine in a continuously scrolling message that just repeats over and over, updating the readings in real time. Nothing ever gets saved anywhere though. Shutdown or reboot and it just starts over with the current values. Knowing what the trends are, rising or lowering might be nice.

Afternoon,

Here is what I use to log variables from an enviro-pHAT to a csv file.

It’s very basic but should give you a jumping off point:

#!/usr/bin/env python

import csv
from datetime import datetime
from envirophat import weather

strTime = datetime.now()
strTime = strTime.replace(microsecond=0)

intTemp = round(weather.temperature(), 2)

csvWrite = strTime, intTemp
csvFile = open('TimeAndTemp.csv', 'a')

with csvFile:
        writer = csv.writer(csvFile)
        writer.writerow(csvWrite)

It takes ‘strTime’ as a variable and strips off the mlliseconds.

It rounds the ‘intTemp’ to two decimal places.

Takes both of those and writes them to ‘TimeAndTemp.csv’

A cron job runs this every 10 minutes.

After that you can graph it, post it to a web page etc.

Hope that helps someone.

Simon.

Thanks for that, and the detailed explanation of what you did. It may come in handy when I sort out exactly what I want to do.

Hi anon83280986,

Thanks very much for that, few days without access at the moment but i’ll give it a go in the next few days and get back to you.
really appreciate you taking the time
gbar

Hi,
I’m trying to use the example by Pimoroni indoor-air-quality.py and log it. Perhaps tellingly i’ve never managed to get their example to work :-

python read-all.py > bme680-data.txt

I’ve tried to just to get a readout of ‘gas’ at the moment. As in your example i’ve added the line
import csv
at the top of the program after import bme680 and import time

i then add the following onto the exmaple
csvWrite = gas
csvFile = open(‘gas.csv’ , ‘a’)

with csvFile:
writer = csv.writer(csvFile)
writer.writerow(csvWrite)

My pi doesn’t like this and points to the first csv line as shown bellow :-

csvWrite = gas
^
any thoughts?
ta

Sorry for the delay in getting back here.

The command:

python read-all.py > bme680-data.txt

Will take the output of read-all.py and send it to the file bme680-data.txt
(I’m pretty sure that’s what it does.)

That breakout uses a different library to the EnviroPhat one, I’d start with something simple like:

#!/usr/bin/env python

import bme680
import csv

intGas = sensor.data.gas_resistance

csvWrite = intGas
csvFile = open(‘gas.csv’, ‘a’)

with csvFile:
writer = csv.writer(csvFile)
writer.writerow(csvWrite)

(The above is pseudo-code and will probably not work without some tweaking.)

A couple of things:

  • The file gas.csv has to exist, it can be an empty file to start with, the ‘a’ after the file name means ‘append’.
  • The error you got doesn’t necessarily mean that is the line number where the error resides, I’d check your indentation first.

Hope that helps,

Simon.

Hi,

sorry for my late reply…4yrs!
oops. where did the time go!
Can’t even get the code to run now? lost in the mists of time like dinosaur names and such like.
How do you enter the I2C address into the sample code? it’s not liking my attempts…

#!/usr/bin/env python

import bme680
import time

print(“”"read-all.py - Displays temperature, pressure, humidity, and gas.

Press Ctrl+C to exit!

“”")

try:
sensor = bme680.BME680(bme680.I2C 0x76)


#!/usr/bin/env python

import bme680
import time

print(“”"read-all.py - Displays temperature, pressure, humidity, and gas.

Press Ctrl+C to exit!

“”")

try:
sensor = bme680.BME680(bme680.I2C 0x76)