![](/media/cache/profiles/home-panel-product-android-lcd.png.50x50_q85.png)
USNA WRCE TSD AUV
Dependencies: mbed AUV_MS5837_30BA_WRCE_TSD
main.cpp@4:2bc5a2cd135f, 2019-07-23 (annotated)
- Committer:
- JohnSarge
- Date:
- Tue Jul 23 13:38:55 2019 +0000
- Revision:
- 4:2bc5a2cd135f
- Parent:
- 0:a06b510ad982
Updated comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yuuitirou528 | 0:a06b510ad982 | 1 | //Bar02 Ultra High Resolution 10m Depth/Pressure Sensor sample |
yuuitirou528 | 0:a06b510ad982 | 2 | //MS5837-02BA onry |
yuuitirou528 | 0:a06b510ad982 | 3 | //ArduinoLibrary->mbedLibrary |
yuuitirou528 | 0:a06b510ad982 | 4 | |
yuuitirou528 | 0:a06b510ad982 | 5 | //https://os.mbed.com/teams/POTLESS/code/MS5837/ |
yuuitirou528 | 0:a06b510ad982 | 6 | //https://github.com/bluerobotics/BlueRobotics_MS5837_Library |
yuuitirou528 | 0:a06b510ad982 | 7 | |
yuuitirou528 | 0:a06b510ad982 | 8 | #include "mbed.h" |
yuuitirou528 | 0:a06b510ad982 | 9 | #include "MS5837.h" |
yuuitirou528 | 0:a06b510ad982 | 10 | |
yuuitirou528 | 0:a06b510ad982 | 11 | |
yuuitirou528 | 0:a06b510ad982 | 12 | Serial pc(USBTX, USBRX,115200); // tx, rx |
yuuitirou528 | 0:a06b510ad982 | 13 | |
yuuitirou528 | 0:a06b510ad982 | 14 | //I2C i2c(I2C_SDA,I2C_SCL); |
yuuitirou528 | 0:a06b510ad982 | 15 | MS5837 sensor(I2C_SDA, I2C_SCL, ms5837_addr_no_CS); |
yuuitirou528 | 0:a06b510ad982 | 16 | |
yuuitirou528 | 0:a06b510ad982 | 17 | |
yuuitirou528 | 0:a06b510ad982 | 18 | int main() { |
yuuitirou528 | 0:a06b510ad982 | 19 | // Initialize pressure sensor |
yuuitirou528 | 0:a06b510ad982 | 20 | // Returns true if initialization was successful |
yuuitirou528 | 0:a06b510ad982 | 21 | // We can't continue with the rest of the program unless we can initialize the sensor |
yuuitirou528 | 0:a06b510ad982 | 22 | printf("start"); |
yuuitirou528 | 0:a06b510ad982 | 23 | sensor.MS5837Reset(); |
yuuitirou528 | 0:a06b510ad982 | 24 | sensor.MS5837Init(); |
yuuitirou528 | 0:a06b510ad982 | 25 | printf("ok"); |
yuuitirou528 | 0:a06b510ad982 | 26 | |
yuuitirou528 | 0:a06b510ad982 | 27 | |
yuuitirou528 | 0:a06b510ad982 | 28 | while(1) { |
yuuitirou528 | 0:a06b510ad982 | 29 | |
yuuitirou528 | 0:a06b510ad982 | 30 | sensor.Barometer_MS5837(); |
yuuitirou528 | 0:a06b510ad982 | 31 | |
yuuitirou528 | 0:a06b510ad982 | 32 | printf("Pressure: "); |
yuuitirou528 | 0:a06b510ad982 | 33 | printf("%f",sensor.MS5837_Pressure()); |
yuuitirou528 | 0:a06b510ad982 | 34 | printf(" mbar"); |
yuuitirou528 | 0:a06b510ad982 | 35 | |
yuuitirou528 | 0:a06b510ad982 | 36 | printf("Temperature: "); |
yuuitirou528 | 0:a06b510ad982 | 37 | printf("%f",sensor.MS5837_Temperature()); |
yuuitirou528 | 0:a06b510ad982 | 38 | printf(" deg C "); |
yuuitirou528 | 0:a06b510ad982 | 39 | |
yuuitirou528 | 0:a06b510ad982 | 40 | printf("Depth: "); |
yuuitirou528 | 0:a06b510ad982 | 41 | printf("%f",sensor.depth()); |
yuuitirou528 | 0:a06b510ad982 | 42 | printf(" m "); |
yuuitirou528 | 0:a06b510ad982 | 43 | |
yuuitirou528 | 0:a06b510ad982 | 44 | printf("Altitude: "); |
yuuitirou528 | 0:a06b510ad982 | 45 | printf("%f",sensor.altitude()); |
yuuitirou528 | 0:a06b510ad982 | 46 | printf(" m above mean sea level\r\n"); |
yuuitirou528 | 0:a06b510ad982 | 47 | |
yuuitirou528 | 0:a06b510ad982 | 48 | |
yuuitirou528 | 0:a06b510ad982 | 49 | wait(1); |
yuuitirou528 | 0:a06b510ad982 | 50 | } |
yuuitirou528 | 0:a06b510ad982 | 51 | } |