This is MEMS MS5803-01BA this device is a new generation of high resolution altimeter sensor which is integrated with serial peripheral interface (SPI) and i2C (two wire interface) bus interface. The MS5803-01BA-HE is a high endurance pad compare to MS580301BA version pressure sensor. This device is optimized for altimeters and variometers with altitude resolution at 10 centimeter. The sensor module includes a high linearity pressure sensor and ultra-low power 24 bit ΔΣ ADC with integrated coefficients. These pressure sensor provides precise digital 24 bit pressure and temperature value on a different operation on current consumption it has high resolution temperature output that provides an altimeter/thermometer function without any extra sensor connected. These pressure sensor can be hookup to any microcontroller because it has communication protocol that can be ease to implementation that does not need to program the internal registers in this device. As see the sensor it has an antimagnetic stainless covered with gel at the top the purpose of these gel is to have a water resistance feature that can submerge up to 100m. Pressure 10~100, and temperature of -40 * ~ +85 * Degree Celsius. These device can be used in mobile altimeter, barometer systems, computers, watches, variometers, dataloggers, and pad technology. Etc… For further details see the datasheet.
Required Components
- Arduino Microcontroller, NodeMCU, Teensy Board, TeensyDuino, ESP8266 12, 12E, ESP8266 NodeMCU, ESPDuino, ATMEGA328 16/12, ATMEGA32u4 16/8/ MHz, ESP8266, ATMEGA250 16 MHz, ATSAM3x8E, ATSAM21D, ATTINY85 16/8 MHz Note: The Diagram below is using NANO. (please refer to each MCU’s respective pin-outs)
- MS5803-01BA Pressure Sensor
- Jumper Wire / DuPont Wire
- Solder Less Breadboard
Optional if you are not using MS5803-01BA Module
- 0.1uF Electrolytic Capacitor
- 10k Ohms Resistor
- PCB Board
Wiring Guide
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
#include <Wire.h> #define Addr 0x77 //i2C Address unsigned long Coff[6], Ti = 0, Offi = 0, sense = 0; unsigned int data[3]; void setup() { Wire.begin(); //Set i2C Communication as Master Serial.begin(9600); //Set serial boud rate 9600 Serial.print("14CORE | MS5803 Test Code "); delay(4000); Serial.print("Reading Value from EEPROM"); Serial.print("........................."); for(int i = 0; i < 6; i++) //Read values from EPROM { Serial.print("Starting i2C Transmission"); Wire.beginTransmission(Addr); //Start i2C Transmission Wire.write(0xA2 + (2 * i)); //Select data registers Wire.endTransmission(); //Stop Transmission Wire.requestFrom(Addr, 2); //Request 2 bytes if(Wire.available() == 2) //Read 2 bytes { data[0] = Wire.read(); data[1] = Wire.read(); } Coff[i] = ((data[0] * 256) + data[1]); // Data convertion } delay(300); } void loop() { Wire.beginTransmission(Addr); // Start I2C Transmission Wire.write(0x1E); // Send reset command Wire.endTransmission(); // Stop I2C Transmission delay(500); Wire.beginTransmission(Addr); // Start I2C Transmission Wire.write(0x40); // Refresh pressure with the OSR = 256 Wire.endTransmission(); // Stop I2C Transmission delay(500); Wire.beginTransmission(Addr); // Start I2C Transmission Wire.write(0x00); // Select data register Wire.endTransmission(); //Stop I2C Transmission Wire.requestFrom(Addr, 3); //Set Request 3 bytes of data if(Wire.available() == 3) { data[0] = Wire.read(); data[1] = Wire.read(); data[2] = Wire.read(); } unsigned long ptemp = ((data[0] * 65536.0) + (data[1] * 256.0) + data[2]); //Set to Convert the data Wire.beginTransmission(Addr); // Start I2C Transmission Wire.write(0x50); // Refresh temperature with the OSR = 256 Wire.endTransmission(); // Stop I2C Transmission delay(500); Wire.beginTransmission(Addr); // Start I2C Transmission Wire.write(0x00); // Select data register Wire.endTransmission(); // Stop I2C Transmission Wire.requestFrom(Addr, 3); // Request 3 bytes of data if(Wire.available() == 3) // Read 3 bytes of data { data[0] = Wire.read(); data[1] = Wire.read(); data[2] = Wire.read(); } unsigned long tempData = ((data[0] * 65536.0) + (data[1] * 256.0) + data[2]); // Convert the data unsigned long dT = tempData- ((Coff[4] * 256)); // Difference between actual and reference temperature tempData = 2000 + (dT * (Coff[5] / pow(2, 23))); unsigned long long Off = Coff[1] * 65536 + (Coff[3] * dT) / 128; // Offset and Sensitivity calculation unsigned long long sens = Coff[0] * 32768 + (Coff[2] * dT) / 256; if(tempData< 2000) //Second order temperature and pressure compensation { Ti = (dT * dT) / (pow(2,31)); Offi = 5 * ((pow((tempData- 2000), 2))) / 2; sense = Offi / 2; if(tempData< - 1500) { Offi = Offi + 7 * ((pow((tempData+ 1500), 2))); sense = sense + 11 * ((pow((tempData+ 1500), 2))) / 2; } } else if(tempData>= 2000) { Ti = 0; Offi = 0; sense = 0; } tempData-= Ti; // Adjust temp, Off, sens based on 2nd order compensation Off -= Offi; sens -= sense; ptemp = (((ptemp * sens) / 2097152) - Off); // Convert the final raw data ptemp /= 32768.0; float pressure = ptemp / 100.0; float ctemp = tempData/ 100.0; float fTemp = ctemp * 1.8 + 32.0; /*************************** OUTPUT *****************************/ Serial.print("Temperature in Celsius > "); Serial.print(ctemp); Serial.println(" C"); Serial.print("Temperature in Fahrenheit > "); Serial.print(fTemp); Serial.println(" F"); Serial.print("Pressure > "); Serial.print(pressure); Serial.println(" mbar"); delay(500); } |
Downloads
- MS5803-01BA Datasheet | PDF
- Download MS5803 SparkFun Code Library with Source Code for Arduino | Zip
- Download MS5803 SparkFun Code Library with Source Code for Java | Zip
- Download MS5803 SparkFun Code Library with Source Code for Python | Zip