How to connect QUIP300 to Domoticz
-
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``` -
-
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 0It works but it's very unstable. Sometimes working sometimes not.
Is it necessary to add some resistors to this circuit? -
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); }