o and i forget to ask if this product is a better option .
Rene046
Posts
-
💬 Soil Moisture Sensor -
💬 Soil Moisture Sensorhow did you wire you normal fork sensor, i get different reading when using a voltage divider if i switch the polarization.
i used this to connect it.
http://www.electronicwings.com/sensors-modules/soil-moisture-sensor
using pin digital 6 and 7 as alternating power, and pin A0 to readAnd how do other people protect there capacitive sensor electronics from water .. rain
-
Get date from Domoticz into NodeHi there,
How can i take the data from a dimmer position out of Domoticz from my node, so i can use it to control a Mosfet.
I tried without luck..
request( Dimvalue, V_DIMMER );but think its not that simple...
kind regards Rene
-
Analog to digital how ?All working fine sometimes the pir reaction could be a bid faster, and sometimes i get a false reading think i'll have to put the pir signal lines to the ground with an resistor.
Any advice is welcome, to make thing faster, and less complex.
else use this with fun......#define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #define MY_DEBUG #include <Wire.h> // Wire library t.b.v. I²C #include <MySensors.h> byte GPIOA = 0x12; // GPIOA adres in 16-bit mode, is directe aansturing 1e groep van 8 I/O poorten. byte GPIOB = 0x13; // GPIOA adres in 16-bit mode, is directe aansturing 1e groep van 8 I/O poorten. boolean sensorBovenActive; // Status of Pir motion sensor 2. boolean sensorOnderActive; // Status of Pir motion sensor 1. boolean sensorKelderActive; // Status of Pir motion sensor 0. int PIR0new; // Pir motion sensor 0 updated value "Kelder". int PIR0old; // Pir motion sensor 0 old value "Kelder". int PIR1new; // Pir motion sensor 1 updated value "sensorOnderActive". int PIR1old; // Pir motion sensor 1 old value "sensorOnderActive". int PIR2new; // Pir motion sensor 2 updated value. "sensorBovenActive" int PIR2old; // Pir motion sensor 2 old value. sensorBovenActive" int StairDelay = 250; // Delay for stairs int StairOn = 30000; // Delay to keep stair light on #define MY_NODE_ID 30 #define CHILD_ID_PIR00 31 // Id of the sensor child #define CHILD_ID_PIR01 32 // Id of the sensor child #define CHILD_ID_PIR02 33 // Id of the sensor child void presentation(){ // Send the sketch version information to the gateway and Controller sendSketchInfo("Trap Controller", "4.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR00, S_MOTION, "PIR Sensor Kelder"); present(CHILD_ID_PIR01, S_MOTION, "PIR Sensor Trap Onder"); present(CHILD_ID_PIR02, S_MOTION, "PIR Sensor Trap Boven"); } // Initialize motion message MyMessage msgPIR00(CHILD_ID_PIR00, V_TRIPPED); MyMessage msgPIR01(CHILD_ID_PIR01, V_TRIPPED); MyMessage msgPIR02(CHILD_ID_PIR02, V_TRIPPED); // the setup routine runs once when you press reset: void setup() { Wire.begin(); // wake up I2C bus // set I/O pins to outputs Wire.beginTransmission(0x20); // Start adress of mcp23017 Wire.write(0x00); // IODIRA register Wire.write(0x00); // set all of port A to outputs Wire.endTransmission(); Wire.beginTransmission(0x20); Wire.write(0x01); // IODIRB register Wire.write(0x00); // set all of port B to outputs Wire.endTransmission(); } // the loop routine runs over and over again forever: void loop() { Pir0lezen(); Pir1lezen(); Pir2lezen(); effneerop(); effopneer(); effKelder(); } void Pir0lezen() { int PIR0new = analogRead(A0); if (PIR0new >=900) { sensorKelderActive = true; // Send status to Domoticz send (msgPIR00.set(sensorKelderActive?"1":"0")); Serial.println("PIR0new----"); Serial.println(PIR0new); PIR0old = PIR0new; sensorKelderActive = false; send (msgPIR00.set(sensorKelderActive)); }} void Pir1lezen() { int PIR1new = analogRead(A1); if (PIR1new != PIR1old && PIR1new >=710) { sensorOnderActive = true ; sensorBovenActive = false ; // Send status to Domoticz send (msgPIR01.set(sensorOnderActive?"1":"0")); Serial.println("PIR1----"); Serial.println(PIR1new); PIR1old = PIR1new; }} void Pir2lezen() { int PIR2new = analogRead(A2); if (PIR2new != PIR2old && PIR2new >=710) { sensorBovenActive = true ; sensorOnderActive = false ; // Send status to Domoticz send (msgPIR02.set(sensorBovenActive?"1":"0")); Serial.println("PIR2----"); Serial.println(PIR2new); PIR2old = PIR2new; }} void effopneer() { if (sensorOnderActive==true && sensorBovenActive==false){ Serial.println("PIR1--aan"); sensorOnderActive = false ; setLEDA(B01111111); // Tree 1 delay(StairDelay); setLEDA(B00111111); // Tree 2 delay(StairDelay); setLEDA(B00011111); // Tree 3 delay(StairDelay); setLEDA(B00001111); // Tree 4 delay(StairDelay); setLEDA(B00000111); // Tree 5 delay(StairDelay); setLEDA(B00000011); // Tree 6 delay(StairDelay); setLEDA(B00000001); // Tree 7 delay(StairDelay); setLEDA(B00000000); // Tree 8 delay(StairDelay); setLEDB(B01111111); // Tree 9 delay(StairDelay); setLEDB(B00111111); // Tree 10 delay(StairDelay); setLEDB(B00011111); // Tree 11 delay(StairDelay); setLEDB(B00001111); // Tree 12 delay(StairDelay); setLEDB(B00000111); // Tree 13 delay(StairDelay); setLEDB(B00000011); // Tree 14 send (msgPIR01.set(sensorOnderActive)); // switch off before delay delay(StairOn); setLEDA(B11111111); // all off setLEDB(B11111111); // all off Serial.println("PIR1--uit"); }} void effneerop() { if (sensorOnderActive==false && sensorBovenActive==true){ Serial.println("PIR2--aan"); sensorBovenActive = false ; setLEDB(B11111011); // Tree 14 delay(StairDelay); setLEDB(B11110011); // Tree 13 delay(StairDelay); setLEDB(B11100011); // Tree 12 delay(StairDelay); setLEDB(B11000011); // Tree 11 delay(StairDelay); setLEDB(B10000111); // Tree 10 delay(StairDelay); setLEDB(B00000011); // Tree 9 delay(StairDelay); setLEDA(B11111110); // Tree 8 delay(StairDelay); setLEDA(B11111100); // Tree 7 delay(StairDelay); setLEDA(B11111000); // Tree 6 delay(StairDelay); setLEDA(B11110000); // Tree 5 delay(StairDelay); setLEDA(B11100000); // Tree 4 delay(StairDelay); setLEDA(B11000000); // Tree 3 delay(StairDelay); setLEDA(B10000000); // Tree 2 delay(StairDelay); setLEDA(B00000000); // Tree 1 send (msgPIR02.set(sensorBovenActive)); delay(StairOn); setLEDA(B11111111); // all off setLEDB(B11111111); // all off Serial.println("PIR2--uit"); }} void effKelder() { } void setLEDA(byte value) { Wire.beginTransmission(0x20); Wire.write(GPIOA); // gpioa Wire.write(byte(value)); // set LEDs volgens waarde 'value' Wire.endTransmission(); } void setLEDB(byte value) { Wire.beginTransmission(0x20); Wire.write(GPIOB); // gpiob Wire.write(byte(value)); // set LEDs volgens waarde 'value' Wire.endTransmission(); } void bonuseff() { setLEDB(B11111011); // Tree 14 delay(StairDelay); setLEDB(B11110111); // Tree 13 delay(StairDelay); setLEDB(B11101111); // Tree 12 delay(StairDelay); setLEDB(B11011111); // Tree 11 delay(StairDelay); setLEDB(B10111111); // Tree 10 delay(StairDelay); setLEDB(B01111111); // Tree 9 delay(StairDelay); setLEDA(B11111110); // Tree 8 delay(StairDelay); setLEDA(B11111101); // Tree 7 delay(StairDelay); ; setLEDA(B11111011); // Tree 6 delay(StairDelay); ; setLEDA(B11110111); // Tree 5 delay(StairDelay); setLEDA(B11101111); // Tree 4 delay(StairDelay); setLEDA(B11011111); // Tree 3 delay(StairDelay); setLEDB(B10111110); // Tree 2 delay(StairDelay); setLEDB(B01111111); // Tree 1 delay(StairDelay); setLEDA(B10111111); // Tree 2 delay(StairDelay); setLEDA(B11011111); // Tree 3 delay(StairDelay); setLEDA(B11101111); // Tree 4 delay(StairDelay); setLEDA(B11110111); // Tree 5 delay(StairDelay); setLEDA(B11111011); // Tree 6 delay(StairDelay); setLEDA(B11111101); // Tree 7 delay(StairDelay); setLEDA(B11111110); // Tree 8 delay(StairDelay); setLEDB(B01111111); // Tree 9 delay(StairDelay); setLEDB(B10111111); // Tree 10 delay(StairDelay); setLEDB(B11011111); // Tree 11 delay(StairDelay); setLEDB(B11101111); // Tree 12 delay(StairDelay); setLEDB(B11110111); // Tree 13 delay(StairDelay); setLEDB(B11111011); // Tree 14 }``` -
Analog to digital how ?Thx
I already got it running after a long night ...lol
here is what i have sofar...
#define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #define MY_DEBUG //#include <SPI.h> #include <MySensors.h> boolean sensorUpperActive; // boolean sensorBottomActive; int sensorBottomActive; int PIR1new; int PIR1old; int PIR2new; int PIR2old; boolean PIR00; #define MY_NODE_ID 30 #define CHILD_ID_PIR00 31 // Id of the sensor child #define CHILD_ID_PIR01 32 // Id of the sensor child #define CHILD_ID_PIR02 33 // Id of the sensor child void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "4.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR00, S_MOTION, "PIR Sensor 0"); present(CHILD_ID_PIR01, S_MOTION, "PIR Sensor 1"); present(CHILD_ID_PIR02, S_MOTION, "PIR Sensor 2"); } // Initialize motion message MyMessage msgPIR00(CHILD_ID_PIR00, V_TRIPPED); MyMessage msgPIR01(CHILD_ID_PIR01, V_TRIPPED); MyMessage msgPIR02(CHILD_ID_PIR02, V_TRIPPED); // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: // Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); } // the loop routine runs over and over again forever: void loop() { Pir0lezen(); Pir1lezen(); Pir2lezen(); effopneer(); effneerop(); Tegelijk(); // delay(1000); // delay in between reads for stability } void Pir0lezen() { int PIR0 = analogRead(A0); if (analogRead(A0) >=700) { Serial.println("PIR0----"); Serial.println(PIR0); PIR00 = true; }} void Pir1lezen() { int PIR1new = analogRead(A1); if (PIR1new != PIR1old && PIR1new >=700) { sensorBottomActive = true ; send (msgPIR01.set(sensorBottomActive?"1":"0")); // Send status to Domoticz Serial.println("PIR1----"); Serial.println(PIR1new); PIR1old = PIR1new; }} void Pir2lezen() { int PIR2new = analogRead(A2); if (PIR2new != PIR2old && PIR2new >=700) { sensorUpperActive = true ; send (msgPIR02.set(sensorUpperActive?"1":"0")); // Send status to Domoticz Serial.println("PIR2----"); Serial.println(PIR2new); PIR2old = PIR2new; } } void effopneer() { if (sensorBottomActive==true && sensorUpperActive==false){ // do something digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorBottomActive = false ; send (msgPIR01.set(sensorBottomActive)); Serial.println("PIR1--uit"); } } void effneerop() { if (sensorBottomActive==false && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; send (msgPIR02.set(sensorUpperActive)); Serial.println("PIR2--uit"); } } void Tegelijk() { if (sensorBottomActive==true && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(5000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; sensorBottomActive = false ; send (msgPIR01.set(sensorUpperActive)); send (msgPIR01.set(sensorBottomActive)); Serial.println("PIR1&2--uit"); } } -
Analog to digital how ?#define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #define MY_DEBUG //#include <SPI.h> #include <MySensors.h> boolean sensorUpperActive; boolean sensorBottomActive; boolean PIR00; #define MY_NODE_ID 30 #define CHILD_ID_PIR00 31 // Id of the sensor child #define CHILD_ID_PIR01 32 // Id of the sensor child #define CHILD_ID_PIR02 33 // Id of the sensor child void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "4.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR00, S_MOTION, "PIR Sensor 0"); present(CHILD_ID_PIR01, S_MOTION, "PIR Sensor 1"); present(CHILD_ID_PIR02, S_MOTION, "PIR Sensor 2"); } // Initialize motion message MyMessage msgPIR00(CHILD_ID_PIR00, V_TRIPPED); MyMessage msgPIR01(CHILD_ID_PIR01, V_TRIPPED); MyMessage msgPIR02(CHILD_ID_PIR02, V_TRIPPED); // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: // Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); } // the loop routine runs over and over again forever: void loop() { Pir0lezen(); Pir1lezen(); Pir2lezen(); effopneer(); effneerop(); Tegelijk(); // delay(1000); // delay in between reads for stability } void Pir0lezen() { int PIR0 = analogRead(A0); if (analogRead(A0) >=700) { Serial.println("PIR0----"); Serial.println(PIR0); PIR00 = true; // Send status to Domoticz }} void Pir1lezen() { int PIR1 = analogRead(A1); if (analogRead(A1) >=700) { sensorBottomActive = true; // Send status to Domoticz Serial.println("PIR1----"); Serial.println(PIR1); }} void Pir2lezen() { int PIR2 = analogRead(A2); if (analogRead(A2) >=700) { sensorUpperActive = true; // Send status to Domoticz Serial.println("PIR2----"); Serial.println(PIR2); }} void effopneer() { if (sensorBottomActive==true && sensorUpperActive==false){ // do something digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorBottomActive = false ; Serial.println("PIR1--uit"); } } void effneerop() { if (sensorBottomActive==false && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; Serial.println("PIR2--uit"); } } void Tegelijk() { if (sensorBottomActive==true && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(5000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; sensorBottomActive = false ; Serial.println("PIR1&2--uit"); } } -
Analog to digital how ?Hi there,
I would like to know what and where i have to look for.
I reading with my nano 328 port A0, A1, A2 voltage from "3" motion senors
and get a specific value >700
if one of those ports gets above this 700
I would like to send this true mysensors as an normal motion sensor normal true trigger
but im not using any interrupt
How do i send this ?if (analogRead(A0) >=700)
{
send(msgmotion0.set(tripped0?"1":"0"));and for the others.
send(msgmotion0.set(tripped0?"1":"0"));
send(msgmotion1.set(tripped1?"1":"0"));
send(msgmotion3.set(tripped3?"1":"0")); -
Double Pir sensorsthx.
Aha i missed those
sketch is accepted, waiting for second pir sensor to test in real time.
thx again learned something new again...
Starting to have fun with Mysensors ...For other users who like to try.
/** * 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 * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // 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 9 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 CHILD_ID_PIR1 21 // Id of the sensor child #define CHILD_ID_PIR2 22 // 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); 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 } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "3.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR1, S_MOTION); present(CHILD_ID_PIR2, S_MOTION); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH; bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH; Serial.println(tripped); send(msg1.set(tripped?"1":"0")); // Send tripped value to gw Serial.println(tripped2); send(msg2.set(tripped2?"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, (DIGITAL_INPUT_SENSOR2), CHANGE, SLEEP_TIME); } -
Double Pir sensorsthx for helping with last problem
only problem left is with why
MyMessage msg(CHILD_ID_PIR2, V_TRIPPED);
is not accepted./** * 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 * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // 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 9 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 CHILD_ID_PIR1 21 // Id of the sensor child #define CHILD_ID_PIR2 22 // Id of the sensor child // Enable repeater functionality for this node #define MY_REPEATER_FEATURE // Initialize motion message MyMessage msg(CHILD_ID_PIR1, V_TRIPPED); MyMessage msg(CHILD_ID_PIR2, 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 } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "3.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR1, S_MOTION); present(CHILD_ID_PIR2, S_MOTION); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH; bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw Serial.println(tripped2); send(msg.set(tripped2?"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, (DIGITAL_INPUT_SENSOR2), CHANGE, SLEEP_TIME); } -
Double Pir sensorsHi there i could use some help, i tried to expand the mysensors motion sketch but i would like to use 2 pir sensors.
I changed the sketch and get a strange message;
#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))^exit status 1
redefinition of 'MyMessage msg'i thought nr 2 and 3 are with interrupt.
Than i think i'll have to change:
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);Well maybe someone have some time to help me.
/** * 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 * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // 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 9 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 CHILD_ID_PIR1 21 // Id of the sensor child #define CHILD_ID_PIR2 22 // Id of the sensor child // Enable repeater functionality for this node #define MY_REPEATER_FEATURE // Initialize motion message MyMessage msg(CHILD_ID_PIR1, V_TRIPPED); MyMessage msg(CHILD_ID_PIR2, 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 } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "3.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR1, S_MOTION); present(CHILD_ID_PIR2, S_MOTION); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH; bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw Serial.println(tripped2); send(msg.set(tripped2?"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); } -
Create relay free potential free switch.Thanks Gohan,
Will the repeater function keep working...... ? more like an interrupt when something is seen ?
-
Create relay free potential free switch.So far 1 relay works perfect adding a second one will be a bid harder because the sketch samples i found use more than 2 i would like to know how to add just a second one.
also in this sketch in need to find out hoe to remove the button function.
Adding the temperature sensor seems for me very hard, because i would like to call it every 5 minutes without interrupting the repeater. (No Sleep can be used).
if i know how to call every 5 minutes the temperature, i think i'll be able to add the also the adc code.I someone could point me to some code sample i would be very happy...
-
Create relay free potential free switch.will give it a try.
this is the sketch i want to implement this in:
It will be a repeater node,
I would like to have 2 Relays on pins D3,D4
And a temperature sensor on D5 (DS1820)
Eventually an voltage sense pin A3/* * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * http://www.mysensors.org/build/relay */ // 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 1 #include <SPI.h> #include <MySensors.h> #include <Bounce2.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define RELAY_PIN1 3 // Arduino Digital I/O pin number for relay #define BUTTON_PIN 7 // dont need this one remove #define CHILD_ID 1 #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); bool state = false; bool initialValueSent = false; MyMessage msg(CHILD_ID, V_STATUS); void setup() { // Setup the button //pinMode(BUTTON_PIN, INPUT_PULLUP); // After setting up the button, setup debouncer //debouncer.attach(BUTTON_PIN); //debouncer.interval(10); // Make sure relays are off when starting up digitalWrite(RELAY_PIN1, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN1, OUTPUT); // Set relay to last known state (using eeprom storage) state = loadState(CHILD_ID); digitalWrite(RELAY_PIN1, state?RELAY_ON:RELAY_OFF); } void presentation() { // Startup initialize MySensors library. Set callback for incoming messages. sendSketchInfo("Lamp", "1.0"); present(CHILD_ID, S_BINARY); } void loop() { if (!initialValueSent) { Serial.println("Sending initial value"); send(msg.set(state?RELAY_ON:RELAY_OFF)); Serial.println("Requesting initial value from controller"); request(CHILD_ID, V_STATUS); wait(2000, C_SET, V_STATUS); } if (debouncer.update()) { if (debouncer.read()==LOW) { state = !state; send(msg.set(state?RELAY_ON:RELAY_OFF), true); // Send new state and request ack back } } } void receive(const MyMessage &message) { if (message.isAck()) { Serial.println("This is an ack from gateway"); } if (message.type == V_STATUS) { if (!initialValueSent) { Serial.println("Receiving initial value from controller"); initialValueSent = true; } // Change relay state state = (bool)message.getInt(); digitalWrite(RELAY_PIN1, state?RELAY_ON:RELAY_OFF); send(msg.set(state?RELAY_ON:RELAY_OFF)); // Store state in eeprom saveState(CHILD_ID, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getInt()); } }``` -
Create relay free potential free switch.Ok i explain.
i have and Gardena Watering computer, here i want to connect a controller on battery to
All this controller has to do via Mysensors is open or close a an switch (the 2 wires of this switch go inside the gardena computer that is looking for an 10k resistance to stop watering the plants, and an open switch 0 ohm to water the plants.Some distance further i have an other node that's measuring soil moisture,
I have this now running by using normal relays, but using 2 of them (2 garden computers ) they use allot of battery power while watering so i was hoping there are some more better options.
-
Create relay free potential free switch.because i dont want the water lock stay open after power lost.
-
Create relay free potential free switch.battery powered project....
-
Create relay free potential free switch.Hi there,
i need some help with an idea i need...
I looking far a way to control a potential free contact to control an water lock, but without using a relay. if my water lock sees 10K on its connection it keeps it closed so no watering, if it sees 0 ohm it will have permission to water. my plants
.
i was thinking to use an opto coupler but those i now need a voltage going tru on the output... or am i wrong.or maybe some kind of hal sensor with internal coil controlled by an arduino
-
💬 Relaythx
-
💬 RelayI just tried this sketch, works on latest version, but i cant seen any relais in Domoticz, only see the node relais, did i miss something
-
💬 Temperature Sensori dont know how but i got it now running perfect, and cleaned up a bid.
for if anyone could use ....// 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 <BH1750.h> #include <Wire.h> #include <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into port 3 on the Arduino #define ONE_WIRE_BUS 3 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); // arrays to hold device address DeviceAddress insideThermometer; unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point int SOLAR_SENSE_PIN = A1; // select the input pin for the solar sense point #define CHILD_ID_BATTERY 4 #define CHILD_ID_SOLAR 6 #define CHILD_ID_LIGHT 1 #define CHILD_ID_TEMP1 2 BH1750 lightSensor; float TempC = 50.5; int oldBatteryPcnt = 0; MyMessage msgTempC(CHILD_ID_TEMP1,V_TEMP); MyMessage msgbatt(CHILD_ID_BATTERY, V_VOLTAGE); MyMessage msgsolar(CHILD_ID_SOLAR, V_VOLTAGE); MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); uint16_t lastlux; //lux void setup(void) { // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif // Send the sketch version information to the gateway and Controller sendSketchInfo("Battery Meter", "2.0"); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); sensors.begin(); // start reading sensor // search for devices on the bus and assign based on an index. ideally, if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions) //sensors.setResolution(insideThermometer, 9); } void loop(void) { // get the battery Voltage int sensorValue2 = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValue1 = analogRead(BATTERY_SENSE_PIN); delay(100); int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValueS = analogRead(SOLAR_SENSE_PIN); delay(1000); #ifdef MY_DEBUG Serial.print("Battery Voltage2: "); Serial.println(sensorValue2); Serial.print("Battery Voltage1: "); Serial.println(sensorValue1); Serial.print("Battery Voltage: "); Serial.println(sensorValue); Serial.print("Solar Voltage: "); Serial.println(sensorValueS); #endif // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 const float vRef = 4.200/ 1.05/ 1023 ; int batteryPcnt = sensorValue / 10; float batteryV = sensorValue * 0.0042598 ; // 0.0038952294568380753114792412093 max 4,2 volt float batteryS = sensorValueS * 0.0102459 ; // 0.0038952294568380753114792412093 max 10 volt float TempC = sensors.getTempC(insideThermometer); #ifdef MY_DEBUG Serial.print("DS1820 Temperature: "); Serial.print(TempC); Serial.println(" C"); send(msgTempC.set(TempC ,2)); Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); send(msgbatt.set(batteryV ,2)); Serial.print("Solar Voltage: "); Serial.print(batteryS); Serial.println(" V"); send(msgsolar.set(batteryS ,2)); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); #endif if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; } uint16_t lux = lightSensor.readLightLevel();// Get Lux value Serial.println(lux); if (lux != lastlux) { send(msg.set(lux)); lastlux = lux; } sleep(SLEEP_TIME); }