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

Dependencies:   MS5803 mbed

Fork of MS5803-Demo by Raig Kaufer

Committer:
rkk
Date:
Thu Jul 24 04:59:32 2014 +0000
Revision:
3:6c96eb0697a5
Parent:
2:05edc973aa75
changed library

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
rkk 1:607dbba0562f 21 * for Pressure Sensors of type MS5803-x of MEAS Switzerland (www.meas-spec.com).
rkk 1:607dbba0562f 22 * The driver uses I2C mode (sensor's Protocol Select (PS) pin pulled to high).
rkk 1:607dbba0562f 23 * MS5803-01BA (Barometer Sensor (Altimeter)) was successfully tested by Raig Kaufer.
rkk 1:607dbba0562f 24 * MS5803-14BA (Underwater Pressure Sensor 14 bar) was successfully tested by Robert Katzschmann
rkk 1:607dbba0562f 25 * Other types of MEAS are compatible but not tested
rkk 1:607dbba0562f 26 * Written by Raig Kaufer, distribute freely!
rkk 1:607dbba0562f 27 * Revised by Robert Katzschmann
Raig 0:f0809a7877ff 28 */
Raig 0:f0809a7877ff 29
Raig 0:f0809a7877ff 30 #include "mbed.h"
Raig 0:f0809a7877ff 31 #include "MS5803.h"
Raig 0:f0809a7877ff 32
Raig 0:f0809a7877ff 33 #define debug
Raig 0:f0809a7877ff 34 #ifdef debug
rkk 1:607dbba0562f 35
Raig 0:f0809a7877ff 36 Serial pc(USBTX, USBRX);
Raig 0:f0809a7877ff 37 #endif
Raig 0:f0809a7877ff 38
rkk 1:607dbba0562f 39 MS5803 press_sensor( p9, p10, ms5803_addrCH ); // sda, scl, I2C_address
rkk 1:607dbba0562f 40 // I2C_address: ms5803_addrCH (0x76) or ms5803_addrCL (0x77)
rkk 1:607dbba0562f 41 // see also at MS5803.h
Raig 0:f0809a7877ff 42
Raig 0:f0809a7877ff 43 int main() {
Raig 0:f0809a7877ff 44
Raig 0:f0809a7877ff 45 #ifdef debug
Raig 0:f0809a7877ff 46 wait( 3 );
rkk 2:05edc973aa75 47 pc.printf("MS5803 demo\r\n");
Raig 0:f0809a7877ff 48 #endif
Raig 0:f0809a7877ff 49
Raig 0:f0809a7877ff 50 while ( 1 ) {
Raig 0:f0809a7877ff 51 #ifdef debug
Raig 0:f0809a7877ff 52 press_sensor.Barometer_MS5803();
rkk 1:607dbba0562f 53 pc.printf("%4.1f (mBar)\r\n", press_sensor.MS5803_Pressure());
rkk 1:607dbba0562f 54 pc.printf("%4.1f (deg C)\r\n", press_sensor.MS5803_Temperature());
Raig 0:f0809a7877ff 55 #endif
Raig 0:f0809a7877ff 56
Raig 0:f0809a7877ff 57 wait( 1 );
Raig 0:f0809a7877ff 58 }
Raig 0:f0809a7877ff 59 }