Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 /* MS5611 Pressure sensor example 00002 Aerodyne Labs 00003 2014 00004 00005 This example uses the MS511 Library to read the temperature and pressure readings 00006 from the MS5611 sensor. It has been modified from the MS507 sensor library with 00007 the different calculations that the MS5611 requires. Otherwise, this library is 00008 identical to the MS5607 00009 ------------ 00010 IndNav: Made adaptions, even though, the original works well, problem: 00011 the original has a delay of 8ms from writing to reading (see line 73 in MS5611I2C.h) 00012 Solution: seperate write and read in 2 processes (hene's hint): 00013 - write at end of data_read thread, without waiting 00014 - at beginning of next call, read the data 00015 since there are 2 seperate reading/writings (one for pressure(altitude), one for Temperature -and we need both!) 00016 toggle the 2 processes, this results, that only every 2nd pressure/altitude value is a new value! 00017 00018 altb 20.2.2020 00019 */ 00020 #include "mbed.h" 00021 00022 //Only uncomment the one needed. 00023 //#include "MS5611SPI.h" 00024 #include "MS5611I2C.h" 00025 00026 Serial pc(USBTX, USBRX); // local terminal interface 00027 Timer timer; 00028 00029 int main() { 00030 pc.baud(115200); // set up USB serial speed 00031 timer.reset(); 00032 timer.start(); 00033 //Only uncomment the I2C or SPI version. 00034 //MS5611SPI ms5611(p11, p12, p13, p10); 00035 //MS5611I2C ms5611(p9, p10, false); 00036 //PB_9 and PB_8 for Nucleo boards 00037 I2C i2c(PB_3,PB_10); 00038 MS5611I2C ms5611(i2c, false); 00039 //Print the Coefficients from the 00040 ms5611.printCoefficients(); 00041 while(1){ 00042 timer.reset(); 00043 // float dum2 = ms5611.getTemperature(); 00044 // float dum3 = ms5611.getAltitude(); 00045 // printf("10 Durchlaeufe: %f sec \r\n", T); 00046 // printf("Pressure = %.0f Pa \r\n", ms5611.getPressure()); 00047 // printf("Temperature = %.2f degC \r\n", ms5611.getTemperature()); 00048 ms5611.getAltitude_toggle_Temp_write(); 00049 wait_ms(100); 00050 printf("Altitude = %.2f m \r\n", ms5611.getAltitude_toggle_Temp_read()); 00051 printf("Altitude = %.2f m \r\n", ms5611.getAltitude()); 00052 float T = timer.read(); 00053 wait(1.0); 00054 } 00055 }
Generated on Wed Jul 13 2022 04:23:21 by
1.7.2