I tried finding an answer, but it eluded me. So I've set my system to SYSTEM_MODE(MANUAL) as I need to perform some Timer functions as well. I'm trying to keep the Particle.process as far a part as possible and the documentation said 20s should be fine so I chose 19s. But I'm still seeing that the first timer is not being sampled as I thought but there's a few mS in between. Also I can't get it to flash with these settings.
#include "SparkIntervalTimer/SparkIntervalTimer.h"
#include "math.h"
#include "application.h"
//debugging
//if this is defined then serial will work
#define SERIALout
SYSTEM_MODE(MANUAL); //Just to have the blink start immediately
unsigned long interval=19000;
IntervalTimer myTimer;
void setup() {
// this is 8 * 512 samples, just reads ADC
myTimer.begin(getData, 244, uSec);
#ifdef SERIALout
Serial.begin(57600);
#endif
WiFi.on();
delay(1000);
WiFi.clearCredentials();
#ifdef setKertsiWifi
if(!(WiFi.hasCredentials())) {
WiFi.setCredentials("XXXXXXX", "XXXXXXX");
}
#endif
//this one is defined
#ifdef testHomeWifi
if(!(WiFi.hasCredentials())){
WiFi.setCredentials("XXXXXX", "XXXXXX");
}
#endif
Particle.variable("biletappi",passData);
//Particle.publish("biletappi", passData);
//begin the measurements
if (!Particle.connected()) {
Particle.connect();
}
Particle.process();
}
}
void loop() {
//check if 19 seconds have passed and it is time to read the sensor
unsigned long currentMillis = millis(); // grab current time
// check if "interval" time has passed
//Serial.println(currentMillis - previousMillis);
if (unsigned long)(currentMillis - previousMillis) >= interval) {
blockingCheck = true;
if (Particle.connected()) {
Particle.process();
} else {
Particle.connect();
}
//save the "current" time
previousMillis = millis();
}
#ifdef SERIALout
Serial.println(passData);
#endif
passData = " TEST: " + String(outputTester) + " TEST2: " + String(outputTester2) + " no: "+outputter;
}
void getData() {
outputTester2 = micros();
// ... everything else is commented out
}
I did look at this:
I'm missing something.