Having consistency issues with Blynk and Photon. Right now here is my state:
-I can post things to a terminal widget during events
-I cannot set LED widgets to on at ANY point
-I cannot post to a terminal widget when the Photo wakes up or before it goes to sleep even when running Blynk.run(); right after
I tried setting the LED to ON both inside of a function and inside of loop() (using a one time state boolean variable so not to flood the system). I tried using both setValue(255) and on(). Not understanding the inconsistency here.
I also just tried Blynk.virtualWrite(1, 255); to turn the LED on and that isn’t working either.
Just tried this… same result. I don’t understand what I’m doing wrong.
Also, that brings me to another question. If I set a virtual PIN on the Core before it connected to Blynk, will that PIN state reach the server/app when it does connect or is it lost forever? Also, how about when setting a virtual PIN on the app?
Here is my new code that still doesn’t do anything:
// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"
char auth[] = "0968761e711c4d6caf298821372815c9";
WidgetTerminal terminal(V3);
WidgetLED led1(V1);
bool firstRun = true;
void setup() {
Blynk.begin(auth);
while (Blynk.connect() == false) {
// Wait until connected
}
}
void loop() {
if (firstRun == true) {
blynkStartup();
}
Blynk.run();
}
void blynkStartup() {
led1.on();
//led1.setValue(255);
//Blynk.virtualWrite(1, 255);
terminal.println("Woke up");
terminal.flush();
firstRun = false;
}
I moved this to a Photon and it started working, but only if I had my .connected()==true condition in place. Seems this works on a Photon, but not the Core.
EDIT: Very odd but this started working after a while on both. Very odd. I does seem like Blynk commands that happen on the device side before a connection is established are dropped. Guess we have to do our own caching in the code if we don’t want to do a ‘while’ loop waiting for a successful connection.