How to connect QUIP300 to Domoticz



  • Dear all,

    I would like to ask for your kind support with this PIR. Currently i'm using Arduino UNO (few relays ) as a gateway to Domoticz system installed on my QNAP ( connected via USB cable) . Everything works perfect.

    Now i found that i have old security system which is unused. And there are 4 PIR as on the attached photo.
    alt text
    Is the any chance to conect to my controler(DOMOTICZ) ?
    (ESP8266 Arduino Uno, Raspberry PiOW) ?
    Thanks in advance for any suggestion!

    Best regards.


  • Mod

    if you find the digital output pin you can use a nano or a mini pro with the motion sensor sketch


  • Hardware Contributor

    Hello, be careful as it's powered with 12V and if I believe the doc in Google results min voltage is 8V do it will fry your Arduino.
    There's a relay output on the top right that you could use but it's probably 12V. What's more interesting is the LED connector below the relay output, you should check what voltage you have there when the PIR is triggered.



  • Thank you Nca78 & gohan.
    Sensor is working very well conected to Wemos D1 mini under Domoticz control. Not i'm testing with 9V battery .
    I faced some problems with conection to Arduino . Basic sketch for motion sensor not working for my setup.
    Any clues how to modify my current sketch ? (for relays)
    0_1497042712762_GatewaySerialWired.ino

    Thank you.


  • Mod

    I can't see your sketch. What problem are you having exactly?



  • Hello Gohan ,

    Here is my sketch. Arduino is conected via uSB cable to my QNAP.
    And there is few relays conected to Arduino. I would like to avoid wireless conection.

    Now i would like to add PIRs to this sketch.

    
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level. 
    //#define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    // Flash leds on rx/tx/err
    // #define MY_LEDS_BLINKING_FEATURE
    // Set blinking period
    // #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    // #define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    #define MY_INCLUSION_BUTTON_FEATURE
    
    // Inverses behavior of inclusion button (if using external pullup)
    //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
    
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60 
    // Digital pin used for inclusion mode button
    #define MY_INCLUSION_MODE_BUTTON_PIN  3 
    
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <Bounce2.h>
    
    // Enable repeater functionality for this node
    #define MY_REPEATER_FEATURE
    
    
    #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    #define BUTTON_PIN A1
    
    
    void before() { 
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    Bounce debouncer = Bounce();
    
    void setup() { 
      // Setup locally attached sensors
      delay(10000);
       // Setup the button.
      pinMode(BUTTON_PIN, INPUT_PULLUP);
      // After setting up the button, setup debouncer.
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(5);
      //presentation();
    }
    void presentation()  
    {   
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relay", "1.0");
    
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    }
    
    MyMessage msg(1, V_LIGHT);
    
    void loop() { 
      // Send locally attached sensor data here 
      if (debouncer.update()) {
        // Get the update value.
        int value = debouncer.read();
        // Send in the new value.
        if(value == LOW){
             saveState(1, !loadState(1));
             digitalWrite(RELAY_1, loadState(1)?RELAY_ON:RELAY_OFF);
             send(msg.set(loadState(1)));
        }
      }
    }
    
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         saveState(message.sensor, message.getBool());
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
       } 
    }
    
    
    
    

    How to make it ? I'm newbie - sorry.

    Regards.


  • Mod

    Just copy the code from motion sensor sketch, assign a child ID to the pir sensor, present it and in code just check pin status with digitalread() and send value changed from last send



  • Hey gohan, thanks - basic sketch will do the job.
    I faced another problem. Now i've conected one of the PIR via WemosD1 mini with ESP Easy.0_1497208049084_DSC_0864.JPG
    And works very well.
    But i would like to connect 3 more sensors.
    Power supply for PIR and Wemos is different and there is only one GND pin .
    Any idea how to make it?


  • Mod

    3 more sensor to the same wemos?



  • Yes. Possible?


  • Mod

    With mysensors it is possible, with esp easy I don't know.



  • I can swich to MySensors- no problem.



  • Hi Gohan, please see my set up i more details.
    Each of PIR is conected to old/not used alarm control panel.
    Now it is used as power supply. I've just ordered Arduino Nano + nRF24L01 to conect all motion sensors. I would like to use one of free port to power my node (thru voltage step down : 12V->5V)
    0_1497296131460_sensors.JPG
    How should i conect sensors to node?


  • Mod

    Do you want to put the nano in that panel?



  • Hi, panel will be use as a power supply only.


  • Mod

    Ok, but if you put the nano in that location you will have the yellow cables coming back from the PIR sensors and you would have to use those to connect to digital pins of the arduino, the problem is that you need to check what is the voltage that most likely will be over 5V and you would need to find a way to lower it.



  • Yellow cable is connected to PIR's relay. And this cable i'm going to conect to digital input of arduino.
    Second cable from PIR's relay will be connnected to arduino's GND pin. ( not shown on this photo).
    There is no voltage on PIR's relay ( works as simple switch).
    Is my understanding correct ?


  • Mod

    If it is just a relay ok, I thought you were using the output of the pir sensor, but always check before connecting to the Arduino



  • So how to connect 4 PIRs to one node to be able to see in Domoticz which was acivated ?


  • Mod

    Connect each one on a different digital pin and create a different child id for each pir sensor and present all of them, it is just replicating 4 times the code of the motion sensor sketch.



  • Last question: one pin of each PIR's relay must be connected to common Arduino GND pin, right ?


  • Mod

    it depends, you could also wire it to the 5V and detect when the digital pin goes high you have movement.



  • THank you Gohan. Now everything is more clearer. 🙂 Will try today to wire everything.



  • Hi GOHAN,

    Finally i've build my serial gateway ( Arduino UNO + nRF24) + node (Arduino Nano + nRF24) but i failed with PIR conection to my NODE. How should i connect PIR's relay to Nano ? ( digital input + GND ) ?
    Now i know that relay is normally closed ( 0, 1 state, no power on it)
    I was trying to connect this way and it was working for few second ( i saw in the serial monitor , 1 , 0) but after some time NODE was sending weird data to GW.
    How connect it corectlly and how to mod the sketch for more sensors? (4 pcs). ```
    This is the way ?

    #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
    #define DIGITAL_INPUT_SENSOR 4   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 2   // Id of the sensor child```

  • Mod

    IF the pir sensor has a normally closed relay you need to use the 5v output of the arduino to one pin of the relay and the other to the digital input and use the code to send TRIPPED true message when pin goes LOW and TRIPPED false when pin is high



  • Hi Gohan,

    This is the way i should follow ?:

    	// Read digital motion value
    	
      if(digitalRead(DIGITAL_INPUT_SENSOR) == HIGH){
        tripped = true;
      } else {
        tripped = false;
      }
    

    Not so easy to set 🙂


  • Mod

    actually the opposite, then you need to send the tripped value. Pls check the logic with the relay on the sensor



  • If my understanding is correct it works as follows:
    (HIGH : when relay is closed, connected to digital pin & 5V VCC)
    1- HIGH->TRUE-> msg.set 1
    2- LOW->FALSE->msg.set 0

    It works but it's very unstable. Sometimes working sometimes not.
    Is it necessary to add some resistors to this circuit?


  • Mod

    In this case you need to debug where problem is, if it is the relay not closing, the arduino not getting the pin change or message send failed. Also pls post all the code you are using.



  • Relay is working correctly, checked with multimeter. Now i'm study about debugging.
    Below is the code i'm using (4 PIRs).
    Problem with sleep mode?

    
    // Enable debug prints
    // #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <MySensors.h>
    #define MY_NODE_ID AUTO
    unsigned long SLEEP_TIME = 5000 ; // 120000 Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR1 2   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define DIGITAL_INPUT_SENSOR2 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define DIGITAL_INPUT_SENSOR3 4   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define DIGITAL_INPUT_SENSOR4 5   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    
    #define CHILD_ID_PIR1 21   // Id of the sensor child
    #define CHILD_ID_PIR2 22   // Id of the sensor child
    #define CHILD_ID_PIR3 23   // Id of the sensor child
    #define CHILD_ID_PIR4 24   // Id of the sensor child
    
    // Enable repeater functionality for this node
    #define MY_REPEATER_FEATURE
    
    // Initialize motion message
    MyMessage msg1(CHILD_ID_PIR1, V_TRIPPED);
    MyMessage msg2(CHILD_ID_PIR2, V_TRIPPED);
    MyMessage msg3(CHILD_ID_PIR3, V_TRIPPED);
    MyMessage msg4(CHILD_ID_PIR4, V_TRIPPED);
    
    void setup()
    {
      pinMode(DIGITAL_INPUT_SENSOR1, INPUT);      // sets the motion sensor digital pin as input
      pinMode(DIGITAL_INPUT_SENSOR2, INPUT);      // sets the motion sensor digital pin as input
      pinMode(DIGITAL_INPUT_SENSOR3, INPUT);      // sets the motion sensor digital pin as input
      pinMode(DIGITAL_INPUT_SENSOR4, INPUT);      // sets the motion sensor digital pin as input
     }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("PIR Sensor", "0.1");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_PIR1, S_MOTION);
      present(CHILD_ID_PIR2, S_MOTION);
      present(CHILD_ID_PIR3, S_MOTION);
      present(CHILD_ID_PIR4, S_MOTION);
    }
    
    void loop()
    {
    // Read digital motion value (PIR1)
      bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH;
      if(digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH)
        tripped1 = true;
       else 
        tripped1 = false;
    // Read digital motion value (PIR2)
      bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH;
      if(digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH)
        tripped2 = true;
       else 
        tripped2 = false;
    // Read digital motion value (PIR3)
       bool tripped3 = digitalRead(DIGITAL_INPUT_SENSOR3) == HIGH;    
       if(digitalRead(DIGITAL_INPUT_SENSOR3) == HIGH)
        tripped3 = true;
       else 
        tripped3 = false;
    // Read digital motion value (PIR4)
      bool tripped4 = digitalRead(DIGITAL_INPUT_SENSOR4) == HIGH;
      if(digitalRead(DIGITAL_INPUT_SENSOR4) == HIGH)
        tripped4 = true;
       else 
        tripped4 = false;
      
    
      
      Serial.println(tripped1);
      send(msg1.set(tripped1?"1":"0"));  // Send tripped value to gw
      
      Serial.println(tripped2);
      send(msg2.set(tripped2?"1":"0"));  // Send tripped value to gw
    
      Serial.println(tripped3);
      send(msg3.set(tripped3?"1":"0"));  // Send tripped value to gw
      
      Serial.println(tripped4);
      send(msg4.set(tripped4?"1":"0"));  // Send tripped value to gw
      
    // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR1), CHANGE, SLEEP_TIME);
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR2), CHANGE, SLEEP_TIME);
          sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR3), CHANGE, SLEEP_TIME);
            sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR4), CHANGE, SLEEP_TIME);
    
    
    }
    

  • Mod

    You can use only 2 interrupts on pin 2 and 3, calling 4 sleep functions is useless


Log in to reply
 

Suggested Topics

  • 87
  • 2
  • 3
  • 1
  • 6
  • 7

17
Online

11.2k
Users

11.1k
Topics

112.5k
Posts