hi there
i just wanted to know if i can set the gpio pin 3 low at reboot
i try with trigger when device go offline set gpio3 low but when it reboot, it go to the last know state, so il it was high, they will reboot high
//includes and defines
int initialized;
void setup()
{
//force it low immediately
digitalWrite(3, LOW);
//clear the initialized flag on reset
initialized = 0;
Serial.begin(9600);
Cayenne.begin(token, ssid, password);
}
//loop function
//virtual in
CAYENNE_IN(V0)
{
if(!initialized) //only once, may be could go in setup too
{
Cayenne.virtualWrite(V0,LOW);
initialized = 1;
//wait a second to allow force to set. May need longer.
delay(1000);
}
// sets digital out to whatever the virtual is set to
digitalWrite(3, getValue.asInt());
}
Hmm I’ve never actually had a situation where that would affect me, but I can now see that when the Arduino boots it checks the values of the dashboard before it does anything else confirming what you said. I guess on second thought it would make more sense to check the dashboard to see what the previous value was instead of taking default boot up values. What @Kreggly posted is definitely a step further and should set the value at the dashboard level solving the problem. I tested it and it worked for me, but as his comment says I had to increase the delay to 3 seconds for it to actually work. I used an LED and I didn’t see it flciker at all during the boot process so you should be good to go.