Hi -
I am VERY new to Blink, so please bear with me Referring to another topic I have found addressing similar situation:
I read that it is advised to keep the Void loop() clean but I have project that requires the code to calculate current used by a device, so it is not a simple case of reading the analogues value of a sensor. In this case, I have Particle publishing the calculated value to Particle Cloud and via a web hook to Blynk. The publishing code however runs in the Void loop() section.
The challenge I am facing is that when the code does not publish for what ever reason, the code is set to reset the device. This happens very quickly, but I noticed that even though the button remains in the ON position, the device being controlled and measured, will not turn on unless the button reverts back to the OFF position and then back to the ON position.
Here is my Void loop() codeā¦ I can post the entire code if needed:
Void loop() {
Blynk.run();
{
d = digitalRead (led);
Serial.println(d);
if (d > 0) {
digitalWrite (redPin, LOW);
digitalWrite (bluePin, HIGH);
}else{
digitalWrite (bluePin, LOW);
digitalWrite (redPin, HIGH);
}
}
float sensor_value = getRms();
if (sensor_value >= 0) {
char data[16];
snprintf(data, sizeof(data), "%.3f", sensor_value);
Particle.publish("Amp", String::format("{\"data\":%.3f}", sensor_value), PRIVATE);
delay(10000);
} else {
System.reset();
}
}
Is it as simple as moving everything outside of the Void loop() and include Timer function?
Many Thanks,
Friedl.