Home › Forums › Mayfly Data Logger › Recording data from pressure sensors on an SD card › Reply To: Recording data from pressure sensors on an SD card
2017-05-01 at 2:59 PM
#2193
Aq_Bar_Press_NoSD.ino
Arduino
1 2 3 4 5 6 |
#include <Wire.h> #include <SparkFun_MS5803_I2C.h> #include <Wire.h> #include <Adafruit_MPL115A2.h> Adaf |
Aq_Bar_Press_NoSD.ino
Arduino
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 |
#include <Wire.h> #include <SparkFun_MS5803_I2C.h> #include <Wire.h> #include <Adafruit_MPL115A2.h> Adafruit_MPL115A2 mpl115a2; #include <Wire.h> #include "Sodaq_DS3231.h" char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; //year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6) //writing any non-existent time-data may interfere with normal operation of the RTC. //Take care of week-day also. DateTime dt(2017, 04, 24, 15, 04, 0, 1); // Begin class with selected address // available addresses (selected by jumper on board) // default is ADDRESS_HIGH // ADDRESS_HIGH = 0x76 // ADDRESS_LOW = 0x77 MS5803 sensor(ADDRESS_HIGH); //Create variables to store results float temperature_c, temperature_f; double pressure_abs, pressure_relative, altitude_delta, pressure_baseline; // Create Variable to store altitude in (m) for calculations; double base_altitude = 1655.0; // Altitude of SparkFun's HQ in Boulder, CO. in (m) void setup() { Serial.begin(9600); Wire.begin(); rtc.begin(); rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above Serial.begin(9600); //Retrieve calibration constants for conversion math. sensor.reset(); sensor.begin(); pressure_baseline = sensor.getPressure(ADC_4096); Serial.begin(9600); Serial.println("Hello!"); Serial.println("Getting barometric pressure ..."); mpl115a2.begin(); } void loop() { DateTime now = rtc.now(); //get the current date-time Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.date(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); Serial.print(weekDay[now.dayOfWeek()]); Serial.println(); // To measure to higher degrees of precision use the following sensor settings: // ADC_256 // ADC_512 // ADC_1024 // ADC_2048 // ADC_4096 // Read temperature from the sensor in deg C. This operation takes about temperature_c = sensor.getTemperature(CELSIUS, ADC_512); // Read temperature from the sensor in deg F. Converting // to Fahrenheit is not internal to the sensor. // Additional math is done to convert a Celsius reading. temperature_f = sensor.getTemperature(FAHRENHEIT, ADC_512); // Read pressure from the sensor in mbar. pressure_abs = sensor.getPressure(ADC_4096); // Report values via UART Serial.print("Temperature C = "); Serial.println(temperature_c); Serial.print("Temperature F = "); Serial.println(temperature_f); Serial.print("Water Pressure abs (mbar)= "); Serial.println(pressure_abs); float pressureKPA = 0, temperatureC = 0; pressureKPA = mpl115a2.getPressure(); Serial.print("Atmospheric Pressure (kPa): "); Serial.print(pressureKPA, 4); Serial.println(" kPa"); delay(10000); } |