issues - most likely caused by light setting
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -98,7 +98,7 @@ void setup() {
|
||||
|
||||
const int millisPerSecond=1000;
|
||||
long previousMotionMillis=millis();
|
||||
short previousState=0;
|
||||
short previousState=-1;
|
||||
long previousNoMoNotifyMinutes=0;
|
||||
|
||||
void loop() {
|
||||
@@ -108,6 +108,9 @@ void loop() {
|
||||
mqttClient.loop();
|
||||
|
||||
short currentState = digitalRead(PIR_PIN);
|
||||
// This out pin triggering is dependent not only on movement, but also on light levels which can be configured in the app.
|
||||
// I set it to 255 and "below" - this triggered it for me.....
|
||||
//send_mqtt("occupancy_state_debug", currentState);
|
||||
if (currentState != previousState) {
|
||||
Serial.print("Status changed; currentState: ");
|
||||
Serial.print(currentState);
|
||||
@@ -118,6 +121,7 @@ void loop() {
|
||||
digitalWrite(LED_BUILTIN,HIGH);
|
||||
previousMotionMillis=millis();
|
||||
} else {
|
||||
send_mqtt("no_motion_ignore");
|
||||
digitalWrite(LED_BUILTIN,LOW);
|
||||
}
|
||||
previousState = currentState;
|
||||
@@ -126,9 +130,9 @@ void loop() {
|
||||
const int secondsPerMinute=60;
|
||||
long minutesSinceLastMotion=(millis()-previousMotionMillis)/(millisPerSecond*secondsPerMinute);
|
||||
if ((previousNoMoNotifyMinutes != minutesSinceLastMotion) && (0 != minutesSinceLastMotion)) {
|
||||
send_mqtt("no_motion",minutesSinceLastMotion);
|
||||
send_mqtt("no_motion", minutesSinceLastMotion);
|
||||
previousNoMoNotifyMinutes = minutesSinceLastMotion;
|
||||
}
|
||||
|
||||
delay(20);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user