MS5611-01BA Arduino library: first developments results

Last updated on Tue, 2012-02-21 11:45. Originally submitted by fabio on 2011-06-12 20:16.

I spent the last days working on the MS5611-01BA high resolution pressure sensor. I wrote an Arduino library for it which you can find on my bzr repository:

The library comes associated with a Processing visualization sketch which you can use to visualize a the readings coming from the sensor using a graphical tool.

The results I've got so fare are pretty good. Precision is about 0.02-0.03 mbar and altitude estimation resolution is about 10-15 cm. Relative measurement of altitude using the sensor looks very good but I'm still looking for a better approach on absolute altitude estimation.

In the video below you find an example of my initial developments.

AttachmentSize
Arduino 0.22 MS561101BA.zip141.04 KB

Ciao Fabio, Ho visto che

Submitted by Kylix (not verified) on Thu, 2012-05-03 21:31.

Ciao Fabio,

Ho visto che utilizzi il Logic Lever Converter per alimentare l'MS5611. C'è qualche problema se io l'alimentazione la prendo direttamente dal pin 3.3V dell'Arduino Uno?

Volevo dire Logic Level

Submitted by Kylix (not verified) on Thu, 2012-05-03 21:32.

Volevo dire Logic Level Converter

Non dovrebbe.. magari

Submitted by fabio on Fri, 2012-05-04 01:05.

Non dovrebbe.. magari aggiungici un condensatore grosso in parallelo vicino alla scheda breakout.. magari un elettrolitico da 10uF, giusto da esser sicuro di avere un'alimentazione pulita.

3.3V

Submitted by Kylix (not verified) on Fri, 2012-05-04 06:55.

Utilizzando i 3.3V dell'Arduino Uno devo disabilitare le resistenze pullup interne? (Ho letto da qualche parte ma non sono sicuro se è necessario o no).

Il condensatore elettrolitico come dovrei collegarlo? (sono un principiante nel campo dell'elettronica).

Grazie

Si, devi disabilitarle. Ma la

Submitted by fabio on Fri, 2012-05-04 11:18.

Si, devi disabilitarle. Ma la libreria in questa pagina le disabilita da sola.

Per la connessione, vedi immagine sotto:

Gli elettrolitici li conosco

Submitted by Kylix (not verified) on Fri, 2012-05-04 11:21.

Gli elettrolitici li conosco ... Quello che mi sfugge è: collegare il condensatore fra GND e 3.3V dell'Arduino?

Il capo positivo del

Submitted by fabio on Fri, 2012-05-04 11:23.

Il capo positivo del condensatore sul +3.3V positivo vicino alla breakout board e il capo negativo vicono al GND sulla breakout board.

MS5611 Sketch is working perfect

Submitted by Jürgen (not verified) on Wed, 2012-05-02 18:44.

Here is a Link to a working Sketch in the Arduino Forum:

http://arduino.cc/forum/index.php/topic,103377.0.html

Look at the posting from Leo and use his sketch, its working perfect :-)

Jürgen

Different MS5611

Submitted by Anonymous (not verified) on Fri, 2012-04-20 21:08.

After some trying the MS5611 gave quite good result. What I did NOT like were the absolute high values.

So I ordered a second MS5611 from another source.

Made a short test with Fabio's sketch today.

Arduino uno, LLC, 2 min run with sensor #1, then 2 min run with sensor #2.

Sensor #1:

temp: 22.48 degC pres: 975.18 mbar altitude: 185.71 m
temp: 22.50 degC pres: 975.18 mbar altitude: 185.72 m
temp: 22.47 degC pres: 975.19 mbar altitude: 185.69 m
temp: 22.49 degC pres: 975.18 mbar altitude: 185.73 m
temp: 22.49 degC pres: 975.18 mbar altitude: 185.73 m
temp: 22.49 degC pres: 975.17 mbar altitude: 185.80 m
temp: 22.49 degC pres: 975.17 mbar altitude: 185.81 m
temp: 22.49 degC pres: 975.18 mbar altitude: 185.80 m
temp: 22.49 degC pres: 975.18 mbar altitude: 185.76 m
temp: 22.48 degC pres: 975.18 mbar altitude: 185.77 m

Sensor #2:

temp: 22.59 degC pres: 991.57 mbar altitude: 41.22 m
temp: 22.60 degC pres: 991.58 mbar altitude: 41.15 m
temp: 22.60 degC pres: 991.58 mbar altitude: 41.10 m
temp: 22.60 degC pres: 991.58 mbar altitude: 41.11 m
temp: 22.61 degC pres: 991.58 mbar altitude: 41.10 m
temp: 22.59 degC pres: 991.58 mbar altitude: 41.10 m
temp: 22.60 degC pres: 991.58 mbar altitude: 41.11 m
temp: 22.60 degC pres: 991.59 mbar altitude: 41.05 m
temp: 22.60 degC pres: 991.59 mbar altitude: 41.04 m
temp: 22.60 degC pres: 991.59 mbar altitude: 41.01 m

Airport nearby 37 m above sea level reported QNH 996.3 mbar

(QNH = pressure calculated at sea level)

Seems to me, there a B quality sensors (or sensors with faulty calibration) around......

Me too, I have purchased 2

Submitted by Marco (not verified) on Mon, 2012-04-23 08:49.

Me too, I have purchased 2 sensors from Drotek and i've same results...
They are marked 5611ba but works only with old library.
The sensors works fine for 2/3 minutes and after seems be "crazy" and pressure reads change of 20/30 mbar.
They are unusable, I don't know why...
Marco

Different MS 56111

Submitted by Anonymous (not verified) on Sat, 2012-04-21 11:31.

I have wrong results with my Sensor too, the baro-readings changes with the temperature! Can you tell me which Fabios sketch you´ve used and if possible did you share the sketch with me.

My MS 5611 read this im moment: temp: 21.85 decC baro: 945.55 mbar

My wheater-station reads 959.51 mbar!

Jürgen

problemi con java

Submitted by Marco (not verified) on Tue, 2012-03-20 15:51.

Ciao Fabio,
sto cercando di provare sto sensore con le tue librerie ma non riesco a compilarlo con l'ide su Mac.
Mi da una serie di errori relativi alle librerie java.. non ho mai usato java con arduino...
Ho provato a installare la libreria java rxtx ma niente..
Secondo te cosa potrebbe essere
Marco, Torino

Yeah, I've got like all

Submitted by Joost (not verified) on Fri, 2012-03-16 02:22.

Yeah, I've got like all symptoms listed below.
I had got 2 pieces of droktek of the MS5607, I now have the MS5611's but the temperature as well as the pressure seem to jump around.

With the NEW library I got:
temp: 28.45 degC pres: 388.60 mbar
temp: 26.45 degC pres: 383.28 mbar
(These are combined results!)
+/- 2 degrees temperature jump.
+/- 5 mbar pressure jump.

With the OLD library I got:
temp: 24.81 degC pres: 1015.38 mbar
temp: 27.98 degC pres: 1020.79 mbar
temp: 29.69 degC pres: 1004.85 mbar
temp: 27.11 degC pres: 999.62 mbar
+/- 2 degrees temperature jump.
+/- 5 mbar pressure jump but now really unstable, ranging 20 mbar!?

I gradually heat them under my desk lamp, and shift the pressure in my mouth :) During changes, the results gradually go up or down as expected, but also jump up and down. Sometimes it stays "jumped" for minutes.

My physical barometer shows about 1021 mbar and 24 degrees.

Is the drotek board crap? they seem to be stamped according to the MS5611-01BA01 datasheet...

Sorry for the late reply..

Submitted by fabio on Wed, 2012-05-02 11:36.

Sorry for the late reply.. keeping up with all the comments on the website is very hard.

How are you powering the board? That's pretty unlikely that such noisy readings are caused by bad software.. so, I'd rather think this may be caused by some noisy power source or something similay.. I'd suggest adding some 10uF tantalum/electrolitic caps in parallel to the sensor power source or use a low noise voltage regulator as the MIC5203 used in FreeIMU.

I'm using an arduino pro mini

Submitted by Joost (not verified) on Fri, 2012-03-16 02:36.

I'm using an arduino pro mini 3.3v and arduino v1.0 software.
(wire.send = wire.write; wire.recieve = wire.read; WProgram.h = Arduino.h)
I've got 1 soldered as 0x77 (CSB_LOW) and 1 as 0x76 (CSB_HIGH)

I'm about to solder them back to back and update the library to handle them both. I've tried to get them working at my mbed (LPC1768) micro but didn't succeed yet. I'm also about to order different breakout's... will mail drotek (again as well)

argh.. :)

use with freeIMU 0.3.5MS

Submitted by raune (not verified) on Mon, 2012-03-12 10:35.

Hi Fabio,

can I use this with my 3.5MS? and the freeImu lib? - been trying to get some values out of the presure sensor but without success and this would be great as the relative value is all i really need.

regards,
raune

This code is already

Submitted by fabio on Tue, 2012-03-13 19:44.

This code is already available in the FreeIMU library. Look under the examples. Yes you can use it with FreeIMU v0.3.5_MS

Pressure accuracy

Submitted by freto (not verified) on Sun, 2012-02-26 12:21.

Same as some of the comments above. the absolute pressure value is wrong on the two sensors I bought.
I tried Fabio's library and then my own code (result matching the example on page 7 of the datasheet), but in fact the raw pressure is always around 6400000 instead of around 9000000 like it should be.
My simple test was posted here.

In this document from MEAS the calculation is different and result is closer to reality, but still the pressure is too low.

Problem solved

Submitted by freto (not verified) on Mon, 2012-02-27 13:29.

I found out with a microscope that the sensors I bought from drotek.fr are in fact MS5607 with 20cm accuracy sold under MS5611 names. Problem is solved using the equations in the proper datasheet.
Waist of time and money on this one!

Hehe, same supplier, same

Submitted by NelsonB (not verified) on Mon, 2012-02-27 14:11.

Hehe, same supplier, same mistake :)

I got the supplier this morning, he 'll send me the good reference once I send him back the bad ones.

Regards,
Nelson.

Absolute Pressure

Submitted by NelsonB (not verified) on Tue, 2012-02-21 11:39.

Hi!
Very nice work.
I recently moved from BMP085 to MS5611 in a personnal project.
I read absolute pressure not in line with the local meteo pressure.
Pressure variation seems good when I move the captor up and down, but I am not able to interpret the absolute value I compute from the sensor.

Did you find something on that point?

Best regards,

Nelson.

Yeah, there may be some bug

Submitted by fabio on Tue, 2012-02-21 11:45.

Yeah, there may be some bug in the library.. probably in the shifting part.. they also told me that the old version of the library for Arduino 022 worked just fine. Are you able to find the bug? I'm quite busy right now and can't work on it.

The old code is available from http://www.varesano.net/files/Arduino%200.22%20MS561101BA.zip

Well, 022 version doesn't

Submitted by NelsonB (not verified) on Tue, 2012-02-21 15:09.

Well, 022 version doesn't work better.
I have corrected a bug in your temperature computation, I now have a correct temperature measurement:
_TEMP = (int32_t) REF_TEMP_DEG + (((int64_t)_dT*_c6)>> 23);
I cast in 64bits the dt*c6 computation.

But it doesn't interfere in the absolute pressure computation. I have values in the range of 50000 for à current weather pressure of 1030 mBar.

If you have some infos on this subject, I can spend some time on it.

Best regards,

Nelson.

Got the 5607 instead of 5611

Submitted by NelsonB (not verified) on Mon, 2012-02-27 11:37.

My supplier made a mistake. I was using the 5607 with the datasheet of the 5611...
I should have the true 5611 by the end of the week.
Best regards,
Nelson.

I 'll check the 022 version,

Submitted by NelsonB (not verified) on Tue, 2012-02-21 14:49.

I 'll check the 022 version, thanks.

Library not usefull

Submitted by Jürgen (not verified) on Thu, 2011-08-04 09:52.

I use your library, but the pressure and temperature readings are not correct.

Example: Temp: 24.00 Pressure: 956.0 mbar!
BMP085 reads 972 mbar!

If i touch the sensor, the temp increase, then suddenly it jumps 2 decC
down, the baro-readings jumps too.

Did you see this too?

Not really.. it's working

Submitted by fabio on Thu, 2011-08-04 10:01.

Not really.. it's working pretty good here.

But there may be bugs of course.. if you are able to send improved code that would be great!

MS5611

Submitted by Ethan (not verified) on Sun, 2011-07-10 20:06.

Could someone please tell me where i can buy these sensors in small quantities (less than 5)? Major distributors such as digikey, mouser and farnell don't seem to carry these.

Same question, where can we

Submitted by Anonymous (not verified) on Sat, 2011-07-23 00:25.

Same question, where can we buy these MS5611 sensors !

According to Rob in one

Submitted by fabio on Sat, 2011-07-23 11:41.

According to Rob in one comment on another blog post:
1) USA: www.servoflo.com contact David Ezekiel david [at] servoflo [dot] com
2) EU: www.amsys.de contact Norbert Rauch vertrieb [at] amsys [dot] de
3) APAC: www.everestpacific.com contact Kenny Yip kenny [at] everestpacific [dot] com

Note that these are raw sensors distributors, so you won't get a handy breakout board but only the sensor which you'll have to solder by yourself. There are some sellers of MS5611 breakout boards, just google for that.

off calculation can overrun

Submitted by ala42 (not verified) on Sat, 2011-07-02 02:59.

Thanks for posting the code. There are some problems...
int64 off = _C[1] * pow(2,16) + (_C[3] * dT) / pow(2, 7);
The term _C[3] * dT is calculated in long and did overrun on my sensor, having _C[3] = 28699 and a dT of 150672. You have to cast dT to int64 to fix this problem.
Besided that, it is a very bad idea to use the pow function, as it forces the conversion of _C[1] and the result of _C[3] * dT to float. Floats have just 23 bit precision, so you loose 9 bits. Without these bits the calculation does not need to be in int64 at all.

powers of two in embedded code

Submitted by Anonymous (not verified) on Tue, 2012-02-21 18:04.

Just saw the recent comments and reread the thread. One common way of representing integer powers of two in a little more mnemonic way than typing the constant value but staying away from floats is with the shift operator.

pow(1,0) === (1<<0)
pow(2,1) === (1<<1)
pow(2,2) === (1<<2)
pow(2,7) === (1<<7)

Besides preserving bits shifts of constants get-precomputed by the compiler so there is no run time overhead like you get with pow() so this paradigm is useful in performance sensitive code as well.

If you need more bits cast the 1 before shifting.

pow(2,32) === (((int64) 1) << 32)

Yeah, this should be what we

Submitted by fabio on Tue, 2012-02-21 18:28.

Yeah, this should be what we have in the current code.. unfortunately it seems there is still some minor issue with the pressure computation.. probably some overflow or wrong shift... if anyone can help it would be awesome!

Changed doConversion

Submitted by Stephen Bishop (not verified) on Sun, 2012-04-15 16:36.

I have tried changing the doConversion method as it should be a UINT32 not a long. Also I wasn't sure that the original was certain to get the bytes in the correct order. It seems to help with the values. I think some extra casts should be used in the other calculations.

There is another odd behaviour I have noticed:
If you make repeated calls to get the raw temperature you get consistent values. But if you request raw temperature, then request raw pressure and then further requests to get the raw temp the temperature values are different compared to the initial reading by roughly:
912 for the 1st call after the pressure reading;
578 for the 2nd call after the pressure reading;
284 for the 3rd call after the pressure reading.
Which is perhaps roughly 4*256, 2*256, 1*256 in each case.
Bizarrely if you simply alternate temp and pressure readings it seems consistent.

uint32_t MS561101BA::doConversion(uint8_t command) {
  uint32_t conversion = 0;
  byte b; // SAB added b
  
  // see page 11 of the datasheet
  
  // initialize pressure conversion
  Wire.beginTransmission(_addr);
  Wire.send(command);
   Wire.endTransmission();
  
  delay(10); // the conversion will take a time <= 9.04 ms to have the output ready
    
  // start read sequence
  Wire.beginTransmission(_addr);
  Wire.send(0);
  Wire.endTransmission();
  
  Wire.beginTransmission(_addr);
   Wire.requestFrom(_addr, (uint8_t)  MS561101BA_D1D2_SIZE); //(uint8_t) 
  if (Wire.available() >= 3) {
   // conversion = (Wire.receive() * 65536) + (Wire.receive() * 256) + Wire.receive();
    conversion = 0L;
    b=0;
for (byte i = 0 ; i < 3 ; i++){       // SAB added loop to ensure sequence of I2C read and shifting
      b = Wire.receive();
   //   Serial.print(b,DEC);
   //   Serial.print("  ");
      conversion = (conversion << 8) | b ; // SAB added loop to ensure sequence of I2C read and shiting
   }
  }
  else {
    conversion = -1;
  }
   Wire.endTransmission(); //SAB added end transmission 
   // Serial.println(conversion);
  return conversion;
}

Thanks for your comments. Do

Submitted by fabio on Sat, 2011-07-02 10:39.

Thanks for your comments. Do you have a fixed code you could share?

No, not yet. These were just

Submitted by ala42 (not verified) on Sun, 2011-07-03 22:22.

No, not yet. These were just the problems I saw on my first test of the sonsor.
Saw a cold start problem now. The sensor changes the pressure readings in the first 500 seconds a lot, see
http://aeroquad.com/showthread.php?2657-New-MEPS-pressure-sensor-from-ST...
The calculated height changes by ~20m.
After the height peak, with rising sensor temperature the height drops, which looks a bit like the temperature based compensation does not work properly.
Did you see effects like this on your sensors ?

Yeah, I'm experiencing

Submitted by fabio on Sun, 2011-07-03 23:38.

Yeah, I'm experiencing something like this but it's quite shorter in time.. about 30 seconds of drifting.

Mix MS5611 and GPS altitude data with Kalman filter?

Submitted by zencuke (not verified) on Wed, 2011-06-15 18:10.

Would mixing the MS5611 data with GPS altimeter data using a Kalman filter help? That should at least give automatic correction for atmospheric pressure. That would work for me because my project needs a GPS for other reasons but other applications might find this an expensive solution. I often post process my data and sometimes I look up more accurate elevation data based on longitude/latitude using the NOAH web service. I think it is SOAP based. I downloaded the NOAA data-set and tried to compile their model once but couldn't get it to give the same results as the web page. It is too big for an Arduino anyway. I need a bigger processor. I should check in with the Maple project again.

Would mixing the MS5611 data

Submitted by fabio on Mon, 2011-06-20 11:23.

Would mixing the MS5611 data with GPS altimeter data using a Kalman filter help?

I think so. I'm actually thinking about some filtering with baro+accelerometer but this is still an idea.. nothing concrete yet.

Post new comment

The content of this field is kept private and will not be shown publicly.
If you have a personal or company website insert its address in the form http://www.example.com/ .
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <del> <img> <h2> <h3> <h4> <b> <video> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may insert videos with [video:URL]
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options