Skip to content

Commit

Permalink
update environmental sensing send interval
Browse files Browse the repository at this point in the history
  • Loading branch information
esthoril committed Feb 14, 2018
1 parent 24772b7 commit 125f145
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions examples/environmental-sensing/environmental-sensing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

#define baud 9600

#define SEND_EVERY 300000 // Send every 300 seconds

ATT_NBIOT nbiot;

#ifdef CBOR
Expand All @@ -60,8 +62,6 @@ ATT_NBIOT nbiot;
#define LightSensorPin A2
#define SoundSensorPin A4

#define SEND_EVERY 30000

AirQuality2 airqualitysensor;
Adafruit_BME280 tph; // I2C

Expand Down Expand Up @@ -101,16 +101,18 @@ void setup()
initSensors();
}

unsigned long ctime = 0;
void loop()
{
readSensors();
displaySensorValues();
sendSensorValues();

DEBUG_STREAM.print("Delay for: ");
DEBUG_STREAM.println(SEND_EVERY);
DEBUG_STREAM.println();
delay(SEND_EVERY);
unsigned long curTime = millis() + SEND_EVERY; // Add interval to make sure data is send on startup
if (curTime > (ctime + SEND_EVERY))
{
readSensors();
displaySensorValues();
sendSensorValues();

ctime = curTime;
}
}

void initSensors()
Expand Down

0 comments on commit 125f145

Please sign in to comment.