Using MS5611 pressure sensor with SPI protocol

Hello,

I have an MS5611 sensor with GY-63 breakout board. On many websites it is listed that it can be operated with an SPI as well as an I2C interface.

Here for example.

I can find many tutorials and sample codes to use it with I2C, but I need to use it with SPI, as I’ve read that SPI is faster, and can provide a higher sampling rate.

Is there anyone who has had experience with MS5611 with SPI? How do I use it?

As you didn't specify otherwise I expect you to use an Arduino UNO. The UNO works at 5V so to work with this 3.3V device you have to use a level converter (at least for the SPI interface, the I2C interface may work without it).

Provide schematics for your module! It looks like it includes a voltage regulator, decoupling capacitor and the I2C pull-ups. If this guess is correct you have to modify the board to use SPI (remove the pull-ups). The PS line has to be pulled low, SDI is MOSI, SDO is MISO and SCKL is SCKL.CSB is the chip select line, choose an appropriate GPIO on the Arduino.

but I need to use it with SPI, as I've read that SPI is faster, and can provide a higher sampling rate.

No, it cannot provide a higher sampling rate, just a higher read out rate. The sampling rate is limited to 2kHz by the chip internals (at the lowest accuracy) and you should be able to read at about that rate with I2C. What kind of pressure are you trying to read that needs such a high sampling rate?

Thanks for your reply @pylon.

Yes, sorry, I’m using an Arduino UNO.

I’m using the chip for a quadcopter we’re working on, and it needs an Altitude Hold mode. Anyway, I didn’t know the sampling rate is as high as 2kHz. Wouldn’t need that much so I think I2C will do fine and I’ll go with it.

Since you mentioned lowest accuracy, how do I increase accuracy? If the sampling rate isn’t very low at high accuracies, the trade off will be definitely worth it.

Also, can you mention the source for your information?

Thanks.

Also, can you mention the source for your information?

The datasheet of the chip.

There you also can find the information of how to change the oversampling rate but with the highest accuracy the sampling rate decreases to about 100Hz. I guess this is more than enough for a quadrocopter altitude hold mode.

Cool, thanks!

Here is a link to arduino mega code, for APM2.8, that reads the MS5611 temperature and pressure, via SPI.

Link: https://github.com/rwsenser/APMhelpers/ then download via zip and take ReadAPMbaroMS5611.ino

This is a standalone sketch that shows the steps needed to use SPI with the MS5611 in an APM 2.8. It has been tested on a single APM -- but the values it shows are correct for central Colorado, USA.

Perhaps this will be useful as there do not seem to be many (any?) working MS5611 libraries that utilize SPI.

Thx,
RW Senser