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:
- 10:f9cb61b29340
- Parent:
- 9:2057c3779b6a
- Child:
- 11:2297d364af61
diff -r 2057c3779b6a -r f9cb61b29340 main.cpp --- a/main.cpp Thu May 14 14:23:28 2015 +0000 +++ b/main.cpp Wed May 20 18:19:30 2015 +0000 @@ -3,8 +3,9 @@ #include "Adafruit_ADS1015.h" #include "MCP40D17.h" #include "BMP280.h" -#include "wire.h" +#include "wire.h" //Used with the RTC in this code. Will need to try and remove this, and also create the correct library/update addresses and registers for the RTC. #include "STC3100.h" +#include "LSM303.h" #define SERIAL_BAUD_RATE 9600 #define SCL 20 @@ -19,6 +20,7 @@ Serial pc(USBTX, USBRX); DigitalOut blower(p29, 0); AnalogIn Honeywell(P0_2); +LSM303 movementsensor(p22, p20); //Timer t; @@ -26,6 +28,13 @@ //float battVolts; //float battGG; +float accel_x; +float accel_y; +float accel_z; +float mag_x; +float mag_y; +float mag_z; + float Honeywell_value; int omronReading; int vInReading; @@ -107,6 +116,15 @@ while(1){ get_time(); + + movementsensor.getACCEL(); + movementsensor.getCOMPASS(); + accel_x = movementsensor.AccelData.x; + accel_y = movementsensor.AccelData.y; + accel_z = movementsensor.AccelData.z; + mag_x = movementsensor.MagData.x; + mag_y = movementsensor.MagData.y; + mag_z = movementsensor.MagData.z; Honeywell_value = Honeywell.read(); omronReading = ads.readADC_SingleEnded(0, 0xC583); // read channel 0 PGA = 2 : Full Scale Range = 2.048V //omronReading = ads.readADC_SingleEnded(0, 0xC183); // read channel 0 PGA = 1 : Full Scale Range = 4.096V @@ -120,7 +138,7 @@ //Mount the filesystem sd.mount(); FILE *fp = fopen(filename, "a"); - fprintf(fp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%2.2f,%04.2f,%f\r\n", Year,Month,Date,Hour,Minutes,Seconds,omronReading,vInReading, vBlowerReading, omronDiff, gasG.getAmps(), gasG.getVolts(), gasG.getCharge(), bmpsensor.getTemperature(), bmpsensor.getPressure(),Honeywell_value); + fprintf(fp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%2.2f,%04.2f,%f,%.0f,%.0f,%.0f,%.0f,%.0f,%.0f\r\n", Year,Month,Date,Hour,Minutes,Seconds,omronReading,vInReading, vBlowerReading, omronDiff, gasG.getAmps(), gasG.getVolts(), gasG.getCharge(), bmpsensor.getTemperature(), bmpsensor.getPressure(),Honeywell_value,accel_x, accel_y, accel_z, mag_x, mag_y, mag_z); fclose(fp); //Unmount the filesystem sd.unmount();