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 Volckens Group Sensors

main.cpp

Committer:
caseyquinn
Date:
2015-05-01
Revision:
0:14d46ef4b6cb
Child:
1:37babeb68ab9

File content as of revision 0:14d46ef4b6cb:

#include "mbed.h"
#include "SDFileSystem.h"
#include "Adafruit_ADS1015.h"

I2C i2c(p22, p20);
Adafruit_ADS1115 ads(&i2c);
DigitalOut blower(p29, 0);

int omronReading;
int vInReading;
int vBlowerReading;
int omronDiff;

//Create an SDFileSystem object
SDFileSystem sd(SPIS_PSELMOSI, SPIS_PSELMISO, SPIS_PSELSCK, SPIS_PSELSS, "sd"); // I believe this matches Todd's pinout, let me know if this doesn't work. (p12, p13, p15, p14)


int main()
{
    
  
    while(1){
    
    omronReading = ads.readADC_SingleEnded(0, 0xC583); // read channel 0
    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
       
    //Mount the filesystem
    sd.mount();
    //Perform a write test
    FILE *fp = fopen("/sd/sdtest.txt", "w");
    fprintf(fp, "%d,%d,%d,%d\r\n", omronReading,vInReading, vBlowerReading, omronDiff);
    fclose(fp);
       
 
    //Unmount the filesystem
    sd.unmount();
    wait(5);
    }
}