Demo program to connect to MS5803-14BA Pressure Sensor with an I2C connection.

Dependencies:   MS5803 mbed

Fork of MS5803-Demo by Raig Kaufer

Committer:
Raig
Date:
Sat Apr 07 14:18:42 2012 +0000
Revision:
0:f0809a7877ff
Child:
1:607dbba0562f
Demo of MS5803 barometer sensor. Dont forget the pull up resistors of 10kOhm on the SDA and SCL lines!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Raig 0:f0809a7877ff 1 /*
Raig 0:f0809a7877ff 2 Permission is hereby granted, free of charge, to any person obtaining a copy
Raig 0:f0809a7877ff 3 of this software and associated documentation files (the "Software"), to deal
Raig 0:f0809a7877ff 4 in the Software without restriction, including without limitation the rights
Raig 0:f0809a7877ff 5 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Raig 0:f0809a7877ff 6 copies of the Software, and to permit persons to whom the Software is
Raig 0:f0809a7877ff 7 furnished to do so, subject to the following conditions:
Raig 0:f0809a7877ff 8
Raig 0:f0809a7877ff 9 The above copyright notice and this permission notice shall be included in
Raig 0:f0809a7877ff 10 all copies or substantial portions of the Software.
Raig 0:f0809a7877ff 11
Raig 0:f0809a7877ff 12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Raig 0:f0809a7877ff 13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Raig 0:f0809a7877ff 14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Raig 0:f0809a7877ff 15 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Raig 0:f0809a7877ff 16 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Raig 0:f0809a7877ff 17 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Raig 0:f0809a7877ff 18 THE SOFTWARE.
Raig 0:f0809a7877ff 19
Raig 0:f0809a7877ff 20 * Demo Program
Raig 0:f0809a7877ff 21 * Barometer Sensor (Altimeter) MS5803-01BA of MEAS Switzerland (www.meas-spec.com).
Raig 0:f0809a7877ff 22 * The driver uses I2C mode (sensor PS pin low).
Raig 0:f0809a7877ff 23 * Other types of MEAS are compatible but not tested.
Raig 0:f0809a7877ff 24 * Written by Raig Kaufer distribute freely!
Raig 0:f0809a7877ff 25 */
Raig 0:f0809a7877ff 26
Raig 0:f0809a7877ff 27 #include "mbed.h"
Raig 0:f0809a7877ff 28 #include "MS5803.h"
Raig 0:f0809a7877ff 29 #include "USBSerial.h"
Raig 0:f0809a7877ff 30
Raig 0:f0809a7877ff 31 #define debug
Raig 0:f0809a7877ff 32 #ifdef debug
Raig 0:f0809a7877ff 33 USBSerial serial;
Raig 0:f0809a7877ff 34 Serial pc(USBTX, USBRX);
Raig 0:f0809a7877ff 35 #endif
Raig 0:f0809a7877ff 36
Raig 0:f0809a7877ff 37 MS5803 press_sensor( p9, p10, ms5803_base_addr ); // sda, scl, I2C_address 0x76 or 0x77 look at MS5803.h
Raig 0:f0809a7877ff 38
Raig 0:f0809a7877ff 39 int main() {
Raig 0:f0809a7877ff 40
Raig 0:f0809a7877ff 41 #ifdef debug
Raig 0:f0809a7877ff 42 wait( 3 );
Raig 0:f0809a7877ff 43 serial.printf("MS5803 demo");
Raig 0:f0809a7877ff 44 #endif
Raig 0:f0809a7877ff 45
Raig 0:f0809a7877ff 46 while ( 1 ) {
Raig 0:f0809a7877ff 47 #ifdef debug
Raig 0:f0809a7877ff 48 press_sensor.Barometer_MS5803();
Raig 0:f0809a7877ff 49 serial.printf("%4.1f (mBar)\r\n", press_sensor.MS5803_Pressure());
Raig 0:f0809a7877ff 50 serial.printf("%4.1f (deg C)\r\n", press_sensor.MS5803_Temperature());
Raig 0:f0809a7877ff 51 #endif
Raig 0:f0809a7877ff 52
Raig 0:f0809a7877ff 53 wait( 1 );
Raig 0:f0809a7877ff 54 }
Raig 0:f0809a7877ff 55 }