GithubHelp home page GithubHelp logo

alexh-name / bsec_bme680_linux Goto Github PK

View Code? Open in Web Editor NEW
86.0 86.0 48.0 58 KB

Read the BME680 sensor with the BSEC library on Linux (e.g. Raspberry Pi)

License: Other

C 90.44% Shell 9.56%
accuracy air air-quality bme680 bosch bsec-library calibration iaq linux raspberry-pi sensor

bsec_bme680_linux's People

Contributors

alexh-name avatar daimoniac avatar gfast2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bsec_bme680_linux's Issues

eCO2 always 0.00000000000

The value for eCO2 is always 0.0000000
The other values seem to look good.

When i run the make script I get an error related to eCO2

./make.sh: 25: cannot open patches/eCO2+bVOCe.diff: No such file

1.4.7.2 no compiling 'incompatible lalgobsec'

I'm trying to compile this with the current 1.4.7.2 update.
I altered the address to new folder name.
Altered the I2C address and the print output to a J_SON and added the new CO2 equivalent_ to the print output also.
Normal changes. The last version I used was 1.4.6.#

I have set for Armv6 PiZero as I'm using 32bit RaspbianOS, SECONDARY I2C
I'm compiling this on RaspberryPi Desktop for x86, but that shouldn't be a problem, it'll then be moved over once compiled.
It fails with

pi@PiLaptop:~/Desktop/BSEC Compile Zero/bsec_bme680_linux $ ./make.sh Compiling... /usr/bin/ld: skipping incompatible ./src/BSEC_1.4.7.2_Generic_Release_20190122/algo/bin/Normal_version/RaspberryPI/PiZero_ArmV6-32bits/libalgobsec.a when searching for -lalgobsec /usr/bin/ld: cannot find -lalgobsec collect2: error: ld returned 1 exit status

raspberrry pi 64 bsec library only actually furnished with BSEC_1.4.7.4 need a little port to work

bosch actually furnish only BSEC_1.4.7.4 version for raspberry native 64 bit raspian.
in this post :
https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/BME680-BSEC-Library-for-ARM64v8-elf64-littleaarch64/td-p/12977/page/2
You can get exemples and config directory from official bosch distro.
Your code do not download correctly the config file.
I workarround this point with using the static table furnished by bosch.
Replacing the config_load function by
memcpy((void *)config_buffer,(void *)bsec_config_iaq,sizeof(bsec_config_iaq));
return sizeof(bsec_config_iaq);
Where bsec_config_iaq are static data from bsec_serialized_configurations_iaq.c
make.sh must be adapted to add this file source.
You can close this point if bosch provide official version of raspberry pi 64 bits library.
Regards.

CO2 equiv

Is anyone getting any readings from the C02 equiv (or Breath) ?
I'm using a Pi Zero.

My IAQ is going through calibration (I've had it sat for an hour or so in a room, now I have a bottle of 90% propanone for the high IAQ calibration half hour as per the BSEC instructions.

While IAQ is now ramping up (still at level1 - calibration required)
CO2 is just 0.00 as though nothing is being return from the BSEC calcs.

P.S. @alexh-name both CO2 and Breath are in 'ppm' (from comment in bsec_datatypes.h)

IAQ drifting up continuously?

I've been running the code for the past few hours and now have an IAQ accuracy reading of "3". However, the IAQ value just keeps increasing and increasing -- I thought this was a percentage and it's now over 200?!

2018-12-02 01:43:45,[IAQ (3)]: 232.51,[T degC]: 24.33,[H %rH]: 41.66,[P hPa]: 980.55,[G Ohms]: 127678,[S]: 0
2018-12-02 01:43:48,[IAQ (3)]: 232.82,[T degC]: 24.33,[H %rH]: 41.67,[P hPa]: 980.55,[G Ohms]: 128070,[S]: 0
2018-12-02 01:43:51,[IAQ (3)]: 231.89,[T degC]: 24.33,[H %rH]: 41.68,[P hPa]: 980.53,[G Ohms]: 128861,[S]: 0
2018-12-02 01:43:54,[IAQ (3)]: 232.54,[T degC]: 24.32,[H %rH]: 41.69,[P hPa]: 980.49,[G Ohms]: 127972,[S]: 0
2018-12-02 01:43:57,[IAQ (3)]: 231.13,[T degC]: 24.32,[H %rH]: 41.69,[P hPa]: 980.53,[G Ohms]: 129260,[S]: 0
2018-12-02 01:44:00,[IAQ (3)]: 230.87,[T degC]: 24.32,[H %rH]: 41.70,[P hPa]: 980.51,[G Ohms]: 128762,[S]: 0

Questions about the set up

I am not a C programmer, so don't really know what I'm looking at, but have a few questions:

  1. Does your implementation poll for readings every 3 seconds because you have picked up the "generic_33v_3s_4d" config?
  2. After 4 days will it go to low power mode?
  3. Is your suggested implementation to start the loop (./bsec_bme680) and log the output to a file; then read the output into another programme that displays the results?

Thanks in advance

Charles

make does fail cause Bosch updated library to 1.4.8.0

Hi,
thanx for sharing your efforts.
Currently migrating to a new RasPi4. Wanted to use the newest soft.

In the meantime BOSCH went forward with its library to version 1.4.8.0.

  • Some files are on a different location:
    now: BSEC_1.4.8.0_Generic_Release/examples/bsec_iot_example/bme680.c
    now: BSEC_1.4.8.0_Generic_Release/examples/bsec_iot_example/bsec_integration.c
    now: BSEC_1.4.8.0_Generic_Release/examples/bsec_iot_example/bsec_integration.h

  • ARCH does distinguish now between "PiThree_ArmV6" (32bit?) and "PiThree_ArmV8" (64bit?) (directory is now "RaspberryPi")

Therefore the make.sh failes:

  • patch does fail
  • compile does fail

New versions

Hi, thanks for the example
FYI The latest BSEC library still has a bug reading high pressure but if you over write the files in the BSEC API directory with the latest BME680_driver files on github that issue is fixed
The latest BSEC adds another level to the include library path Normal/
and you have to copy bsec_datatypes.h and bsec_interface.h from /algo into /example to get it to compile

error compiling with makefile

I have the same error as a previous comment and made sure that my directories are correct:
"/usr/bin/ld: cannot find -lalgobsec"

I looked in the directories and couldn't even to find the file myself
/home/pi/BME680 for your source code and
/home/pi/src/BSEC_1.4.6.0_Generic_Release_20180323
/home/pi/src/BME680_driver-master

Air pressure issue

Hi,

I have several Bosch BME 280's and they are reprting pressure more or less ~1012.7 hPa and BME 680 with this build reporting [P hPa]: 770.07. Local meteo is reporting 1018.3 hPa at their station. Is this some difference with HW?

Sleep method in milliseconds

Hello,

thank you very much for your work but I found an error in your code.

/*

  • System specific implementation of sleep function
  • param[in] t_ms time in milliseconds
  • return none
    */
    void _sleep(uint32_t t_ms)
    {
    sleep(t_ms/1000);
    }

This method does not sleep at all. If the software want so sleep for 25ms for example 25/1000 is 0. And the sleep function uses seconds. You should replace sleep with usleep in microseconds and multiply with 1000.
void _sleep(uint32_t t_ms)
{
usleep(t_ms * 1000);
}

Kind regards

Alex

Question: Are you able to build this on Pi 4?

I stumbled upon this, thank you for your work!

Are you able to build this on a ArmV8 Ubuntu 20.04 (64bit) Raspberry Pi v4?

If not are there any steps you might recommend outside of https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/algobsec-for-raspberry-pi-3-running-Ubuntu-64-bit/m-p/16620/highlight/true#M4322

Found this forum post https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/General-questions-about-BME680/td-p/12399 and it doesn't look like outside the algos we're able to calculate the IAQ etc so my python library I'm using won't be able to access this information, but with your setup (or even their examples) you can! I believe I even found a python wrapper for your stuff.

Anyways any help would be appreciated as I would love to have these additional sensor readings (*calculations) available.

user_i2c_write: Remote I/O error

Hi,

I just followed the instructions to build the code, and all went well. I'm using a Raspberry Pi Zero. When running it, however, I get:

pi@pi0:~/bsec_bme680_linux $ ./bsec_bme680
user_i2c_write: Remote I/O error

Also happens if I sudo it. I can read values correctly using the Adafruit Python library.

Any ideas?

Compensate Pressure with sea level

Do you know if there is any way to implement the pressure compensation with the sea level?
Not sure if Bosch library has, but a lot of the BME280 python libraries have.

Strange sleep function

ts.tv_sec = 0;

Is there a reason this never sleeps more than a second?
This would be the more obvious code for that function, actually assigning something to the sleep seconds?

void _sleep(uint32_t t_ms)
{
  struct timespec ts;
  ts.tv_sec = t_ms / 1000;
  /* mod because nsec must be in the range 0 to 999999999 */
  ts.tv_nsec = (t_ms % 1000) * 1000000LL;
  nanosleep(&ts, NULL);
}

README should be added more info?

I have a clean Rasbian - My Hardware is BME680 Breakout from Pimorino.

I had to run Pimorino installer before you're nice software worked

bme680@raspberrypi:~ $ curl https://get.pimoroni.com/bme680 | bash

Before this, the BME680 wasn't detected in I2C (lsmod | grep i2c) after the Pimorino instal,l the BME680 was detected and you're software worked perfectly - maybe som more intro to get the software running? - or did I miss you're docs?

IAQ Binary reading

Hi,
Thanks for your work, i can make work the sensor with https://github.com/alexstocker/sensorlogger

i'm currently getting binary reading on the IAQ value, as shown below :

In the living room it's giving 0.00, as soon I expose it to alcohol it jumps to 500...
They is not much change in the resistance reading.

time IAQ, IAQ accuracy, raw temp, raw humidity, temp, humidity, pressure, resistance, status
2018-08-25T20:29:06Z 0.00 2 29.50 75.81 28.39 79.02 1011.51 56295 0
2018-08-25T20:29:12Z 0.00 2 29.52 76.43 28.41 80.23 1011.49 56220 0
2018-08-25T20:29:15Z 500.00 2 29.67 78.62 28.56 82.24 1011.53 53365 0
2018-08-25T20:29:18Z 500.00 2 29.64 79.20 28.53 83.30 1011.49 53162 0
2018-08-25T20:30:03Z 500.00 2 29.96 72.36 28.85 77.84 1011.53 54827 0
2018-08-25T20:30:06Z 500.00 2 29.92 71.16 28.81 76.54 1011.53 55478 0
2018-08-25T20:30:09Z 0.00 2 29.86 70.40 28.75 75.79 1011.51 55884 0
2018-08-25T20:30:12Z 0.00 2 29.82 70.00 28.71 75.35 1011.49 56637 0
2018-08-25T20:30:15Z 0.00 2 29.88 70.41 28.77 75.42 1011.53 55187 0
2018-08-25T20:30:18Z 0.00 2 29.79 71.41 28.68 76.73 1011.51 56258 0
2018-08-25T20:30:21Z 0.00 2 29.86 70.76 28.75 75.67 1011.49 53263 0
2018-08-25T20:30:24Z 500.00 2 30.31 76.77 29.20 80.37 1011.51 46800 0
2018-08-25T20:30:27Z 500.00 2 30.46 82.34 29.35 85.94 1011.57 47220 0

Any idea how to calibrate it to get linear feedback ?

eCo2 and bVOCe is always 0

Hi,

since the last updates of 2018 and 2019 he shows me no Air Quality value.
The version BSEC_1.4.6.0_Generic_Release_20180425 Unfortunately, the other version does not work for me. Compiling has worked for all versions.

Maybe they have an idea. Thanks for the great support

pi@raspberrypi:/var/homebridge $ ./bsec_bme680
bsec_iaq.state empty
2019-10-01 18:54:15,[IAQ (0)]: 25.00,[T degC]: 19.32,[H %rH]: 83.17,[P hPa]: 988.72,[G Ohms]: 344287,[S]: 0,[eCO2 ppm]: 0.00,[bVOCe ppm]: 0.00
2019-10-01 18:54:18,[IAQ (0)]: 25.00,[T degC]: 19.56,[H %rH]: 82.13,[P hPa]: 988.64,[G Ohms]: 458132,[S]: 0,[eCO2 ppm]: 0.00,[bVOCe ppm]: 0.00
2019-10-01 18:54:22,[IAQ (0)]: 25.00,[T degC]: 19.63,[H %rH]: 81.80,[P hPa]: 988.63,[G Ohms]: 483970,[S]: 0,[eCO2 ppm]: 0.00,[bVOCe ppm]: 0.00
2019-10-01 18:54:24,[IAQ (0)]: 25.00,[T degC]: 19.34,[H %rH]: 82.90,[P hPa]: 988.70,[G Ohms]: 460337,[S]: 0,[eCO2 ppm]: 0.00,[bVOCe ppm]: 0.00

Don‘t create bsec_iaq.state

Hello,
I have the problem that when completing the bsec_iaq.state is not generated. It should be created with or right? Completing with make.sh worked and the / bsec_bme680 outputs values.

In the make.config I had to adjust the directory BSEC_DIR accordingly.

pi@raspberrypi:~/bsec_bme680_linux $ ./make.sh
Compiling...
Compiled.
Copied config.

pi@raspberrypi:~/bsec_bme680_linux $ ./bsec_bme680
stat'ing binary file: No such file or directory
2018-08-15 23:03:54,[IAQ (0)]: 25.00,[T degC]: 24.83,[H %rH]: 48.86,[P hPa]: 1007.43,[G Ohms]: 77742,[S]: 0

pi@raspberrypi:/usr/src/BSEC_1.4.6.0_Generic_Release_20180425

I would be very happy about an answer. Unfortunately, I'm an absolute Linux beginner.

Humidity offset

In the file their is a way to apply an offset on the temperature, through
#define temp_offset
Is it possible to have the same to adjust humidity ?

I'm looking at calibrating humidity level, to have better precision on the AIQ calculation.

SPI comms for multiple sensors?

Hi Alex,
I'm looking to try and convert this to use the SPI interface with an end goal of using multiple sensors together and was wondering if you could provide any insight.

I am pretty new to programming(intro to C++ class), so any insight at all would be helpful.

I am currently looking to use the spidev library, unless there's any you'd recommend?

I am thinking i just need to swap out i2cOpen, i2cClose and i2cSetAddress, and their corresponding calls. I believe I am currently hung up on i2cSetAddress, specifically with if (ioctl(g_i2cFid, I2C_SLAVE, address) < 0)
not fully sure what the SPI equivalent of this would be, so any help would be appreciated. I'm mostly just replacing every instance of "i2c" with "spi" and hoping for the best though. (also, I set spi_address = 0.0, no clue if that's right or not)

I understand if you aren't able to help me, and I thank you for creating this program regardless!

bsec_bme680.txt
(made it a .txt just to upload it)

user_i2c_write: Remote I/O error

Hey,

excellent stuff, but I ran into the same problem as @Gfast2 in pull request #23. Except I spent an entire afternoon figuring it out myself, because I didn't look at the open pull requests.
Opening a new issue for more visibility until merged or otherwise fixed.

Thanks for sharing your work!

1.4.7.2 no compiling

I have a problem with compile

pi@raspberrypi:~/bsec_bme680_linux $ ./make.sh
Patching...
File /home/pi/homebridge-bme680/src/BSEC_1.4.7.2_Generic_Release_20190122/examples/ is not a regular file -- refusing to patch
2 out of 2 hunks ignored -- saving rejects to file /home/pi/homebridge-bme680/src/BSEC_1.4.7.2_Generic_Release_20190122/examples/.rej

The content of the .rej file:

--- bsec_integration.c
+++ bsec_integration.c
@@ -84,7 +84,7 @@
/* local macro definitions /
/
*********************************************************************************************************************/

-#define NUM_USED_OUTPUTS 8
+#define NUM_USED_OUTPUTS 10

/*********************************************************************************************************************/
/
global variable declarations */
@@ -135,6 +135,10 @@ static bsec_library_return_t bme680_bsec_update_subscription(float sample_rate)
requested_virtual_sensors[6].sample_rate = sample_rate;
requested_virtual_sensors[7].sensor_id = BSEC_OUTPUT_STATIC_IAQ;
requested_virtual_sensors[7].sample_rate = sample_rate;

  • requested_virtual_sensors[8].sensor_id = BSEC_OUTPUT_CO2_EQUIVALENT;

  • requested_virtual_sensors[8].sample_rate = sample_rate;

  • requested_virtual_sensors[9].sensor_id = BSEC_OUTPUT_BREATH_VOC_EQUIVALENT;

  • requested_virtual_sensors[9].sample_rate = sample_rate;

    /* Call bsec_update_subscription() to enable/disable the requested virtual sensors */
    status = bsec_update_subscription(requested_virtual_sensors, n_requested_virtual_sensors, required_sensor_settings,

What am I doing wrong?

Cant run bsec_bme680

every time I attempt to run my bsec_bme680 file, terminal closes instantly without any messages. I edited make.config so that the ARCH reflects the raspberry pi 3 instead of the zero since I'm using a pi3. not sure if I need to change the CONFIG path or not though. make.sh seems to work returning

Compiling...
Compiled.
Copied config.


(program exited with code: 0)
Press return to continue

no form of bsec_iaq.state is formed (unless its already somewhere else and I need to find it) although there is a bsec_iaq.config file formed by make.sh

compiling from new version of BSEC (1.4.7.1) yelds some errors

Hi i tried to compile the program using provided make.sh. There is new version of BSEC since last time sources were updated so I changed the path in make.config (from BSEC_1.4.6.0_Generic_Release_20180425 to BSEC_1.4.7.1_Generic_Release_20180907) and that was fine. But when I tried to run make.sh this didn't go well and ended quickly with errors I can't fix on my own.

Compiling...
./bsec_bme680.c: In function ‘main’:
./bsec_bme680.c:338:43: warning: passing argument 3 of ‘bsec_iot_loop’ from incompatible pointer type [-Wincompatible-pointer-types]
   bsec_iot_loop(_sleep, get_timestamp_us, output_ready, state_save, 10000);
                                           ^~~~~~~~~~~~
In file included from ./bsec_bme680.c:24:0:
./src/BSEC_1.4.7.1_Generic_Release_20180907/examples/bsec_integration.h:155:6: note: expected ‘output_ready_fct {aka void (*)(long long int,  float,  unsigned char,  float,  float,  float,  float,  float,  float,  enum <anonymous>,  float,  float,  float)}’ but argument is of type ‘void (*)(int64_t,  float,  uint8_t,  float,  float,  float,  float,  float,  float,  bsec_library_return_t) {aka void (*)(long long int,  float,  unsigned char,  float,  float,  float,  float,  float,  float,  enum <anonymous>)}’
 void bsec_iot_loop(sleep_fct sleep, get_timestamp_us_fct get_timestamp_us, output_ready_fct output_ready,
      ^~~~~~~~~~~~~
Compiled.
Copied config.

Since BOSCH don't keep the older versions of BSEC to download I could use some help with the newer sources. At the end it says 'Compiled' and bsec_bme680 file is there but when I run it there is no output. Even when I remove bsec_iaq.state file

EDIT
output_ready function in this newer version is expanded and expects a few extra parameters so i updated that according to bsec_integration.h:103 but no luck so far and no output as well.

EDIT2
It works. One i updated function output_ready

void output_ready(int64_t timestamp, float iaq, uint8_t iaq_accuracy,
so parameters are correct to the ones from bsec_integration header file everything works.

Compile error

I tried to compile your source code on a Raspberry Pi 3 and got the following error:
"/usr/bin/ld: cannot find -lalgobsec"

I used the following directories:

/home/pi/BME680 for your source code and
/home/pi/src/BSEC_1.4.5.1_Generic_Release_20171214 and
/home/pi/src/BME680_driver-master

What is wrong?

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.