Hello, I have an Argon connected to 2 float sensors and would like the device to sleep until awake by digital pin change. Issue I am having here is that device keeps on awaking right away after sleeping eventhough no pin change. Here is my code.
#include "Particle.h"
#define FLOAT_SENSOR0 D3 // the number of the pushbutton pin
#define FLOAT_SENSOR1 D6 // the number of the pushbutton pin
int currState[2] = {0,0};
int float_value = 0;
void setup()
{
pinMode(FLOAT_SENSOR0, INPUT_PULLUP); // initiate the sensor
pinMode(FLOAT_SENSOR1, INPUT_PULLUP);
Particle.variable("float_value", float_value);
}
void getsensors()
{
currState[0] = digitalRead(FLOAT_SENSOR0);
currState[1] = digitalRead(FLOAT_SENSOR1);
switch(currState[0])
{
case(0):
if((currState[1] == 0)){
float_value = 0;
Particle.publish("Level is above 70%", PRIVATE);
break;
}
else if((currState[1] == 1)){
float_value = 1;
Particle.publish("Error Float", PRIVATE);
break;
}
case(1):
if((currState[1] == 1)){
float_value = 2;
Particle.publish("Level is below 20%", PRIVATE);
break;
}
else if((currState[1] == 0)){
float_value = 3;
Particle.publish("Level is around 40%", PRIVATE);
break;
}
}
}
void loop()
{
getsensors();
delay(5000);
pin_t wakeUpPins[2] = {D3, D6};
InterruptMode edgeTriggerModes[2] = {CHANGE, CHANGE};
System.sleep(wakeUpPins, 2, edgeTriggerModes, 2);
}