I’m new to blynk and try to combine the Particle world with Blynk. Now I’m facing the problem, that my sketch either works with the pure Particle.variable / function or works with only Blynk. when both are enabled, only the Blynk part is working. Any hint for me? The system firmware is 0.7.0, Particle.pubish is fuctional
One thing you might also want to change is to get rid of that delay(500) in loop()
If you want to only do the DHT reading less often, rather go with something like this
void loop()
{
static uint32_t ms = 0;
Blynk.run();
timer.run(); // Initiates BlynkTimer
if (millis() - ms > 500) {
ms = millis();
h = dht.getHumidity();
t = dht.getTempCelcius();
}
}
BTW, which tip worked? @MikeM’s or mine about moving the variable setup to the top?
yes it worked, the moving to the beginning of setup()! The mordern style was my first test, but it didn’t help. Thanks for that. And btw. it works now with both styles, the move to the beginning of setup().
This script is only to get familar with the comination of particle and Blynk. In my productive scripts I use timer or the kind of loop you suggested. I try to avoid delay…
The background to this cure is that Particle.variable(), Particle.function() and Particle.subscribe() need to be registered with the cloud within aprox. 5 seconds after the connection gets established.
After that any new registrations would only take effect after a disconnect/reconnect.
And I guess the setup of the LCD and Blynk takes longer than 5 sec which causes the variables to not be registered in time.