Scheduling triger alerts for motion sensor


#1

Hello cayenne community,
I wanted to share idea. I have ESP8266(nodeMCU) connected to motion sensor and it works fine with cayenne. Problem is that i want make schedules so it start to be active only if i leave my home so in certain time in day.If i leave it active24/7 then it alert me every time im walking home whish is useless. I think its not possible with cayenne to schedule triger alerts.
BTW anyone have idea if its possible resolve in arduino code?
thanks!


#2

That’s a pretty good idea. You can definitely do it in Arduino code but it would get a bit complicated. Ideally you would need a real time clock module, but syncing with an NTP server would be ok. In the main loop use code like if time of day is right then run the cayenne loop else do nothing.


#3

Hello ! i find some solution !

When i cabling motion sensor i put 5V on a relay, who is command by one GPIO. I make widget for turn on or off this GPIO, like this i can turn on or off when i want (:


#4

@adrien.testas there is another way. add a button widget with virtual pin 2.
then read the status.
int x;
int y;
if (millis() - lastMillis1 > 10000)
{
lastMillis1 = millis();
Cayenne.virtualWrite(3, y, “digital_sensor”, “d”);
}
if (x == 1)
{
y = digitalRead(motionPin);
}
else
{
y = 0;
}
CAYENNE_IN(2)
{
int currentValue = getValue.asInt();
if (currentValue == 1)
{
x = 1;
}
else
{
x = 0;
}
}