Since I put the Blynk code in my app the Photon keeps going into this series of fast blinking lights.
It almost appears to happen when I turn on the Android client side. It blinks fast white, then fast green and finally fast cyan and then settles down to the pulse (breathing).
Is this normal behavior or do I have a coding problem?
I am using a delay(12000) to avoid overruns, should I use a timer instead?
/* This function is called once at start up ----------------------------------*/
void setup()
{
Particle.function(“controlRelay”, triggerRelay);
Serial.begin(9600);
// delay(5000);
Blynk.begin(auth);
while (Blynk.connect() == false) {
// Wait until connected
}
sensor.begin();
relayController.setAddress(0,0,0);
// To change resolution of the sensor use
// sensor.changeResolution(int i) where i=[0-3], //sensor.changeResolution(0);
Spark.variable(“number”, &number, INT);
}
/* This function loops forever --------------------------------------------*/
void loop()
{
Blynk.run(); // Run Blynk for Android interface
delay(12000);
@RPM99 delay(12000) is a sure fire way to kill your Blynk connection. Blynk has a 5 to 10 second timeout depending which version you are using. You need to use timer and your loop should look like this when you have fixed your code.
I downloaded SimpleTimer.cpp,SimpleTimer.h and led.ino from gethub (jfturcot/SimpleTimer).
They also required WProgram.h , I wonder if I have the correct one?
It has the following includes which I do not have on my machine, I am using Particle dev on my PC
These programs do not compile and simpletimer.cpp is not so simple.
Generates 8 errors that I am not able to fix, hope you can help?
This accounts for 7 of the 8 errors:
‘enabled’ was not declared in this scope SimpleTimer.cpp 39:9
Lines 27 thru 46: #include “SimpleTimer.h”
// Select time function:
//static inline unsigned long elapsed() { return micros(); }
static inline unsigned long elapsed() { return millis(); }
SimpleTimer::SimpleTimer() {
unsigned long current_millis = elapsed();
for (int i = 0; i < MAX_TIMERS; i++) {
enabled[i] = false;
callbacks[i] = 0; // if the callback pointer is zero, the slot is free, i.e. doesn't "contain" any timer
prev_millis[i] = current_millis;
numRuns[i] = 0;
}
Hello,
I get the same results.
The 2 files in the simpletimer directory are the same as the one I downloaded.
SimpleTimer.h file has an #include “WProgram.h”
This file is not in the blynk download, I had to use the one I found on github.
Simpletimer.h has the following line that creates error.
lines 70-71:
// returns true if the specified timer is enabled
boolean isEnabled(int numTimer);
Returns error:
boolean does not return a type
simpletimer.cpp has the folowing line that generates an error:
Lines 35-46:
SimpleTimer::SimpleTimer() {
unsigned long current_millis = elapsed();
for (int i = 0; i < MAX_TIMERS; i++) {
enabled[i] = false;
callbacks[i] = 0; // if the callback pointer is zero, the slot is free, i.e. doesn't "contain" any timer
prev_millis[i] = current_millis;
numRuns[i] = 0;
}
numTimers = 0;
}
Generates error:
'Enabled" was not declared in this scope
@RPM99 I did a file comparison and you appear to have the correct SimpleTimer. The WProgram.h and the associated Arduino.h is a throwback to changes in the Arduino IDE (I forget the version details but that’s not important).
Any timer will do and I believe Photon’s have their own interrupt timers. Maybe look at this one https://github.com/pkourany/SparkIntervalTimer if you can’t fix SimpleTimer for the Photon.