wireless door / window sensor



  • guys,
    did anyone build up a wireless door or windows sensor yet?
    For example with this one?
    433 wireless door sensor

    I guess it shouldn't be too hard to hack this.

    Cheers,
    SJ



  • I built a window and a door sensor, just using a normal magnetic switch as proposed in this example. They are working quite well and are powered by a coin cell battery.



  • @mortommy thank you. So you have the whole thing incl. the Arduino powered by a battery?
    That would work most probably but is too bulky for me. Don't like to have a too big case dangling around on my windows. Also using a wireless could save a few arduinos. I give it a shot and order a few and let you know the outcome.
    SJ



  • Most of these cheap sensors are based on PT2622 chip or similar. RF link works fine with them.



  • @mikee thank you, that ensures my thoughts. There will be SALE on Aliexpress tomorrow...



  • I heard about a new radio chip monitoring window sensor? Have anyone heard about this? It warns when the windows are left open. It powers up with energy provided by solar power and the maintenance is also easy. Is it good for preventing the break-ins?



  • @all
    When the window sensors from above arrived, receiving the wireless signal was easy. I noted that they only report open and not change when closed, so I tried to "fix" it but failed after a few hours of improving the original hardware. I took all electronics out and fittet an Arduino pro mini, radio and a reed switch into the case easily.

    Quite expensive after all but exactly what I wanted. I still do have two laying here and not sure if I shall remodel them or go with an out of the box sensor from Homematic here...


  • Contest Winner

    Kind of off topic but personally when I struggle too much in repurposing an existing radio sensor I go with this https://github.com/merbanan/rtl_433, attach a 7$ DVB dongle to a raspberry or equivalent, connect a proper antenna and decode the signal (which is usually pretty easy when it comes to cheap sensors). Of course the learning curve can be quite steep at the beginning so it is not convenient in every situation.

    A bit more on topic, if I have understood correctly, the example at https://www.mysensors.org/build/binary is not suitable for a sleeping sensor cause debouncing and sleeping do not play well together. For a sleeping sensor what I did was attaching to an interrupt and if waking up on CHANGE you get a message when the door/window opens as well as closes. If anybody is interest can copy the relevant code from the SensorDoor of https://sourceforge.net/projects/mynodemanager/



  • @user2684
    correct, debouncing does not work. below is my code which works pretty well.
    I forgot the power drain but it was very minimal. The major "problem" are the standard reed switches which are <normally open>
    that means in most cases when the door is closed, the switch is closed as well and this means the circuit is also closed and power flows which results in a factor 10 higher power consumption. The solution is to use a <normally closed> reed switch which will turn it around (circuit closed when door is open).
    At least in my case, the door is 98% of the time closed and therefore power consumption is less during close phase.

    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <SPI.h>
    #include <MySensors.h>
    //#include <Bounce2.h>
    #include <Vcc.h>
    
    #define CHILD_ID 3
    #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
    
    //Bounce debouncer = Bounce();
    int oldValue = -1;
    
    float oldVolts = 0;
    const float VccExpected   = 3.00;
    const float VccCorrection = 3.0 / 3.0; // Measured Vcc by multimeter divided by reported Vcc
    Vcc vcc(VccCorrection);
    static int oldBatteryPcnt = 0;
    
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()
    {
      // Setup the button
      pinMode(BUTTON_PIN, INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN, HIGH);
    
      // After setting up the button, setup debouncer
    //  debouncer.attach(BUTTON_PIN);
    //  debouncer.interval(5);
    
    }
    
    void presentation() {
      // Register binary input sensor to gw (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      present(CHILD_ID, S_DOOR);
    }
    //  Check if digital input has changed and send in new value
    void loop()
    {
    //  debouncer.update();
      // Get the update value
      // int value = debouncer.read();
      int value = digitalRead(BUTTON_PIN);
      wait(100);
      if (value != oldValue) {
        // Send in the new value
        send(msg.set(value == HIGH ? 1 : 0));
        oldValue = value;
      }
      //BAtterie
      int batteryPcnt = (int)vcc.Read_Perc(VccExpected);
      float volts = (float)vcc.Read_Volts();
      int myPerc = volts * 100 / VccExpected;
      Serial.print("Battery percent: ");
      Serial.print(myPerc);
      Serial.println(" %");
    
      Serial.print("Volts: ");
      Serial.print(volts);
      Serial.println(" V");
      if (oldBatteryPcnt != myPerc)
      {
        sendBatteryLevel(myPerc);
        oldBatteryPcnt = myPerc;
      }
    
      sleep(1, CHANGE, 0);
    }```


  • @user2684
    it was not so much figuring out the 433 signal/transport, the hardware just did not capture the close phase of the switch. I guess this is due to the issue I explained in the other reply regarding power consumption and they just cut that off somehow in order to make the batteries last longer. But thanks a lot for the link, will check this out


  • Contest Winner

    Oh you're right, also the "Magnetic Door Switch Sensor" from the example https://www.mysensors.org/build/binary is normally closed. I read somewhere a high value resistor can help in limiting the current flow in these situations but never tried myself



  • If you need a signal both if the window was closed and opened you can buy this sensor:
    https://www.aliexpress.com/item/Free-shipping-Wireless-window-and-door-magnetic-sensor-open-detector-1527-chips/32334214010.html
    It is based on a 1527 Chip.
    Open the rear cover and connect these pins with a solder point:
    0_1490295555056_433MHz Reed Sensor small.jpg


Log in to reply
 

Suggested Topics

  • 87
  • 2
  • 6
  • 8
  • 10
  • 7

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts