Code supports writing to the SD card as well as working with the Volckens group smartphone apps for the mbed HRM1017
Dependencies: ADS1115 BLE_API BME280 Calibration CronoDot EEPROM LSM303 MCP40D17 NCP5623BMUTBG SDFileSystem SI1145 STC3100 mbed nRF51822
Fork of UPAS_BLE_and_USB by
Diff: main.cpp
- Revision:
- 114:84e759e07948
- Parent:
- 113:846f67efaa80
- Child:
- 115:fb25810c1fab
--- a/main.cpp Wed Feb 17 03:16:59 2016 +0000 +++ b/main.cpp Thu Feb 18 01:02:00 2016 +0000 @@ -3,7 +3,7 @@ #include "Adafruit_ADS1015.h" #include "MCP40D17.h" #include "STC3100.h" -#include "LSM303.h" +//#include "LSM303.h" #include "BME280.h" #include "SI1145.h" #include "NCP5623BMUTBG.h" @@ -36,7 +36,7 @@ Serial pc(USBTX, USBRX); DigitalOut blower(p29, 0); DigitalOut pbKill(p18, 1); -LSM303 movementsensor(p22, p20); +//LSM303 movementsensor(p22, p20); SI1145 lightsensor(p22, p20); NCP5623BMUTBG RGB_LED(p22, p20); CronoDot RTC(p22, p20); @@ -44,8 +44,8 @@ DigitalOut GPS_EN(p4,0); //pin 4 is used to enable and disable the GPS, in order to recive serial communications Calibration calibrations(1); //Default serial/calibration if there are no values for the selected option -Timeout stop; //This is the stop call back object -Timeout logg; //This is the logging call back object +//Timeout stop; //This is the stop call back object +//Timeout logg; //This is the logging call back object @@ -61,6 +61,7 @@ int vis; int ir; +/* float compass; float accel_x; float accel_y; @@ -72,6 +73,7 @@ float mag_x; float mag_y; float mag_z; +*/ int vInReading; int vBlowerReading; @@ -179,17 +181,17 @@ } -int r =0; -int g =1; -int b=1; +//int r =0; +//int g =1; +//int b=1; void log_data() { - //logg.detach(); - //logg.attach(&log_data, logInerval); // reading and logging data must take significintly less than 0.5s. This can be increased. - if(r==0) r=1; - else r=0; - RGB_LED.set_led(r,g,b); - wait(0.5); + logg.detach(); + logg.attach(&log_data, logInerval); // reading and logging data must take significintly less than 0.5s. This can be increased. + // if(r==0) r=1; + //else r=0; + //RGB_LED.set_led(r,g,b); + //wait(0.5); RTC.get_time(); @@ -411,7 +413,7 @@ RunReady = 0; - //stop.attach(&check_stop, 30); // check if we should shut down every 9 seconds, starting 60s after the start. + //stop.attach(&check_stop, 30); // check if we should shut down every 30 seconds, starting 60s after the start. //Use the flow rate value stored in eeprom E2PROM.read(0x00010,flowRateOriginal,4); @@ -509,6 +511,8 @@ sampledVol = 0.0; RGB_LED.set_led(0,1,0); + + // logg.attach(&log_data, logInerval); // uses callbacks or block Interrupts for anything that uses i2c while(1){ @@ -567,6 +571,7 @@ RGB_LED.set_led(0,1,0); } + /* movementsensor.getACCEL(); movementsensor.getCOMPASS(); compass = movementsensor.getCOMPASS_HEADING(); @@ -577,7 +582,7 @@ mag_x = movementsensor.MagData.x; mag_y = movementsensor.MagData.y; mag_z = movementsensor.MagData.z; - + */ vInReading = ads.readADC_SingleEnded(1, 0xD583); // read channel 0 vBlowerReading = ads.readADC_SingleEnded(2, 0xE783); // read channel 0 omronDiff = ads.readADC_Differential(0x8583); // differential channel 2-3 @@ -592,11 +597,13 @@ FILE *fp = fopen(filename, "a"); fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,",RTC.year, RTC.month,RTC.date,RTC.hour,RTC.minutes,RTC.seconds); fprintf(fp, "%1.3f,%1.3f,%2.2f,%4.2f,%2.1f,%1.3f,", omronVolt,massflow,temp,press,rh,atmoRho); - fprintf(fp, "%1.3f,%5.1f,%1.1f,%1.1f,%1.1f,%1.1f,", volflow, sampledVol, accel_x, accel_y, accel_z, accel_comp); - fprintf(fp, "%.1f,%.1f,%.1f,%.3f,%.3f,%.3f,%.1f,", angle_x,angle_y,angle_z,mag_x, mag_y, mag_z,compass); + fprintf(fp, "%1.3f,%5.1f,", volflow, sampledVol); + // fprintf(fp, "%1.3f,%5.1f,%1.1f,%1.1f,%1.1f,%1.1f,", volflow, sampledVol, accel_x, accel_y, accel_z, accel_comp); + // fprintf(fp, "%.1f,%.1f,%.1f,%.3f,%.3f,%.3f,%.1f,", angle_x,angle_y,angle_z,mag_x, mag_y, mag_z,compass); fprintf(fp, "%d,%d,%d,%d,%d,%d," ,uv,omronReading, vInReading, vBlowerReading, omronDiff,gasG.getAmps()); fprintf(fp, "%d,%d,%d,%1.3f,%1.3f\r\n", gasG.getVolts(), gasG.getCharge(),digital_pot_set, deltaMflow, deltaVflow); fclose(fp); + //free(fp); }