Motion sensor(s) send false trigger a few minutes after motion occured.



  • I am using motion sensors combined with Domoticz on pi and an alarm relay.
    The problem is intermittent false motion activation being sent just a few minutes after all rooms are vacated. If it gets past the first few minutes then everything works as expected.
    I am using the standard motion sketch combined with battery level.

    void loop()
    {
    	// Read digital motion value
    	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    
    	Serial.println(tripped);
    	send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
    
    	// Sleep until interrupt comes in on motion sensor. Send update every two minute.
    	sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    
      // get the battery Voltage
      delay(500);
      int sensorValue = analogRead(BATTERY_SENSE_PIN);
    #ifdef MY_DEBUG
      Serial.println(sensorValue);
    #endif
    

    Battery levels get reported every 2 minutes. Occasionally battery reports do not get through. Sometimes a single sensor will just give up sending battery reports? (still working on this problem).

    I am wondering if the motion trigger messages before I leave a room somehow get queued and then eventually get sent after the system is armed? Is that possible? What happens to a message if it cannot get through?

    The only other think I have thought of is that the sleep happens inbetween the motion trigger message and the battery read.



  • @grumpazoid You don't say what sensors you are using but I assume a pir of some sort.

    Many pir modules have a time delay setting on board. If this is set higher than your sleep period a trigger detection will stay high (or low) for the delay period and may still be active when the node awakes to check the pin (which it does as a by product of sending battery levels). Find the delay adjustment and set for the minimum time delay possible.

    Another point is why send battery levels every 2 minutes? This will drain the battery very fast. Once a day should do. You cann have the node send you an alert when it reaches a certain point. Don't forget that batteries are temperature sensitive and levels will vary on hot and cold days.

    I hope this helps! 😉



  • If you are using an HC-sr501, they can be very sensitive to the voltage supply. Sometimes sleeping a few ms without interrupts can avoid false trips -- like this:

    sleep(5);  //Allow PIR to settle without interrupts
    // Sleep until interrupt comes in on motion sensor. Send update every two minute.
    sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    


  • @skywatch Thanks. Am using HC-SR-501. I have them set on lowest time so they trip for 1-2 seconds. My alarm code takes 15s to arm so they should all be back to off by then.

    I read battery levels every 2 minutes as I also use this information to make sure the sensor is still alive. This works well for the most part however I do get intermittent sequences of missed battery reports. I think this is more to do with NRF24L01+.
    I am using single 18650 cells and getting many months from them - I have all LEDs and regulators removed. Both arduino and PIR run directly on 3.3V from a 662K regulator.
    Battery level is also sent when the PIR is triggered as both parts are in the sketch loop - but that is fine.

    I am currently using the serial gateway on a pi B, but plan to build an ethernet gateway and see if that helps with things. I also plan to relocate it to a more central point in the house.

    @nagelc Thanks...that is food for thought. So would your code make the aduino sleep for 5ms, then wake, then sleep again until there is either an interrupt or the sleep time has elapsed? OR does it sleep for 5ms, then carry on sleeping?

    I use a delay before my battery reading is taken to let thinks settle. Do you think delay would work here also?

    I have tested the system today, and it has behaved perfectly. I am still thinking that something starts to run slow and messages get delayed somewhere.



  • I don't know the inner workings of the library, but it seems to just keep sleeping. I had some sensors that would go to sleep then immediately wake up on motion detected. I found some threads in the forum that indicted the powering down as devices are put into sleep mode caused a big enough variation in the power line that the motion detector would trip and wake the system again. Using some caps on the PIR power input is probably a better approach, but this was easy and seemed to work.


  • Mod


Log in to reply
 

Suggested Topics

  • 3
  • 4
  • 2
  • 2
  • 1
  • 24

22
Online

11.2k
Users

11.1k
Topics

112.5k
Posts