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: ADS1115 BME280 CronoDot SDFileSystem mbed
Fork of Outdoor_UPAS_v1_2_Tboard by
Revision 59:4221935a12d8, committed 2016-05-24
- Comitter:
- scottkelleher
- Date:
- Tue May 24 20:52:26 2016 +0000
- Parent:
- 58:3233c10a668c
- Commit message:
- latest version
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun May 22 18:49:25 2016 +0000
+++ b/main.cpp Tue May 24 20:52:26 2016 +0000
@@ -18,8 +18,8 @@
/////////////////////////////////////////////
//Analog to Digital Converter
/////////////////////////////////////////////
-Adafruit_ADS1115 ads(&i2c);
-//Adafruit_ADS1115 ads2(&i2c, 0x49);
+ Adafruit_ADS1115 ads(&i2c);
+Adafruit_ADS1115 ads2(&i2c);
//DigitalIn ADS_ALRT(PA_10); //Connected but currently unused. (ADS1115) http://www.ti.com/lit/ds/symlink/ads1115.pdf
@@ -62,17 +62,19 @@
float temp;
float rh;
float atmoRho; //g/L
-int logInerval = 5;//seconds
+int logInerval = 2;//seconds
DigitalOut sharp1LED(D7, 1);
DigitalOut sharp2LED(D6, 1);
DigitalOut sharp3LED(D5, 1);
DigitalOut sharp4LED(D4, 1);
+DigitalOut sharp5LED(D3, 1);
+DigitalOut sharp6LED(D2, 1);
int samplingTime = 280;
int deltaTime = 40;
-int sharp1, sharp2, sharp3, sharp4;
-float sharpVolt1, sharpVolt2, sharpVolt3, sharpVolt4; //V
+int sharp1, sharp2, sharp3, sharp4, sharp5, sharp6;
+float sharpVolt1, sharpVolt2, sharpVolt3, sharpVolt4, sharpVolt5, sharpVolt6; //V
@@ -116,12 +118,16 @@
rh = bmesensor.getHumidity();
atmoRho = ((press-((6.1078*pow((float)10,(float)((7.5*temp)/(237.3+temp))))*(rh/100)))*100)/(287.0531*(temp+273.15))+((6.1078*pow((float)10,(float)((7.5*temp)/(237.3+temp))))*(rh/100)*100)/(461.4964*(temp+273.15));
+ //pc.printf("%f,%f,%f,%f\r\n", temp, press, rh, atmoRho);
+
sharp1LED = 0;
sharp2LED = 0;
sharp3LED = 0;
sharp4LED = 0;
-
- wait_ms(samplingTime);
+ sharp5LED = 0;
+ sharp6LED = 0;
+
+ wait_us(samplingTime);
sharp1 = ads.readADC_SingleEnded(0, 0xC383); // read channel 1
sharpVolt1 = (sharp1*4.096)/(32768*1);
@@ -132,21 +138,32 @@
sharp4 = ads.readADC_SingleEnded(3, 0xF383); // read channel 1
sharpVolt4 = (sharp4*4.096)/(32768*1);
- wait_ms(deltaTime);
+ sharp5 = ads2.readADC_SingleEnded(0, 0xC383); // read channel 1
+ sharpVolt5 = (sharp4*4.096)/(32768*1);
+ sharp6 = ads2.readADC_SingleEnded(1, 0xD383); // read channel 1
+ sharpVolt6 = (sharp4*4.096)/(32768*1);
+
+ wait_us(deltaTime);
sharp1LED = 1;
sharp2LED = 1;
sharp3LED = 1;
sharp4LED = 1;
+ sharp5LED = 1;
+ sharp6LED = 1;
+ pc.printf("%d,%f,%d,%f,\r\n" ,sharp5,sharpVolt5, sharp6, sharpVolt6);
+ //pc.printf("%d,%f,%d,%f,%d,%f,%d,%f\r\n" ,sharp1,sharpVolt1, sharp2, sharpVolt2,sharp3,sharpVolt3, sharp4, sharpVolt4);
+ //pc.printf("%2.2f,%4.2f,%2.1f,%1.3f\r\n", temp,press,rh,atmoRho);
+ //pc.printf("%d,%f,%d,%f\r\n" ,sharp3,sharpVolt3, sharp4, sharpVolt4);
-
FILE *fp = fopen(filename, "a");
- fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,",RTC_UPAS.year, RTC_UPAS.month,RTC_UPAS.date,RTC_UPAS.hour,RTC_UPAS.minutes,RTC_UPAS.seconds);
- fprintf(fp, "%s,", timestr);
- fprintf(fp, "%2.2f,%4.2f,%2.1f,%1.3f,", temp,press,rh,atmoRho);
+ // fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,",RTC_UPAS.year, RTC_UPAS.month,RTC_UPAS.date,RTC_UPAS.hour,RTC_UPAS.minutes,RTC_UPAS.seconds);
+ //fprintf(fp, "%s,", timestr);
+ fprintf(fp, "%2.2f,%4.2f,%2.1f,%1.3f", temp,press,rh,atmoRho);
fprintf(fp, "%d,%f,%d,%f," ,sharp1,sharpVolt1, sharp2, sharpVolt2);
- fprintf(fp, "%d,%f,%d,%f\r\n" ,sharp3,sharpVolt3, sharp4, sharpVolt4);
+ fprintf(fp, "%d,%f,%d,%f" ,sharp3,sharpVolt3, sharp4, sharpVolt4);
+ fprintf("%d,%f,%d,%f,\r\n" ,sharp5,sharpVolt5, sharp6, sharpVolt6);
fclose(fp);
free(fp);
@@ -236,7 +253,7 @@
wait_ms(100);
}
- logg.attach(&log_data, 10);
+ logg.attach(&log_data, 3);
