BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Please add any feature requests for Flowcode version 7 here

Moderator: Benj

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Alan_37 »

Hi

I am playing with this Sensor and thought would be a nice new Component for Flowcode
this sensor is very cheap around $4 it comes in a break out board and it's
3 sensors in 1, Temperature Humidity & atmospheric Pressure
can even calculate Altitude with this sensor very nice :D :D

Ebay BME280
Attachments
BST-BME280_DS001-10.pdf
(1.84 MiB) Downloaded 595 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Benj »

Hello Alan,

I've made a start on this now, the device is quite complex so there's a lot to take in but I'll spend some time on it today and see where I end up.

For now I have managed to create a Pressure component for the MS5637 sensor which you may be interested in.

Please note for the component to work correctly you need to be using Flowcode v7.2 or later.

Simply copy the attached file into your "Flowcode 7\components" folder and restart Flowcode, the new component will then be available from the Sensors component category.
PressureSensor.fcpx
(3.08 KiB) Downloaded 452 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Benj »

Ok here is a go at the BME280 component. Again Flowcode 7.2 or later is required.

I've done some basic setup but by no means configure everything. I've exposed the low level read register and write register functions so you can play around with the various register settings if you need to.
PressureSensor_BME280.fcpx
(2.8 KiB) Downloaded 469 times
If you have a go with it then please let me know how you get on.

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Alan_37 »

Hi Benj

That is very good news , I will try it as soon as i find some time

will this work on the stm32 ?

Thanks very much

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Benj »

Hi Alan,
will this work on the stm32
It should do, though may be best to test first on a known working device just in case there are bugs lurking.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi Ben!

And work on arduino and pic16 fxx :D

I Will also order some and test...

Jorgen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Benj »

Sorry, just come to do some testing on these components and the properties had a bug where they weren't reacting correctly.

I had exposed properties from the cal_i2c1 component and then renamed the cal_i2c1 component to CAL_I2C so the property references were broken.

Anyway this is now fixed.
PressureSensor.fcpx
(3.08 KiB) Downloaded 457 times
PressureSensor_BME280.fcpx
(2.8 KiB) Downloaded 431 times

User avatar
JohnCrow
Valued Contributor
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 I2C/SPI Temperature Humidity & Pressure Sensor

Post by JohnCrow »

BME280 sensor BOB ordered. (Adafruit)

UK source http://skpang.co.uk/catalog/adafruit-bm ... -1447.html

Should be here for Friday, hopefully be able to test it at the weekend. :)
1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi John!

Sounds really exciting. I also bought one, but from Ebay. So it takes a little longer. hopefully it works, otherwise I buy one where you bougth yours.

Hope you Will share (as you always do) and or tell us your experience with this. Look foreward to hear. :D

Thanks in advance

Br

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Alan_37 »

Hi Ben

So I have had a very quick go with the BME280 Sensor what i have done is

Initialize -> Read HumidityFloat -> Float to string -> Send via RS323 , Same thing for the temperature and Pressure
but without initializing .

I can see the sensor on Address 0x76

But the results i am getting are a bit confusing please see pic .

Are these raw values from the sensor registers ?
Attachments
BME.png
(19.7 KiB) Downloaded 14599 times
Last edited by Alan_37 on Thu Apr 06, 2017 9:36 pm, edited 1 time in total.

User avatar
JohnCrow
Valued Contributor
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 I2C/SPI Temperature Humidity & Pressure Sensor

Post by JohnCrow »

The board is on its way, so should be here Fri or Sat. I've knocked up a quick FC program to read the 3 values in a loop and display them on the EB005 LCD Board

Will post my findings once tested.
1 in 10 people understand binary, the other one doesn't !

User avatar
JohnCrow
Valued Contributor
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 I2C/SPI Temperature Humidity & Pressure Sensor

Post by JohnCrow »

Hi Ben

The Adafruit board has a default Ic2 Address of 0x77, (0r 0x76 if SDO is connected to GND)

Can these address be added to the component please, as It currently on allows 0xEE or 0xEC

Thanks
1 in 10 people understand binary, the other one doesn't !

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Alan_37 »

Hi John , Good morning

I think that 0xEC is referring to address 0x76 , and 0xEE to Address 0x77 , let me explain

in order to communicate with a device via i2c we need 3 addresses , the main address of the device
for example 0x76 , when this address (1110110) is sent on the i2c bus the device with that address
reply with an Ack , this means that the device is present and ready to communicate with us .

Than for the 2 other addresses we use these to let the device know if we need to read or write
from or to the device . these 2 addresses are simply calculated as follows .

Example Main Device Address = 0x76 binary = 1110110
For the Write address simply add a binary 0 to the main Address -> 11101100 = 0xEC
For the Read address add a binary 1 to the main Address -> 11101101 = 0xED

Regarding the BME280 component if my calculations are right & the output are raw
register values , there are still work to be done cause this is a tiny but complicated sensor
we will need to read from other calibration and compensation registers to work out
the final values.

So i think this is not going to be a simple task but hey when there is a will there is a way :)


Regards

Alan C

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi all!

I have bought some BME280 but have not received them yet. I expect to get them this weekend.
Meanwhile I have tried to make a testprogram with Bens BME component.

Is there maybe here in a forum some that will look into the program and see if I've done it right, if not then correct it, I've used an Arduino Mega.

When I compile to hex, I see lot of warning?. As soon I receive the component and have done a test, I inform you :D

Best regard Jorgen
Attachments
BME280.fcfx
(14.64 KiB) Downloaded 302 times

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi all!
I have received my BME280 from Ebay. To be sure that it work, it made a test with this example: https://www.youtube.com/watch?v=NtdFibIuxsE. And it work fine, (But I prefer Flowcode)

When I test with my above att. program I get some strange value. I would be glad if somebody would look at my program to see if I have done it correct, or some more calculation needed, please. I am not able to do it, but I have at least done a try.

Best regard

Jorgen.

User avatar
JohnCrow
Valued Contributor
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 I2C/SPI Temperature Humidity & Pressure Sensor

Post by JohnCrow »

Hi Jorgen

You seem to be getting similar results to me.
My post above was where I got confused by the R/W bit.

I have both an Adafruit board and a Sparkfun Board
The Sparkfun has separate I2C and SPI connections, where as the Adafruit share the pins.

Adafruit has
SCK = I2C Clock
SDI = I2C Data

I have tried both boards on the Arduino Uno using both Adafruit and Sparkfun developed library's.
They both work fine even with the other manufacturers library, so I know the boards are fine.

I've just read an article in Elektor (July/August 2016) about this sensor being used with the Microbit.

It says When used in I2C Mode the SDO pin cannot be left floating.
If SDO is connected to GND it sets the I2C address to 0x76
If SDO is connected to Vin its sets the I2C address to 0x77
However, I didn't need to this on the Arduino to get it to work.
BME280 V1.fcfx
(9.42 KiB) Downloaded 329 times
This is my basic flowcode file
1 in 10 people understand binary, the other one doesn't !

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Benj »

Hello,

Thanks for trying this out and letting us know it's not quite right. I've re-done the component based on the Arduino library and hopefully it should work better now.

I'm a bit concerned that the component now uses signed 64-bit values which has potential to not work on different compilers. The AVR compiler should be fine and hopefully the others will be fine too.
PressureSensor_BME280.fcpx
(4.39 KiB) Downloaded 304 times
Let me know how you get on.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi Ben!

Thank´s Ben Make a try this evening. You hear......

Br Jorgen.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi Ben!

Sorry still not ok! When I test with my Arduino Mega2650 with your Component, FC7, still strange value in display.

If I test with John¨s program with Pic16f1937 Nothing work, only 0.00000 and 0.00000 and 0.00000 in the display. If I make a new loop and place 1sek flasher it the top of John´s loop it flash ok, so the config seem to be ok..

Br Jorgen

User avatar
JohnCrow
Valued Contributor
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 I2C/SPI Temperature Humidity & Pressure Sensor

Post by JohnCrow »

Hi

Loaded the new version of the component
When I try to run my program (or Jorgens) I get

http://www.matrixtsl.com
Errors when generating C source code:
BME280 V1.c : 1 : error : Too many arguments: PressureSensor_BME280::ReadTemperatureFloat
BME280 V1.c : 1307 : error : Too many arguments: PressureSensor_BME280::ReadTemperatureFloat

I also get a pop up box (crash)
Flowcode has encountered a problem from which it is unable to recover, please save your work and restart flowcode.
But it only does it the first time its run

But if I re-write a new flowchart, It compile and runs but I still get strange readings, or sometimes 0.00

Example
Address = 0xEE
Temperature = -139.828

Address = 0xEC
Temperature = 0.000
1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi Ben!

Something new concerning the BME2280, please.
I experience the same as John

Br Jorgen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by Benj »

Hello,

The compile errors are because the parameters for the ReadTemperatureFloat have changed. Go into any references to this macro in your project and click OK and the error should be resolved.

The 0,0,0 is worrying, I'll have another look and make sure I've not introduced an issue.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi Ben!

Maybe something from here you could use : http://educ8s.tv/arduino-bme280-weather-station/ I have tested the project, and it work. Maybe something useful from the library. Unfortunately I am not able to make the component.

And I still prefer to make a semilar project from FC7, maybe with more feature. :D

Br Jorgen

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: BME280 I2C/SPI Temperature Humidity & Pressure Sensor

Post by jgu1 »

Hi!

Friendly inquiry, does it end here. I have really looked forward to this component, please

Br Jorgen

User avatar
JohnCrow
Valued Contributor
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 I2C/SPI Temperature Humidity & Pressure Sensor

Post by JohnCrow »

Hi Jorgen

I've got a few ideas for it too, but I'm sure Ben will get it sorted eventually.
This component is only one of many things he will be working on, and as much I have a need for it, I appreciate it may not be something that a large amount of users will need, compared to other parts of Flowcode.

Ah well where did I put that Arduino sketch :D :lol:
1 in 10 people understand binary, the other one doesn't !

Post Reply