Version one of final code
Dependencies: ARCH_GPRS_V2_HW Blinker GPRSInterface HTTPClient_GPRS SDFileSystem USBDevice mbed RTC_WorkingLibrary
Fork of finalV1 by
Revision 2:5e5c2a000d25, committed 2015-04-22
- Comitter:
- mbotkinl
- Date:
- Wed Apr 22 16:46:48 2015 +0000
- Parent:
- 1:6746983fa040
- Commit message:
- added timestamp from RTC;
Changed in this revision
RTC_WorkingLibrary.lib | Show annotated file Show diff for this revision Revisions of this file |
finalCode.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6746983fa040 -r 5e5c2a000d25 RTC_WorkingLibrary.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RTC_WorkingLibrary.lib Wed Apr 22 16:46:48 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Cellular-building-monitoring/code/RTC_WorkingLibrary/#9702e2e4aef9
diff -r 6746983fa040 -r 5e5c2a000d25 finalCode.cpp --- a/finalCode.cpp Wed Apr 22 16:37:24 2015 +0000 +++ b/finalCode.cpp Wed Apr 22 16:46:48 2015 +0000 @@ -9,9 +9,13 @@ #include "DHT.h" #include "i2c_uart.h" #include "ARCH_GPRS_Sleep.h" +#include "ds1307.h" #define PIN_TX P1_27 #define PIN_RX P1_26 + +#define SDA P0_5 +#define SCL P0_4 #define BROADCAST_TIME 300 //LED Blink @@ -20,6 +24,11 @@ //USBSerial pc; SDFileSystem sd(P1_22, P1_21, P1_20, P1_23, "sd"); // the pinout on the /Arch GPRS v2 mbed board. +//RTC +DS1307 rtc(SDA,SCL); +int sec, min, hours, day, date, month, year; +char timestamp[17]; + //variables for reading data from SD card char APIKey[17]; char sensors[3][5]; @@ -161,7 +170,9 @@ void sdWrite1(int sensor1Data) { - + rtc.gettime( &sec, &min, &hours, &day, &date, &month, &year); + sprintf(timestamp,"20%.2d-%.2d-%.2d %.2d:%.2d:%.2d", year, month, date, hours, min, sec); + mkdir("/sd", 0777); FILE *fp = fopen("/sd/node1.csv","a"); if (fp == NULL) { @@ -169,7 +180,7 @@ redLED.blink(10); } else { - fprintf(fp,"timestamp, %d \r\n",sensor1Data); + fprintf(fp,"%s, %d \r\n",timestamp,sensor1Data); fclose(fp); blueLED.blink(5); } @@ -177,6 +188,9 @@ void sdWrite2(int sensor1Data, int sensor2Data) { + rtc.gettime( &sec, &min, &hours, &day, &date, &month, &year); + sprintf(timestamp,"20%.2d-%.2d-%.2d %.2d:%.2d:%.2d", year, month, date, hours, min, sec); + mkdir("/sd", 0777); FILE *fp = fopen("/sd/node1.csv","a"); if (fp == NULL) { @@ -184,7 +198,7 @@ redLED.blink(10); } else { - fprintf(fp,"timestamp, %d, %d\r\n",sensor1Data, sensor2Data); + fprintf(fp,"%s, %d, %d\r\n",timestamp, sensor1Data, sensor2Data); fclose(fp); blueLED.blink(5); } @@ -192,6 +206,9 @@ void sdWrite3(int sensor1Data, int sensor2Data,int sensor3Data) { + rtc.gettime( &sec, &min, &hours, &day, &date, &month, &year); + sprintf(timestamp,"20%.2d-%.2d-%.2d %.2d:%.2d:%.2d", year, month, date, hours, min, sec); + mkdir("/sd", 0777); FILE *fp = fopen("/sd/node1.csv","a"); if (fp == NULL) { @@ -199,7 +216,7 @@ redLED.blink(10); } else { - fprintf(fp,"timestamp, %d, %d, %d\r\n",sensor1Data, sensor2Data, sensor3Data); + fprintf(fp,"%s, %d, %d, %d\r\n",timestamp, sensor1Data, sensor2Data, sensor3Data); fclose(fp); blueLED.blink(5); }