Door, Motion and Temperature Sensor
-
I think you have to redo inclusion of the sensors if you want them to use the repater in their routing. At least it looks like this when I setup my Vera and sensors.
-
@Dwalt @m26872 Thanks for the feedback, I did do that on the Vera unit. I've even removed the plugin files and re-did everything. I even, and this is a bit extreme, cleared the eprom on the gateway and reflashed it. None of it worked, I really have no clue what to do next. I'm open to every suggestion :D
-
@Dwalt @m26872 Thanks for the feedback, I did do that on the Vera unit. I've even removed the plugin files and re-did everything. I even, and this is a bit extreme, cleared the eprom on the gateway and reflashed it. None of it worked, I really have no clue what to do next. I'm open to every suggestion :D
@CaptainZap It your sketch you have this line:
#define ONE_WIRE_BUS 14What pin is your Dallas sensor connected to?
-
First make sure a pure repeater node is working. With only the gw.process() to run, it should be fast to enough catch any new inlusion before the gateway. With a proper range of course. Clear the sensors eeprom and Vera-device before reinclusion, but you should not need to do anything with the gateway.
-
@CaptainZap It your sketch you have this line:
#define ONE_WIRE_BUS 14What pin is your Dallas sensor connected to?
@Dwalt said:
@CaptainZap It your sketch you have this line:
#define ONE_WIRE_BUS 14What pin is your Dallas sensor connected to?
One sensor is connected to A0(14) the other is connected to D5 as it can be seen in my last sketch. Temperature reporting worked on, in my original sketch, however the sketch wasn't perfect so I improved it based on feedback.
@m26872 The sensor is on a breadboard 5cm from the gateway, and I'm not sure about the repeater part...
-
Well since nobody knew what the problem is I thought I would re-flash my first sketch which was working properly... however after doing it it no longer works... this is blowing my mind away. I don't understand why that would be, as the only changes I've done are listed in this thread, major one was that I upgraded lib to 1.4.1 from 1.4. Anyone has any ideas cause this is driving me crazy now :(
-
Well since nobody knew what the problem is I thought I would re-flash my first sketch which was working properly... however after doing it it no longer works... this is blowing my mind away. I don't understand why that would be, as the only changes I've done are listed in this thread, major one was that I upgraded lib to 1.4.1 from 1.4. Anyone has any ideas cause this is driving me crazy now :(
@CaptainZap would suggest to clear the eeprom
-
Did you ever get a repeater-only node to work in your mys network ?
-
@Moshe-Livne @m26872 : I did clear the eprom, I've tried everything I could think of... I'm not quite sure if the repeater works, so far everything is at the breadboard state, so I was pretty much prototyping.
-
@AWI Yes I want all my nodes to be repeaters, and that's exactly what I want to do :) However I use a Vera as my controller, and there you are supposed to have a parent node for your arduino sensor, followed by child devices for sensors/relays etc. Right now I have 3 child devices for the My Sensors plugin which isn't right.
@CaptainZap said:
@AWI Yes I want all my nodes to be repeaters,
Why?
Unless you plan expand your network in the near future, think the increased complexity just will give you trouble. -
@Moshe-Livne @m26872 : I did clear the eprom, I've tried everything I could think of... I'm not quite sure if the repeater works, so far everything is at the breadboard state, so I was pretty much prototyping.
@CaptainZap did you clear the eeprom before loading the sketch that used to work?
-
Hello,
I've read this thread with interest because I want to make my Motion/Temp sensor using Dallas.
Adapting the given code was quite easy (well I guess as I have not tested it for now :D ), I only have changed gw.wait with gw.sleep, because if I understand it correctly, gw.sleep put the sensor in sleep mode which is a bit better for battery :
#include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define CHILD_ID_S1 1 // Id of the sensor child #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected #define CHILD_ID_T1 2 //CHILD ID for temp OneWire oneWire(ONE_WIRE_BUS); DallasTemperature DallasSensors(&oneWire); float lastTemperature ; unsigned long SLEEP_TIME = 30000; // Sleep time between reports (in milliseconds) unsigned long lastRefreshTime = 0; boolean lastTripped = 0; MySensor gw; // Initialize motion message MyMessage motionMsg(CHILD_ID_S1, V_TRIPPED); MyMessage tempMsg(CHILD_ID_T1,V_TEMP); void setup() { // Startup OneWire Temp Sensors DallasSensors.begin(); DallasSensors.setWaitForConversion(false); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Motion and Temperature Sensor", "1.0"); pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_S1, S_MOTION); gw.present(CHILD_ID_T1, S_TEMP); } void loop() { // Process incoming messages (like config from server) gw.process(); // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; if (lastTripped != tripped ) { Serial.println("Tripped"); gw.send(motionMsg.set(tripped?"1":"0")); // Send tripped value to gw lastTripped=tripped; } boolean bNeedRefresh = (millis() - lastRefreshTime) > SLEEP_TIME; if (bNeedRefresh) { lastRefreshTime = millis(); DallasSensors.requestTemperatures(); gw.sleep(750); float tempC = DallasSensors.getTempCByIndex(1); float difference = lastTemperature - tempC; if (tempC != -127.00 && abs(difference) > 0.1) { // Send in the new temperature gw.send(tempMsg.set(tempC, 1)); lastTemperature = tempC; } } else { gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME); } }But I'm concerned about thoses particular lines :
lastRefreshTime = millis(); DallasSensors.requestTemperatures(); gw.sleep(750); float tempC = DallasSensors.getTempCByIndex(1);Why do we need gw.sleep(750) ? My concern is, when the sensor tries to pull temperature, it could not trigger new motion state for at least 750ms ? This is a problem for me, as I want to use these sensor to trigger light when I come in the room, so I need it to be fast.
Thanks !
-
@petoulachi said:
this will sleep the device until the interrupt triggers it to awaken...
gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);you are correct that it seems that the
sleep(750)function will block your device, I don't think you want that. -
@petoulachi @BulldogLowell Glad to hear there is some progress, in regards to my issue and hopefully this is step in the right direction. I'm positive that we're not alone in our need to create multisensors, both powered and battery operated, as arduinos offer too many possibilities to limit yourself to just a single type of device :)
-
@petoulachi @BulldogLowell Glad to hear there is some progress, in regards to my issue and hopefully this is step in the right direction. I'm positive that we're not alone in our need to create multisensors, both powered and battery operated, as arduinos offer too many possibilities to limit yourself to just a single type of device :)
-
@BulldogLowell Temperature isn't working, and is never updated on the Vera interface :|
-
try something like this, which is untested.
#include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> //myPins const int PIR_PIN = 3; const int INTERRUPT = 1; const int DALLAS_PIN = 4; //myDevices const int PIR_SENSOR = 1; const int DALLAS_SENSOR = 2; OneWire oneWire(DALLAS_SENSOR); DallasTemperature DallasSensors(&oneWire); int lastTemperature = -99; unsigned long readTempInterval = 60 * 60 * 1000UL; // One Hour Sleep time between reports (in milliseconds) unsigned long sleepTime = readTempInterval; boolean lastTripped = 0; boolean sendTemp = true; MySensor gw; MyMessage motionMsg(PIR_SENSOR, V_TRIPPED); MyMessage tempMsg(DALLAS_SENSOR, V_TEMP); void setup() { DallasSensors.begin(); //DallasSensors.setWaitForConversion(false); /I could not get this to compile gw.begin(); gw.sendSketchInfo("Multi-Sensor", "1.0alpha"); pinMode(PIR_PIN, INPUT); // sets the motion sensor digital pin as input gw.present(PIR_SENSOR, S_MOTION); gw.present(DALLAS_SENSOR, S_TEMP); } void loop() { //gw.process(); don't need this, it is a one-way device. boolean tripped = digitalRead(PIR_PIN); if (lastTripped != tripped ) { Serial.println(tripped? "Tripped" : "Not Tripped"); gw.send(motionMsg.set(tripped)); // Send tripped value to gw lastTripped = tripped; } if (sendTemp) { DallasSensors.requestTemperatures(); int tempC = (int) DallasSensors.getTempCByIndex(1); gw.send(tempMsg.set(tempC)); lastTemperature = tempC; sendTemp = false; } unsigned long startSleepTime = millis(); gw.sleep(INTERRUPT, CHANGE, sleepTime); unsigned long endSleepTime = millis(); if (endSleepTime - startSleepTime >= sleepTime) { sleepTime = readTempInterval; sendTemp = true; } else { sleepTime = max(sleepTime -= (endSleepTime - startSleepTime), 1000UL); } }It will send temp to controller once an hour... you can change that for testing;
also will detect motion...
it may need debouncing.
-
try something like this, which is untested.
#include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> //myPins const int PIR_PIN = 3; const int INTERRUPT = 1; const int DALLAS_PIN = 4; //myDevices const int PIR_SENSOR = 1; const int DALLAS_SENSOR = 2; OneWire oneWire(DALLAS_SENSOR); DallasTemperature DallasSensors(&oneWire); int lastTemperature = -99; unsigned long readTempInterval = 60 * 60 * 1000UL; // One Hour Sleep time between reports (in milliseconds) unsigned long sleepTime = readTempInterval; boolean lastTripped = 0; boolean sendTemp = true; MySensor gw; MyMessage motionMsg(PIR_SENSOR, V_TRIPPED); MyMessage tempMsg(DALLAS_SENSOR, V_TEMP); void setup() { DallasSensors.begin(); //DallasSensors.setWaitForConversion(false); /I could not get this to compile gw.begin(); gw.sendSketchInfo("Multi-Sensor", "1.0alpha"); pinMode(PIR_PIN, INPUT); // sets the motion sensor digital pin as input gw.present(PIR_SENSOR, S_MOTION); gw.present(DALLAS_SENSOR, S_TEMP); } void loop() { //gw.process(); don't need this, it is a one-way device. boolean tripped = digitalRead(PIR_PIN); if (lastTripped != tripped ) { Serial.println(tripped? "Tripped" : "Not Tripped"); gw.send(motionMsg.set(tripped)); // Send tripped value to gw lastTripped = tripped; } if (sendTemp) { DallasSensors.requestTemperatures(); int tempC = (int) DallasSensors.getTempCByIndex(1); gw.send(tempMsg.set(tempC)); lastTemperature = tempC; sendTemp = false; } unsigned long startSleepTime = millis(); gw.sleep(INTERRUPT, CHANGE, sleepTime); unsigned long endSleepTime = millis(); if (endSleepTime - startSleepTime >= sleepTime) { sleepTime = readTempInterval; sendTemp = true; } else { sleepTime = max(sleepTime -= (endSleepTime - startSleepTime), 1000UL); } }It will send temp to controller once an hour... you can change that for testing;
also will detect motion...
it may need debouncing.
@BulldogLowell Thanks, I'll try it tonight once I get home.
-
try something like this, which is untested.
#include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> //myPins const int PIR_PIN = 3; const int INTERRUPT = 1; const int DALLAS_PIN = 4; //myDevices const int PIR_SENSOR = 1; const int DALLAS_SENSOR = 2; OneWire oneWire(DALLAS_SENSOR); DallasTemperature DallasSensors(&oneWire); int lastTemperature = -99; unsigned long readTempInterval = 60 * 60 * 1000UL; // One Hour Sleep time between reports (in milliseconds) unsigned long sleepTime = readTempInterval; boolean lastTripped = 0; boolean sendTemp = true; MySensor gw; MyMessage motionMsg(PIR_SENSOR, V_TRIPPED); MyMessage tempMsg(DALLAS_SENSOR, V_TEMP); void setup() { DallasSensors.begin(); //DallasSensors.setWaitForConversion(false); /I could not get this to compile gw.begin(); gw.sendSketchInfo("Multi-Sensor", "1.0alpha"); pinMode(PIR_PIN, INPUT); // sets the motion sensor digital pin as input gw.present(PIR_SENSOR, S_MOTION); gw.present(DALLAS_SENSOR, S_TEMP); } void loop() { //gw.process(); don't need this, it is a one-way device. boolean tripped = digitalRead(PIR_PIN); if (lastTripped != tripped ) { Serial.println(tripped? "Tripped" : "Not Tripped"); gw.send(motionMsg.set(tripped)); // Send tripped value to gw lastTripped = tripped; } if (sendTemp) { DallasSensors.requestTemperatures(); int tempC = (int) DallasSensors.getTempCByIndex(1); gw.send(tempMsg.set(tempC)); lastTemperature = tempC; sendTemp = false; } unsigned long startSleepTime = millis(); gw.sleep(INTERRUPT, CHANGE, sleepTime); unsigned long endSleepTime = millis(); if (endSleepTime - startSleepTime >= sleepTime) { sleepTime = readTempInterval; sendTemp = true; } else { sleepTime = max(sleepTime -= (endSleepTime - startSleepTime), 1000UL); } }It will send temp to controller once an hour... you can change that for testing;
also will detect motion...
it may need debouncing.
@BulldogLowell I just managed to test this and I have some questions :
- Motion doesn't seem to work that great - meaning that it takes at least one minute after being untripped to be tripped again
- Door/window doesn't seem to work - I think I have to add this part, but I'm a bit overwhelmed
- Temperature starts with temperature of -127C and doesn't update at all (I held my finger on it for 2 minutes) plus I think I need something to avoid -127 temps, like :
if (lastTemperature != tempC && tempC != -127.00)For your info I used these pins to connect my sensors :
const int PIR_PIN = 3; - PIR sensor const int INTERRUPT = 4; - Door/Window const int DALLAS_PIN = 5; - Temperature sensor [...] unsigned long readTempInterval = 1 * 60 * 1000UL; - modified read interval to 1 minute for testing purposesAlso I get this output of the serial monitor once I compile and upload the sketch to my nano after 2 minutes and multiple tries to trip PIR sensor :
sensor started, id 2 send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1 send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0 send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=12,st=ok:Multi-Sensor send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=8,st=ok:1.0alpha send: 2-2-0-0 s=1,c=0,t=1,pt=0,l=0,st=ok: send: 2-2-0-0 s=2,c=0,t=6,pt=0,l=0,st=ok: send: 2-2-0-0 s=2,c=1,t=0,pt=2,l=2,st=ok:-127 Tripped send: 2-2-0-0 s=1,c=1,t=16,pt=2,l=2,st=ok:1 Not Tripped send: 2-2-0-0 s=1,c=1,t=16,pt=2,l=2,st=ok:0 Tripped send: 2-2-0-0 s=1,c=1,t=16,pt=2,l=2,st=ok:1I would appreciate any help I can get to get this started... this project has been on hold for at least 1 year and I would like to implement it now since I have all the parts I need, including 5 cases for the motion detectors (I will need to have at least two variations for them). My focus right now is getting a working sketch, with repeating functions or not, I can place repeaters if needed that is not a problem.
-
@BulldogLowell I just managed to test this and I have some questions :
- Motion doesn't seem to work that great - meaning that it takes at least one minute after being untripped to be tripped again
- Door/window doesn't seem to work - I think I have to add this part, but I'm a bit overwhelmed
- Temperature starts with temperature of -127C and doesn't update at all (I held my finger on it for 2 minutes) plus I think I need something to avoid -127 temps, like :
if (lastTemperature != tempC && tempC != -127.00)For your info I used these pins to connect my sensors :
const int PIR_PIN = 3; - PIR sensor const int INTERRUPT = 4; - Door/Window const int DALLAS_PIN = 5; - Temperature sensor [...] unsigned long readTempInterval = 1 * 60 * 1000UL; - modified read interval to 1 minute for testing purposesAlso I get this output of the serial monitor once I compile and upload the sketch to my nano after 2 minutes and multiple tries to trip PIR sensor :
sensor started, id 2 send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1 send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0 send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=12,st=ok:Multi-Sensor send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=8,st=ok:1.0alpha send: 2-2-0-0 s=1,c=0,t=1,pt=0,l=0,st=ok: send: 2-2-0-0 s=2,c=0,t=6,pt=0,l=0,st=ok: send: 2-2-0-0 s=2,c=1,t=0,pt=2,l=2,st=ok:-127 Tripped send: 2-2-0-0 s=1,c=1,t=16,pt=2,l=2,st=ok:1 Not Tripped send: 2-2-0-0 s=1,c=1,t=16,pt=2,l=2,st=ok:0 Tripped send: 2-2-0-0 s=1,c=1,t=16,pt=2,l=2,st=ok:1I would appreciate any help I can get to get this started... this project has been on hold for at least 1 year and I would like to implement it now since I have all the parts I need, including 5 cases for the motion detectors (I will need to have at least two variations for them). My focus right now is getting a working sketch, with repeating functions or not, I can place repeaters if needed that is not a problem.
@CaptainZap The motion detector (if you are using one like in the store) has two little dials on it. One is sensitivity and the other is time delay (see http://www.mpja.com/download/31227sc.pdf). Try to play with these until you get the effect you are looking for