Flotsam / Full-Project

Dependencies:   GPSLibrary GSM mbed-modifed Storage_Library Temp_Library Wakeup pH_Sensor

Revision:
6:10b0ff2803e5
Parent:
5:e180c73f4f70
Child:
7:92f2d8c79565
--- a/main.cpp	Fri Nov 06 20:20:45 2015 +0000
+++ b/main.cpp	Mon Nov 09 18:55:17 2015 +0000
@@ -16,9 +16,12 @@
 #define PH_TX PC_10
 #define PH_RX PC_11
 
+#define TMP_ANALOG A0
+#define ADC_CONVERSION 3.3/5.0
 Adafruit_FONA fona(FONA_TX, FONA_RX, FONA_RST, FONA_RI);
 Serial pcSerial(USBTX, USBRX);
 DigitalOut key(FONA_KEY);
+AnalogIn temperature(TMP_ANALOG);
 
 // GPS
 char c; //when read via Adafruit_GPS::read(), the class returns single character stored here
@@ -111,6 +114,17 @@
     }
 }
 
+//function to get both the 
+double AD22100K_AI_value_to_Celsius() {                                               // Convert Analog-input value to temperature
+  //1023 is to scale it up to the arduino read values.
+  float voltage = (int)((temperature.read() * ADC_CONVERSION) * 1023);
+   
+  float temperatureValue = (voltage * 0.217226044) - 61.1111111; // conversion factor simplified.
+  pcSerial.printf("AI_Val: %f\n", temperatureValue);
+  return temperatureValue;       // 22.5 mV / °C; Ratiometric measurement, conversion valid for 5 V!
+}
+      
+
 // n_queries is the number of times we query the GPS. We need something like 23000 characters.
 void GPSRead(int n_queries) {
     pcSerial.printf("\n");