New nodes, new problems :/ Motion sensor [Solved]



  • I have a new node, a motion sensor node with repeater.
    Sometimes, when another node change state and communicates through my new repeating node or if another node searching for a new parent, the new repeating node triggers the motion sensor.
    Another strange thing is, 3 times an hour the node triggers the motion.

    This is when i am not home.
    Check time stamp
    19:01 Motion Sensor TV 4 1 turned off
    19:01 Motion Sensor TV 4 1 turned on
    18:41 Motion Sensor TV 4 1 turned off
    18:41 Motion Sensor TV 4 1 turned on
    18:21 Motion Sensor TV 4 1 turned off
    18:21 Motion Sensor TV 4 1 turned on
    18:06 Väder changed to 2
    18:01 Motion Sensor TV 4 1 turned off
    18:01 Motion Sensor TV 4 1 turned on
    17:41 Motion Sensor TV 4 1 turned off
    17:41 Motion Sensor TV 4 1 turned on
    17:21 Motion Sensor TV 4 1 turned off
    17:21 Motion Sensor TV 4 1 turned on
    Just can't figure what makes it trigger on exact times.
    Even if i reset the node it triggers on same times.

    This is the sketch

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     * 
     * DESCRIPTION
     * Example sketch showing how to create a node thay repeates messages
     * from nodes far from gateway back to gateway. 
     * It is important that nodes that has enabled repeater mode calls  
     * process() frequently. Repeaters should never sleep. 
     */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_RF24_PA_LEVEL RF24_PA_MAX
    
    // Enabled repeater feature for this node
    #define MY_REPEATER_FEATURE
    #define MY_NODE_ID 4
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC
    
    #include <SPI.h>
    #include <MySensors.h>
    
    //unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 1   // Id of the sensor child
    
    boolean previousTripped = LOW;
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup() {
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input  
    }
    
    void presentation()  
    {  
      //Send the sensor node sketch version information to the gateway
      sendSketchInfo("Motion Sensor TV", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_MOTION);
    }
    
    void loop() 
    {
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      //Serial.println(tripped);
      // Sensor must be HIGH and not yet sent the status of the sensor
      if ((tripped == HIGH) && (tripped != previousTripped) ) {     
        send(msg.set(tripped ? "1" : "0")); // Send tripped value to gw
        previousTripped = tripped;   
      }  
      
      // Is sensor low and not sent? Then send LOW to gateway
      if ((tripped == LOW) && (tripped != previousTripped)) {    
          send(msg.set(tripped ? "1" : "0")); // Send tripped value to gw
          previousTripped = tripped;
      }
    }
    

    Even tried this sketch but i get the same result.

    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_RF24_PA_LEVEL RF24_PA_MAX
    
    #define MY_NODE_ID 4
    #define MY_REPEATER_FEATURE
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC
    
    #include <SPI.h>
    #include <MySensors.h>
    
    #define CHILD_ID 1   // Id of the sensor child
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    
    int oldTripped = 0;
    int tripped = 0;
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()  
    {  
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Motion Sensor TV", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_MOTION);
    }
    
    void loop()     
    {
         
    //Read digital motion value
    tripped = digitalRead(DIGITAL_INPUT_SENSOR);
    
    if (tripped != oldTripped){
      Serial.println("Motion");
      send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
      oldTripped = tripped;
    }}
    

  • Mod

    Power fluctuations during transmission can trigger pir sensor: try using a 47-100 uF capacitor to stabilize power



  • Just tried it but still same problem.
    I am suspecting hardware issues but always same time stamp makes me wonder.


  • Mod

    you tell me if you notice some coincidences 😄



  • I had that problem when use ESP8266 as active WiFi source near PIR sensor..


  • Plugin Developer

    @xydix

    I also think it's the radio transmissions that causes the sensor to trigger. One thing that happens every 20 min by default is the gateway sends a discover request broadcast. This will force all repeaters to resend that broadcast. You can test to change the interval of this broadcast at the gateway and see if the false triggers timing follows.

    The setting is called MY_TRANSPORT_DISCOVERY_INTERVAL_MS. You can define this in the gateway sketch to override the default setting.


  • Mod

    If that is the case then it could still be a power issue



  • I'd suggest to add capacitors: 47uF for radio and for PIR. Maybe this way power will be more smooth



  • Thank you @martinhjelmare for that answer. It explains it. i Can confirm this is the issue.
    The pir i am using is this one, the mini pir.
    http://www.ebay.com/itm/121880058682?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

    I tried another pir, the HC-SR501 (http://www.ebay.com/itm/201414880948?rmvSB=true)
    This pir is working ok with the node as it is.
    First i tried an 100uF capacitor as @gohan suggested, but it didn't help.
    Now i tried an 470uF capacitor and it seems to be fine with the mini pir.

    @Vladimir-Dobrikov my radio already got an 100uF for the 3,3V circuit.
    Im am still testing but the node it seems fine for now.
    Thank you all for the help.



  • I guess this thread should be in the hardware forum.
    But if someone find this thread i can share some pictures and the idea with this node.
    I built it as a USB-stick with a USB-connector on a prototype PCB.
    Not good looking but when i get my TV up on the wall you can't see it.
    I use it to turn on light in the bathroom at night if my kids visit the toilet.
    0_1491467736631_IMG_20170406_102320.jpg
    0_1491467746038_IMG_20170406_102342.jpg


Log in to reply
 

Suggested Topics

  • 1
  • 5
  • 5
  • 2
  • 3

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts