MS5803-14BA Pressure Sensor Hookup Guide
The MS5803-14BA is a pressure sensor with an I2C ("Wire") and SPI interface.
Pressure sensors measure the absolute pressure of the fluid around them. This includes air, water, and anything else that acts like a viscous fluid. Depending on how you interpret the data, you can determine altitude, water depth, or any other tasks that require an accurate pressure reading.
Covered in This Tutorial
We will show you how to connect this sensor to an Arduino microcontroller and use the included software library to get measurements out of the sensor. We'll also show you how to interpret the readings showing changes in altitude and water depth.
This part is easy to use. But before you start, we recommend the following background knowledge:
How to Solder: Through-Hole Soldering
Connecting the Hardware - I2C
In this example, we will communicate with the MS5803-14BA using the I2C interface.
The MS5803-14BA Breakout Board breaks out seven connections from the IC. We traditionally call these connections "pins" because they come from the pins on the IC, but they are actually holes that you can solder wires or header pins to.
We'll connect four of the seven pins on the board to your Arduino. The four pins you need are labeled GND, VCC, SCL, and SDA.
Connecting Headers to the Board
You can use any method you like to make your connections to the board. For this example, we'll solder on a seven-pin length of male-male header strip, and use male-female jumper wires to connect the MS5803-14BA to your Arduino.
Solder a 7-pin length of male-male header to the board. You can solder it to either side. The bottom is more useful for breadboards, and the top is more useful for jumper wires.
Connecting the Board to your Arduino
When you're done soldering, connect the GND, 3.3v, SDA, and SCL pins to your Arduino. Different Arduino models use different pins for the I2C interface; use the following chart to determine where to plug everything in.
IMPORTANT: Connect the power pins (3.3v and GND) ONLY to a 3.3V supply. Larger voltages will permanently damage the part. Note that because I2C uses open drain drivers, it is safe to connect the I2C pins (DA and CL) to an I2C port on a 5V microprocessor.
|MS5803-14BA label||Pin function||Arduino connection|
|3.3v||3.3V power supply||3.3V|
Any pin labeled SDA, or:
Any pin labeled SCL, or:
Once you have the MS5803-14BA connected to your Arduino, we're ready to play with the software.
Installing the Arduino Library
Libraries are collections of software functions geared towards a single purpose, such as communicating with a specific device. Arduino comes with a number of built-in libraries that help you do advanced tasks. We've written an Arduino library called SFE_MS5803_14BA_I2C that allows you to easily talk to the MS5803 sensor. This library is not included with the stock Arduino software, but don't worry, installing new libraries is easy.
1. Install the Arduino IDE
If you don't already have the Arduino IDE (Integrated Development Environment) installed, download the version for your system (Windows, Mac, Linux) from http://arduino.cc/en/Main/Software and install it following the instructions on that site.
If you need help installing the IDE, check out our tutorial.
2. Install the SFE_MS5803_14BA_I2C Library
User-installed libraries live in a "libraries" folder within your personal Arduino sketch folder. On Windows systems your personal sketch folder is located in "My Documents/Arduino". On Mac computers, it's "~/Documents/Arduino". On Linux it is usually "~/Arduino/sketchbook". Locate your personal Arduino sketch folder and open it so you can drag new files into it.
Now download the latest MS5803 software archive from this link: https://github.com/sparkfun/MS5803-14BA_Breakout/archive/master.zip. You can either save the file to your system and open it later, or open it directly.
(Note that you can find the .zip file for any Github repository by looking for the "Download ZIP" button on the main page:)
Open the .zip file you just downloaded. (On most systems you should be able to double-click it to show the included files.) Open the folder called "MS5803-14BA_Breakout-master", then "Libraries", then "Arduino". You should now see a folder called "SFE_MS5803_14BA_I2C". Drag the "SFE_MS5803_14BA_I2C" folder from the .zip folder into your personal Arduino sketch folder. If you get a warning that there is already a libraries folder there, that's fine. It just means you've already installed some libraries, which is great! Just tell your system to go ahead and overwrite them, which sounds alarming but will only add the new library to the existing folder.
That's it! Now restart the Arduino IDE and you should be ready to go.
If any of these instructions are unclear, you can find more detailed instructions in our installing an arduino library tutorial.
Running the Example sketches
Running the Example Sketch
The library you just installed includes an example sketch that show basic operation of the MS5803. This are designed to be a starting point for writing your own code.
After you install the library, run the Arduino IDE, and open the following menu item: File / Examples / SFE_MS5803_14BA / SFE_MS5803_14BA_I2C_demo.
(If you don't see this menu item, you may not have installed the library correctly, or didn't restart the Arduino IDE. Take another look at the library installation page to see if you missed any steps.)
When the example opens, upload it to your Arduino (remember to select the correct board type and serial port), and open the Serial Monitor to 9600 baud. You should see some diagnostic information (if it can't find the device, double check your hardware connections) followed by measurement readings.
Writing Your Own Sketches
The comments and code in the example sketch should get you started when writing your own sketches. In many cases you should be able to copy and paste the example code into your own sketch.