Remote Writing IoT Data to Influx-DB over HTTP-API.
Fork of AvnetATT_shape_hackathon by
Revision 30:48b43538e98b, committed 2016-07-20
- Comitter:
- stefanrousseau
- Date:
- Wed Jul 20 04:01:03 2016 +0000
- Parent:
- 29:e6c8bd41caa6
- Child:
- 31:d7c386d2e95a
- Commit message:
- Changed the motion sensor instantiation from static to dynamic inside the function that uses it. This is needed because the WNC on the shield corrupts the I2C bus during initialization.
Changed in this revision
--- a/config_me.h Sat Jul 16 17:35:15 2016 +0000 +++ b/config_me.h Wed Jul 20 04:01:03 2016 +0000 @@ -32,7 +32,8 @@ #define TEMP_HUMIDITY_ONLY 1 #define TEMP_HUMIDITY_ACCELEROMETER 2 #define TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS 3 -static int iSensorsToReport = TEMP_HUMIDITY_ONLY; //modify this to change your selection +//static int iSensorsToReport = TEMP_HUMIDITY_ONLY; //modify this to change your selection +static int iSensorsToReport = TEMP_HUMIDITY_ACCELEROMETER; //modify this to change your selection // This is the APN name for the cellular network, you will need to change this, check the instructions included with your SIM card kit: static const char * MY_APN_STR = "m2m.com.attz";
--- a/hts221_driver.cpp Sat Jul 16 17:35:15 2016 +0000 +++ b/hts221_driver.cpp Wed Jul 20 04:01:03 2016 +0000 @@ -17,8 +17,7 @@ { char data = ToRead; - //i2c.write(slaveAddress, &data, 1, 0); - i2c.write(slaveAddress, &data, 1, 1); //by Stefan + i2c.write(slaveAddress, &data, 1, 1); i2c.read(slaveAddress, &data, 1, 0); return data; }
--- a/sensors.cpp Sat Jul 16 17:35:15 2016 +0000 +++ b/sensors.cpp Wed Jul 20 04:01:03 2016 +0000 @@ -6,12 +6,9 @@ #define Si7020_PMOD_I2C_ADDR 0x80 //this is for 7-bit addr 0x4 for the Si7020 #include "hardware.h" -//I2C i2c(PTC11, PTC10); //SDA, SCL #include "FXOS8700CQ.h" -// Pin names for the motion sensor FRDM-K64F board: -FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1) -// Storage for the data from the sensor +// Storage for the data from the motion sensor SRAWDATA accel_data; SRAWDATA magn_data; //InterruptIn fxos_int1(PTC6); // unused, common with SW2 on FRDM-K64F @@ -20,7 +17,6 @@ void trigger_fxos_int2(void) { fxos_int2_triggered = true; - //us_ellapsed = t.read_us(); } /*------------------------------------------------------------------------------ @@ -318,8 +314,10 @@ bool bMotionSensor_present = false; void init_motion_sensor() { + // Note: this class is instantiated here because if it is statically declared, the cellular shield init kills the I2C bus... + // Class instantiation with pin names for the motion sensor on the FRDM-K64F board: + FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1) int iWhoAmI = fxos.get_whoami(); - printf("FXOS8700CQ WhoAmI = %X\r\n", iWhoAmI); // Iterrupt for active-low interrupt line from FXOS // Configured with only one interrupt on INT2 signaling Data-Ready @@ -338,8 +336,12 @@ void read_motion_sensor() { + // Note: this class is instantiated here because if it is statically declared, the cellular shield init kills the I2C bus... + // Class instantiation with pin names for the motion sensor on the FRDM-K64F board: + FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1) if (bMotionSensor_present) { + fxos.enable(); fxos.get_data(&accel_data, &magn_data); //printf("Roll=%5d, Pitch=%5d, Yaw=%5d;\r\n", magn_data.x, magn_data.y, magn_data.z); sprintf(SENSOR_DATA.MagnetometerX, "%5d", magn_data.x);