BME280 Pressure Sensor
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
Try the code for the component BME280_2.fcfx
For me it worked with PIC16F1829, PIC18F4550 and with Arduino Uno R3.
For me it worked with PIC16F1829, PIC18F4550 and with Arduino Uno R3.
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: BME280 Pressure Sensor
I hope to find the time this weekend to have an in depth look at your posts and try them again.
I've got all 3 of the devices you have used so should be able to get somewhere.
I've got all 3 of the devices you have used so should be able to get somewhere.
1 in 10 people understand binary, the other one doesn't !
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: BME280 Pressure Sensor
Here is our updated repo version, based on Bosch datasheet and all work done by Viki2000 - big thanks!
- Attachments
-
- PressureSensor_BME280.fcpx
- (4.98 KiB) Downloaded 286 times
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: BME280 Pressure Sensor
Hi Leigh!
Thank you. AS soon i get 10 min. off, I will test the component.
Br Jorgen
Thank you. AS soon i get 10 min. off, I will test the component.
Br Jorgen
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
@Leigh
OK, the error was due to the same GUID for your component and my component.
When you implemented the Compensation Integer and Float, did you do the Integer for Pressure, Humidity and Temperature as mentioned on datasheet page 23 and 50?
Or was it implemented only for Pressure?
I ask that because in the initial code made by Ben, was only integer for some, if I remember right.
And then for the float, did you implement it for all 3: temperature, humidity and pressure?
https://ae-bst.resource.bosch.com/media ... 001-11.pdf
OK, the error was due to the same GUID for your component and my component.
When you implemented the Compensation Integer and Float, did you do the Integer for Pressure, Humidity and Temperature as mentioned on datasheet page 23 and 50?
Or was it implemented only for Pressure?
I ask that because in the initial code made by Ben, was only integer for some, if I remember right.
And then for the float, did you implement it for all 3: temperature, humidity and pressure?
https://ae-bst.resource.bosch.com/media ... 001-11.pdf
Last edited by viki2000 on Wed Dec 06, 2017 11:08 am, edited 1 time in total.
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
OK, but I think it can be done also for temperature and humidity according with datasheet page 23, 49, 50.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: BME280 Pressure Sensor
OK, yes, thanks, it will be interesting to add it, but I'm not volunteering just at the moment
it's busy here in the office
it's busy here in the office
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
If I have time I will do it, but I cannot promise as we have to move our office soon, so a lot of preparing beside the normal work.
Here is one more thing related with Reset Macro.
The initial code written by Ben is next: But the datasheet on page 25 says: And the C code from CCS project has next line:
Then should not be the Reset Macro as follows?
If I try with your component or my component BME280 and apply soft reset with the Reset Macro, then nothing happens with the readings of temperature or humidity.
If I apply the soft reset with the modified Reset Macro as above, then right away the readings are 0 for all, temperature, humidity and pressure and it requires a new initialization in order to read again values.
So I guess the initial Reset Macro code with 0x1E is not right and the corrected one below with 0xE0 register and 0xB6 value is right.
Here is one more thing related with Reset Macro.
The initial code written by Ben is next: But the datasheet on page 25 says: And the C code from CCS project has next line:
Code: Select all
BME280WriteByte(0xE0, 0xB6);
If I apply the soft reset with the modified Reset Macro as above, then right away the readings are 0 for all, temperature, humidity and pressure and it requires a new initialization in order to read again values.
So I guess the initial Reset Macro code with 0x1E is not right and the corrected one below with 0xE0 register and 0xB6 value is right.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: BME280 Pressure Sensor
OK, thanks for that, it was on my list to check the reset due to your previous comment, looks like there is more to do.
Thanks, I'll fix the component
Edit: Fixed component attached - thanks!
Thanks, I'll fix the component
Edit: Fixed component attached - thanks!
- Attachments
-
- PressureSensor_BME280.fcpx
- (5.16 KiB) Downloaded 203 times
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
I have added the oversampling, mode, standby time normal mode and filter parameters to the component settings and works fine.
Then for Forced Mode I made a new Macro, but I am not sure if we have to add a small delay time instruction in that macro or not. I did not.
The Reset Macro is corrected as well.
I have some questions for which maybe you can provide some suggestions:
- Would it make sense to have some Macros able to let you to change the above settings on fly during run time?
I guess not, but I need your opinion.
Normally you set up the sensor in the beginning and you run with those settings.
If it is really necessary to change the settings on fly during run time, then I guess the provided I2C Write Register Macro can do it, but this is seldom case.
I am just afraid that if we add more Macros to the component, then the code becomes bigger and takes too much space from flash memory of the microcontroller.
What is your opinion?
- When you added the Property Compensation Integer and Float, how is the code working?
I mean, are both calculations Float and Integer active and you just choose one with a decision?
Or is it possible based on that Property Compensation Integer and Float to disable a part of the code as I do with click right Disable Icon?
I am just afraid that the code of the component becomes bigger and would be nice to have it smaller, but with the wanted functions and during compilation time to be reduced as needed depending what you have chosen to enable or disable as parts of code in program.
Is that possible?
I will add the Property Compensation Integer and Float later.
Then for Forced Mode I made a new Macro, but I am not sure if we have to add a small delay time instruction in that macro or not. I did not.
The Reset Macro is corrected as well.
I have some questions for which maybe you can provide some suggestions:
- Would it make sense to have some Macros able to let you to change the above settings on fly during run time?
I guess not, but I need your opinion.
Normally you set up the sensor in the beginning and you run with those settings.
If it is really necessary to change the settings on fly during run time, then I guess the provided I2C Write Register Macro can do it, but this is seldom case.
I am just afraid that if we add more Macros to the component, then the code becomes bigger and takes too much space from flash memory of the microcontroller.
What is your opinion?
- When you added the Property Compensation Integer and Float, how is the code working?
I mean, are both calculations Float and Integer active and you just choose one with a decision?
Or is it possible based on that Property Compensation Integer and Float to disable a part of the code as I do with click right Disable Icon?
I am just afraid that the code of the component becomes bigger and would be nice to have it smaller, but with the wanted functions and during compilation time to be reduced as needed depending what you have chosen to enable or disable as parts of code in program.
Is that possible?
I will add the Property Compensation Integer and Float later.
- Attachments
-
- BME280_3.fcpx
- (5.08 KiB) Downloaded 175 times
-
- BME280_3.fcfx
- (45.64 KiB) Downloaded 160 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: BME280 Pressure Sensor
Hi,
In view of all the work you have done, we have decided to release the source, so that we just have the one component for this.
So please use the attached, you can see how to do the property based code switching.
Might be easiest to merge your changes into this code, then we will use your modified version back into our repository, maintaining the GUID.
You will notice that for the Device Address I use the 7 bit 0x76/0x77, then shift in the actual read/write functions.
I prefer this way as the Address then matches the datasheet, and is the correct way of describing I2C device addresses.
Thanks,
Leigh
Edit: or use any techniques from mine into yours, and restore the original GUID from it, whichever is best for you
In view of all the work you have done, we have decided to release the source, so that we just have the one component for this.
So please use the attached, you can see how to do the property based code switching.
Might be easiest to merge your changes into this code, then we will use your modified version back into our repository, maintaining the GUID.
You will notice that for the Device Address I use the 7 bit 0x76/0x77, then shift in the actual read/write functions.
I prefer this way as the Address then matches the datasheet, and is the correct way of describing I2C device addresses.
Thanks,
Leigh
Edit: or use any techniques from mine into yours, and restore the original GUID from it, whichever is best for you
- Attachments
-
- Pressure_Sensor_BME280.fcfx
- (45.38 KiB) Downloaded 155 times
Last edited by LeighM on Wed Dec 06, 2017 9:21 pm, edited 1 time in total.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: BME280 Pressure Sensor
Hi viki2000,
I have not got a BME280 Pressure Sensor.
However I would like to personally thank you for the time and effort you have put in for all the testing/developing you have done.
Kind Regards
Martin
I have not got a BME280 Pressure Sensor.
However I would like to personally thank you for the time and effort you have put in for all the testing/developing you have done.
Kind Regards
Martin
Martin
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
Thank you for sharing the source code.
I will try to work on it when I have time.
1st observation that came into my mind today:
- For the Slave Address, instead of 0xEC and 0xEE, in order to show 0x76 and 0x77, I have used *2 and you have used <<1, which is the same, but shift left is faster and better.
- But in fact we do not need the above operations. It is enough to show in component properties 0x76 and 0x77 for the user and the assigned value to be in decimal 236 and 238. I have tried it out and it works like that. It is simpler. Actually in this way I have done it will all the other component properties exposed to the user as the oversampling properties. In this way we do not have to make any more calculations with Slave Address, neither shift left nor multiply by 2.
Below is the small change/merge between your component and what I have done yesterday. It works, I have tested it.
From my point of view next changes should be done/added:
- Integer Compensation also for Temperature and for Humidity.
- Eventually add Altitude calculation based on Sea Level Pressure.
- When there is a SPI BME280, then the code should be changed accordingly, perhaps a new component with 3 and 4 wire SPI.
- Test the final I2C BME280 with the “5.5 Recommended modes of operation” – datasheet page 17 onwards – and measure the consumption current as tinkerman did it here (http://tinkerman.cat/low-power-weather- ... 0-moteino/ )
I will try to work on it when I have time.
1st observation that came into my mind today:
- For the Slave Address, instead of 0xEC and 0xEE, in order to show 0x76 and 0x77, I have used *2 and you have used <<1, which is the same, but shift left is faster and better.
- But in fact we do not need the above operations. It is enough to show in component properties 0x76 and 0x77 for the user and the assigned value to be in decimal 236 and 238. I have tried it out and it works like that. It is simpler. Actually in this way I have done it will all the other component properties exposed to the user as the oversampling properties. In this way we do not have to make any more calculations with Slave Address, neither shift left nor multiply by 2.
Below is the small change/merge between your component and what I have done yesterday. It works, I have tested it.
From my point of view next changes should be done/added:
- Integer Compensation also for Temperature and for Humidity.
- Eventually add Altitude calculation based on Sea Level Pressure.
- When there is a SPI BME280, then the code should be changed accordingly, perhaps a new component with 3 and 4 wire SPI.
- Test the final I2C BME280 with the “5.5 Recommended modes of operation” – datasheet page 17 onwards – and measure the consumption current as tinkerman did it here (http://tinkerman.cat/low-power-weather- ... 0-moteino/ )
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: BME280 Pressure Sensor
Hi viki2000
Thanks for that. Yes you are right about using the "fixed list of integers" in that way to save processing the shift - good spot!
My property started out as a free entry field integer, but as the addresses are fixed for this device, I changed to a fixed list.
I'll put this back into our repo and hopefully get some time to progress your other suggestions at some point.
Regards,
Leigh
Thanks for that. Yes you are right about using the "fixed list of integers" in that way to save processing the shift - good spot!
My property started out as a free entry field integer, but as the addresses are fixed for this device, I changed to a fixed list.
I'll put this back into our repo and hopefully get some time to progress your other suggestions at some point.
Regards,
Leigh
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
I have added:
- Integer Compensation also for Temperature and for Humidity.
- Altitude calculation based on Sea Level Pressure based on formula from sensor Bosch BMP180 - datasheet page 16:
https://ae-bst.resource.bosch.com/media ... 00-121.pdf
It remains to test the current consumption in the datasheet page 17 onward “5.5 Recommended modes of operation”, maybe during the next days.
The part with SPI remains for you guys to develop it, as I do not have such component and the I2C one is good enough for me for the time being.
Please check it, test it, make the changes that you consider necessary and then you may release it officially.
For me it works as it is here.
The icon used is from here:
http://www.iconarchive.com/show/ios7-ic ... -icon.html
The source code and the component are here:
- Integer Compensation also for Temperature and for Humidity.
- Altitude calculation based on Sea Level Pressure based on formula from sensor Bosch BMP180 - datasheet page 16:
https://ae-bst.resource.bosch.com/media ... 00-121.pdf
It remains to test the current consumption in the datasheet page 17 onward “5.5 Recommended modes of operation”, maybe during the next days.
The part with SPI remains for you guys to develop it, as I do not have such component and the I2C one is good enough for me for the time being.
Please check it, test it, make the changes that you consider necessary and then you may release it officially.
For me it works as it is here.
The icon used is from here:
http://www.iconarchive.com/show/ios7-ic ... -icon.html
The source code and the component are here:
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: BME280 Pressure Sensor
Here are few more observations.
The altitude calculation is a crap. I would take it out of the component macro.
I have the sensor on my table and it changes too much. I had values as 70m, then in another day 116m and today 250m – and all that without any change in the software/calculation or hardware. Of course today was 1st real snow and the atmospheric pressure changed over the night. The change of calculated altitude is too high for the same point. Either I do something wrong in calculation or we can just not relay on it due to the way how is calculated based on pressure.
Then I made some current consumption measurements according with the datasheet.
Unfortunately I cannot get the same values as in the datasheet, I guess because my BME280 sensor is mounted on a small break board where other more components are installed, probably including a voltage regulator, capacitors, resistors and the values from datasheet refer strictly to the senor.
In my case I measure the current at VDD of the break board.
The values of the current consumption are:
- In sleep mode around 6.5-7.5uA, then in forced mode when it wakes up for burst measurements the current goes up to 750uA.
- In normal mode, it depends by the standby time, but with 0.5ms I have 750uA for normal operation and 1.4-1.5mA during measurements. I did not measure exactly the duration of the measurements with the oscilloscope, but seems less than 0.5s – visually seen on the multimeter.
- From my point of view 7uA in sleep mode and 750uA during measurements is good enough for portable application, if we set the sample rate of the measurements let’s say 1min or more.
My I2C BME280 can be seen below:
The altitude calculation is a crap. I would take it out of the component macro.
I have the sensor on my table and it changes too much. I had values as 70m, then in another day 116m and today 250m – and all that without any change in the software/calculation or hardware. Of course today was 1st real snow and the atmospheric pressure changed over the night. The change of calculated altitude is too high for the same point. Either I do something wrong in calculation or we can just not relay on it due to the way how is calculated based on pressure.
Then I made some current consumption measurements according with the datasheet.
Unfortunately I cannot get the same values as in the datasheet, I guess because my BME280 sensor is mounted on a small break board where other more components are installed, probably including a voltage regulator, capacitors, resistors and the values from datasheet refer strictly to the senor.
In my case I measure the current at VDD of the break board.
The values of the current consumption are:
- In sleep mode around 6.5-7.5uA, then in forced mode when it wakes up for burst measurements the current goes up to 750uA.
- In normal mode, it depends by the standby time, but with 0.5ms I have 750uA for normal operation and 1.4-1.5mA during measurements. I did not measure exactly the duration of the measurements with the oscilloscope, but seems less than 0.5s – visually seen on the multimeter.
- From my point of view 7uA in sleep mode and 750uA during measurements is good enough for portable application, if we set the sample rate of the measurements let’s say 1min or more.
My I2C BME280 can be seen below:
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: BME280 Pressure Sensor
Hi viki2000
Oh, OK, message received, I will remove the altitude.
Thanks for all your testing.
Leigh
edit:
updated attached
Oh, OK, message received, I will remove the altitude.
Thanks for all your testing.
Leigh
edit:
updated attached
- Attachments
-
- Pressure_Sensor_BME280.fcfx
- (51.75 KiB) Downloaded 193 times
-
- PressureSensor_BME280.fcpx
- (6.32 KiB) Downloaded 173 times