openxsensor with BMP280

Development & General Chat for the superb openxvario project.

Moderator: rainer

advancefly
Posts: 9
Joined: Sun Jan 24, 2016 9:45 am
Country: -

openxsensor with BMP280

Post by advancefly »

Hey Folks did anyone connect an BMP280 to the openxsensor instead of an BMP180? :shock:

mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

I think that BMP280 requires a different code.
Currently it is not supported by openXsensor but it could be added.
maisky
Posts: 20
Joined: Sun Jan 08, 2017 5:22 pm
Country: -

Re: openxsensor with BMP280

Post by maisky »

Hey friends of openxsensor,
I'm new here in this forum and I also searched for support for the BMP280.
But in the actual version (7?) i don't found any driver or option in config.h.
So I tried to adjust the driver, but I'm not a good software developer ( more hardware).
The driver works, but I've only tested it on the desktop, not on the plane.
Is there still any interest in it?
Can anyone check the code?
I think it is also possible to optimize the code.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

Thanks for your interest in openXsensor.
I support currently the code.
It could make sense to add bmp280 to the list of sensor because this sensor is cheaper than MS5611 and , I expect, more accurate than BMP180.

You can give me the code. I can have a look and try to integrate it into the next release of openXsensor.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

I just had a look at the datasheet of the BMP280 and I tried to add code to oXs in order to support this sensor.
Please find in attachment a draft version of oXs with my code.
I do not have a BMP280 sensor to test the code so there could be some bug (even if the code is greatly based on the code for BMP180).
At least, I do not get compilation errors.

Perhaps you can test this version.
Note : do not forget to adapt the config.h file in function of your setup.

Please note that this version contains also changes in order to support :
- JETI telemetry protocol
- an ads1115 ADC converter in order to get more accurate voltages conversion. This ADC converter can e.g. be connected to a differential analogic baro sensor like MPXV7002 in order to measure airspeed.
Attachments
openXsensor.rar
(227.51 KiB) Downloaded 353 times

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: openxsensor with BMP280

Post by jhsa »

mstrens wrote: - an ads1115 ADC converter in order to get more accurate voltages conversion.
Interesting ;)
Could this be used to also measure individual cells of a LiPo battery? If so, and as this communicates over I2C, we could parallel 2+ of them to read all 6 (or more) cells of a battery, or even different batteries?

Thanks

João

EDIT: They are quite small :) Many people would have problems soldering one of these, unless there are boards with them already :)
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

Currently, the code support only 1 ads1115 but it could be adapted in order to support up to 4.
Code can already calculate current (and consumption) if ads1115 is connected to a current sensor (which converting current into voltage).
Currently, code does not calculate individual voltage cells based on the different voltage. This could be added but it requires handling a lot of parameters in the config.h file.
Note : one ads1115 can provide up to 4 voltages measurement (less when measuring the difference between 2 pins).

Soldering is very easy because boards are available (e.g. on aliexpress.com ). They are very cheap (2 euro).
Note: code for ads1115 is not yet tested (I am waiting for a module from China). If someone has one and want to make test, he can send me feedback. I will fix bugs.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: openxsensor with BMP280

Post by jhsa »

Thanks aliexpress is a no no here in Germany. They charge a huge amount of money for postage :o

Anyway, if you will in the future support cells with these little chips I might get a few of them, and design a board that could take 2 or 3 of them. That would probably cover all the analog inputs we might need :)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

It is strange that they charge for Germany while it is free for Belgium.
Here link to what I can get when I search on aliexpress.

https://fr.aliexpress.com/item/16-Bit-I ... a2a5ef46e5
User avatar
Kilrah
Posts: 11107
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: openxsensor with BMP280

Post by Kilrah »

Aliexpress postage is up to the seller... I regularly buy small stuff with free shipping.
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: openxsensor with BMP280

Post by kalle123 »

Just ordered one ADS1115 from Aliexpress. $1.79. No charge for Germany.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: openxsensor with BMP280

Post by jhsa »

Kalle, would you please post the link? When I try to buy from them, they want always a stupid amount of money for the postage.. Maybe it changed..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
Kilrah
Posts: 11107
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: openxsensor with BMP280

Post by Kilrah »

Link is 3 posts above yours

$1.79, free shipping
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: openxsensor with BMP280

Post by jhsa »

ok, thanks.. Missed it

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: openxsensor with BMP280

Post by kalle123 »

Sorry, to late, João.

Lately I am ordering more with aliexpress than over china dealers at ebay.

Don't have to mess with paypal, if there is an issue ....
maisky
Posts: 20
Joined: Sun Jan 08, 2017 5:22 pm
Country: -

Re: openxsensor with BMP280

Post by maisky »

Many thanks mstrens for this fast answer.
Unfortunately your version is not working properly yet.
The read calibration data are not correct:
calibration data #1 = 0 error= 0
calibration data #2 = 13056 error= 0
calibration data #3 = 192 error= 0
calibration data #4 = 84 error= 0
calibration data #5 = 0 error= 0
calibration data #6 = 0 error= 0
calibration data #7 = 24576 error= 0
calibration data #8 = 1 error= 0
calibration data #9 = 65531 error= 0
calibration data #10 = 4942 error= 0
calibration data #11 = 2048 error= 0
calibration data #12 = 64 error= 64

correct calibration data of my BMP280:
calibration data #1 = 26768 error= 0
calibration data #2 = 25811 error= 0
calibration data #3 = 50 error= 0
calibration data #4 = 37866 error= 0
calibration data #5 = 54846 error= 0
calibration data #6 = 3024 error= 0
calibration data #7 = 5036 error= 0
calibration data #8 = 16 error= 0
calibration data #9 = 65529 error= 0
calibration data #10 = 15500 error= 0
calibration data #11 = 50936 error= 0
calibration data #12 = 6000 error= 0

I think the high and low byte are swapped. The start address of calibration data is 88 not AA(old BMP180 value).
You can take a look into my code (attached).
Sorry for my bad english, but I hope you understand me...
Attachments
openXsensor.zip
(218.26 KiB) Downloaded 361 times
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

You are right.
Here a new version with the corrections.
I also fixed another bug about the size of an array.
Thanks to test this new version.
Attachments
openXsensor.rar
(227.48 KiB) Downloaded 294 times
maisky
Posts: 20
Joined: Sun Jan 08, 2017 5:22 pm
Country: -

Re: openxsensor with BMP280

Post by maisky »

Hi mstrens, I have tested the new version.
The good news, reading of calibration data are correct.
But the adc_P and adc_T are all times 00.
I believe, the sensor is not started. in the setup routine I set:
I2c.write( BMP280_ADR , 0xF5 , (uint8_t)0 ) ; // t_sb = 0 ,IIR filter = 0
I2c.write( BMP280_ADR , 0xF4 , 0x2F ) ; // osrs_t = 001 , osrs_p = 011 (4*), mode = 11

I see another difference
your:
errorI2C = I2c.write( _addr , (uint8_t) 0xF7 , (uint8_t) 6) ; // read 6 bytes starting from register F7
// we should add a test on errorI2C
adc_P = I2c.receive() ;
adc_P <<= 8 ;
adc_P |= I2c.receive() ;
adc_P <<= 4 ;
adc_P |= I2c.receive() >> 4 ;

my:
if( ! I2c.read( BMP280_ADR, 0xF7, 3 )) { ; //read 3 bytes from the device starting from register F7 (presure); keep previous value in case of error
result = I2c.receive() ;
result <<= 8 ;
result |= I2c.receive() ;
result <<= 8 ;
result |= I2c.receive() ;
D1=result >> 4; // divide by 16 (20bit format)

I have modified your code to:
errorI2C = I2c.read( _addr , (uint8_t) 0xF7 , (uint8_t) 6) ; // read 6 bytes starting from register F7
// we should add a test on errorI2C
adc_P = I2c.receive() ;
adc_P <<= 8 ;
adc_P |= I2c.receive() ;
adc_P <<= 8 ;
adc_P |= I2c.receive() ;
adc_P >>= 4;
adc_T = I2c.receive() ;
adc_T <<= 8 ;
adc_T |= I2c.receive() ;
adc_T <<= 8 ;
adc_T |= I2c.receive() ;
adc_T >>= 4 ;

Now the adc_T, adc_P und t_fine are correckt.

results of your code (modified):
adc_T = 503760
t_fine= 118912

adc_P = 367948
rawPressure= 98688


results of my code:
D2 = 503792
t_fine= 118963

D1 = 367964
rawPressure= 985263825


Only the rawPressure is in a different range (10000 times smaller).
What is the right range of rawPressure?

Many thanks for your activities.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

Thanks for the feedback.

In the setup(), I have some code to start up the BMP280.
// write in register 0xF4 value 0x33 (it means oversampling temperature 1 X , oversampling pressure 8 X and normal mode = continue )
errorI2C = I2c.write( _addr , (uint8_t) 0xF4 , (uint8_t) 0x33 ) ;
// write in register 0xF5 value 0x00 (it means 0.5msec between sampling, no filter, I2C protocol )
errorI2C = I2c.write( _addr , (uint8_t) 0xF5 , (uint8_t) 0x00 ) ;

This seems me ok. In fact I try to configure the BMP in order to get a conversion every 20 msec (like with the MS5611).
So, I ask of 1 oversampling for temperature conversion (bits 7,6,5 = 001 ) and 8 oversampling for pressure (bits 4,3,2 = 100) . I want to run in normal mode in order to have continuous conversion (bits 1,0 = 11). So register F4 must be set with 0x33).

You are right again: it should be I2c.read ... (instead of I2c.write).
This should explain why you never got a T and P.

My other code with
adc_P = I2c.receive() ;
adc_P <<= 8 ;
adc_P |= I2c.receive() ;
adc_P <<= 4 ;
adc_P |= I2c.receive() >> 4 ;
should be OK. It should give the same result as your code.
I had expected that it would require less cpu instructions but I now see that it takes more flash memory. Probably that the compiler performs a good optimisation.
So I will you your code.

About rawPressure, it must be multiplied by 10000. It as a factor that I used in MS5611 version in order to increase the precision.
For BMP280, it will not really increase the precision (except the code before is adapted) but for uniformity between the diferent sensors it is better to apply this scale factor too.

In attachement my new version.
Attachments
openXsensor.rar
(227.48 KiB) Downloaded 256 times
maisky
Posts: 20
Joined: Sun Jan 08, 2017 5:22 pm
Country: -

Re: openxsensor with BMP280

Post by maisky »

Hi mstrens,
GREAT IT WORKS!!!
It sounds just like my version when I lift the vario.

Sorry, I have not seen the two lines to initialize the sensor.

Now we need people to test during the flight.
In Germany the weather is terrible now and much too cold for me ;)
If there is good weather, I will test the Vario in an EasyGlider (my airplane for all tests)

Many thanks
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

Fine that it works.
Thanks again for your support.
If you want, you can already get a good idea of the performance just going up and down in a stair.
That the way I check different versions of the program at the beginning.

If you have a ms5611 sensor, it should also be possible to connect it as vario2 and then compare the performance of the 2 types of sensor (looking at a log on the Tx or adding code in order to send debugging data to a PC).

Have fun.
maisky
Posts: 20
Joined: Sun Jan 08, 2017 5:22 pm
Country: -

Re: openxsensor with BMP280

Post by maisky »

Yes, today i got a sm5611 modul.
In the next days I will build a setup with both sensors.
Then I can play a bit at home with it.
I let you know what is the result of comparison.
It is possible to transmit two Vspeed simultaneously (without switching with PWM)?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

In Sport protocol (and some other), above version 5, oXs uses default settings to select which fields are transmitted.
So standard you do not get 2 Vspeed or 2 Alt simultaneously.
Still this can easily be solved.
In the config file you can ask to send fields TEST_1, TEST_2 (and if needed TEST3) as e.g. T1 and T2 using lines #define T1_SOURCE and #define T2_SOURCE.
Still those fields have to be filled with whatever you want.
Best is to fill them in the function calculateAllFields() defined at line 808 in file openXsensor.ino
I suggest that you connect the MS5611 to the I2C bus as vario2. This means that you have to connect the CE (chip enable) pin to VDD. So it gets automatically an I2C address 0x76. Do not forget to uncomment the line #define VARIO2.
Let line #define VSPEED_SOURCE FIRST_BARO so you will get Vspeed and ALt from BMP280 in usual telemetry fields.

Then, in order to get Vspeed and relative Alt from MS5611 as T1 and T2, you can add following code in calculateAllFields() function:

#if defined (VARIO) && ( defined (VARIO2) )
#define VARIO2_FIELDS_IN_TEST12
#ifdef VARIO2_FIELDS_IN_TEST12
test1.value = oXs_MS5611_2.varioData.climbRate.value ;
test1.available = oXs_MS5611_2.varioData.climbRate.available ;
test2.value = oXs_MS5611_2.varioData.relativeAlt.value ;
test2.available = oXs_MS5611_2.varioData.relativeAlt.available ;
#endif
#endif

In attachment I put a version that should do the job. Still I did not test it.
Attachments
openXsensor.rar
(227.48 KiB) Downloaded 230 times
onki
Posts: 40
Joined: Tue May 14, 2013 8:34 am
Country: -

Re: openxsensor with BMP280

Post by onki »

Hi,

I am new with with this project and a Jeti User.
Looking at the zip file I can't find a Jeti Ino File.
Is this still in progress or how do I need to modify the existing INO file to get this running with Jeti.
This would be great as I dream of a single sensor providing Vario, Current and GPS information.
My Current solution with GPSLogger2 and UniSens-E or LinkVario is a bit too expensive for some of my gliders.
Is there a board availabe to handle the sensors?

Best regards
Onki
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: openxsensor with BMP280

Post by kalle123 »

Onki, there is NO Jeti ino file. There is ONE ino file, and that is openXsensor.ino. That is the file, you load in the ide.

All configuration is done by making the settings in oXs_config.h. Description is in oXs_config_description.h.

Just had a look into oXs_config.h and right at the start THERE IS JETI!

// --------- 1 - Telemetry protocol ---------
#define PROTOCOL FRSKY_SPORT // select between FRSKY_SPORT , FRSKY_HUB , FRSKY_SPORT_HUB , MULTIPLEX , HOTT, JETI

to test with JETI, change that line to

// --------- 1 - Telemetry protocol ---------
#define PROTOCOL JETI // select between FRSKY_SPORT , FRSKY_HUB , FRSKY_SPORT_HUB , MULTIPLEX , HOTT, JETI

br KH (who has under oXs current, vario, voltage and gps under FrSky and MPX, but I don't have Jeti ;) )
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

Initially oXs had been developped for Frsky telemetry but it is supposed to support now JETI, MULTIPLEX and HOTT protocols.
It uses an Arduino pro mini (best is with AVR328P 5 V 16mhz). It cost less than 2 euro on aliexpress.com.
In order to get a vario, this module has to be connected to a board having a baro sensor. It can be a board with a MS5611 (probably the best one) or a BMP085, BMP180 (probably the less accurate) or a BMP280. There are different boards available on aliexpress.com for less than 7 euro. One of them is named gy-63.
If you want ultra fast reaction of the vario you can even take a board that combines the baro sensor with an IMU (acc+gyro) sensor. Those boards are named 10DOF and cost about 10 euro.
If you want to measure a current, you should add a component that convert the current in a voltage. oXs then convert this voltage back in a current measurement. You can find several components that achieve this conversion. The model depends on the max Amp that you want to measure.

oXs can also be connected to a gps module using a Ublox Neo-6 or Neo-7. I tested it with this
https://fr.aliexpress.com/item/Ublox-NE ... 0.0.Lj3dIG

So, for about 30 euro you can build a sensor with vario, current and GPS (and even voltages)

You can find general information on oXs here:
https://github.com/openXsensor/openXsensor
Still this site is not up to date.

You can find up to date info the file oXs_config_description.h included in the rar.
Please read this carrefully to understand all options.
You normally do not have to modifiy the files in the rar except the file oXs_config.h. This file has to be edited in order to fill your set up requirements.

Note : I did not yet got test results of using GPS with JETI protocol but if you got an issue with it I can solve them.

If you have more questions, just ask for.
AndreasD
Posts: 3
Joined: Sat May 14, 2016 11:54 am
Country: -

Re: openxsensor with BMP280

Post by AndreasD »

Does the AVR328P 3.3 V 8mhz have enough power to read a BMP280 and a analog input? If so, I could avoid using a level shifter for conecting the BMP280.

Best regards,
Andreas
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: openxsensor with BMP280

Post by mstrens »

Yes, there should be no issue if you just connect a bmp280 and measure some analog pins (for voltage/current).
It is mainly the IMU (MP6050 that requires more calculation power).
On the other side, if you use standard boards like arduino pro mini, you easily find cheap boards that contains all components needed for vario :3.3 volt regulator, level shifter and BMP280.
If you make your own pcb you can build a much smaller device and then it makes totally sense to use only 3.3V components.
AndreasD
Posts: 3
Joined: Sat May 14, 2016 11:54 am
Country: -

Re: openxsensor with BMP280

Post by AndreasD »

Thank you for your hint.
The boards with level shifer have been well hidden at Aliexpress. I just ordered some of these.

Best regards,
Andreas
maisky
Posts: 20
Joined: Sun Jan 08, 2017 5:22 pm
Country: -

Re: openxsensor with BMP280

Post by maisky »

Hi mstrens,
sorry for tho long silence, the construction of the test setup was a bit difficult.
I tried to use a cordless screwdriver with a belt pulley to raise and lower the sensor. To control the motor I used a ESC.
So I have a chance to synchronize the measurements (with additional FrSKY High precision Sensor).
The results are very interesting (see image)
I would say the MS5611 is the best, it has the lowest noise of all.
The BMP280 has the most noise and the FrSKY and the FrSKY is in the middle.
I think the BMP280 is also usable. Maybe you have to adjust the sensitivity slightly (I used the standard value 50).

Many thanks for your support
Attachments
compare_BMP280_MS5611_FrSKY.JPG

Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”