you cold try to modify this sketch:
https://github.com/n3roGit/MySensors_n3ro/tree/master/in_process/Multisensor_PIR_DHT_light_switch_battery
its not finished but there is all you need
Posts made by n3ro
-
RE: Multisensor_PIR_DHT_LDR_Battery
-
RE: Multisensor_PIR_DHT_LDR_Battery
@Dylano the sketch send the battery percentage everytime the voltage is changed
-
RE: Multisensor_PIR_DHT_LDR_Battery
@Dylano what do you mean with long readVcc?
The battery life is different because of the frequency of triggering from the pir.
Some nodes works for 2 month. Other ones for 6..
-
RE: Multisensor_PIR_DHT_LDR_Battery
But I don't use the dht anymore.
https://github.com/n3roGit/MySensors_n3ro/tree/master/Multisensor_PIR_SI7021_LDA_BatteryThis works much better!
-
RE: Multisensor_PIR_DHT_LDR_Battery
@Dylano
Hey,
Yes it works very good with 2 aaa Batts.You can find the read library here
https://github.com/sweebee/Arduino-home-automation/tree/master/libraries/readVcc
-
how to use repeater nodes
Hey folks,
what's the correct way to use repeating nodes?
I have build 3 usb powered LED-Lights and one of them is out of range...
Is it a good idea to enable repeating on every USB-powered node?
https://github.com/n3roGit/MySensors_n3ro/blob/master/moodlight_extended/moodlight_extended.ino
gw.begin(incomingMessage, NODE_ID, true);
Regards,
n3ro -
RE: MySensors 1.5.2 Released
@Anticimex like homeduino with:
sudo apt-get install arduino-core avr-libc avrdude binutils-avr gcc-avr libconfig-yaml-perl libftdi1 libyaml-perl screen python-serial git clone --recursive https://github.com/pimatic/homeduino.git make upload
-
RE: MySensors 1.5.2 Released
yeah!
is it possible to update the gateway via shell?
-
RE: SI7021 Multisensor - first try
@dakky Yes, this is because of the multiple sensors on my board. maybe somebody have more tuning tipps.
-
RE: 110v-230v AC to Mysensors PCB board
i hope i can buy this board in the near future
-
RE: SI7021 Multisensor - first try
@riataman said:
with a 5v arduino
Hey
the operating voltage of this component is 1.9 to 3,6 v. not 5vBut the idea to remove the regulator to save a little bit energy is cool. i will try it
-
RE: Multisensor_PIR_DHT_LDR_Battery
@icebob hey the used pir consumes ~50uA. Since my last modifications I replaced the stepup and the dht with a si7021 sensor and the external pullup with 1m ohm. Now the sleeping current is ~190uA
-
RE: Multisensor_PIR_DHT_LDR_Battery
What do you mean with you recommenced sensors?
-
RE: Gateway queue commands
Jeah this is very cool!
My Idea is to change the sleep time when iam not at home or in the night.
Do you know the release time for 1.6?
-
Gateway queue commands
Hey folks,
is it possible to queue commands on the gw to send it to the node later (like zwave)?
cenario:
1x battery powered node
1x mysensors gwgw send "turn light on" to node (queue)
node is in deep sleep...
...
...
node wakes up and connect to the gw
gw transmit "turn light on" to the node
...regards
n3ro -
RE: SI7021 Multisensor - first try
@tbowmo
why i cant see the debug information "ratio failed" or sending commands if debug is only enabled in the sketch? -
RE: SI7021 Multisensor - first try
Perfect
// Enable debug flag for debug prints. This will add a lot to the size of the final sketch but good // to see what is actually is happening when developing //#define DEBUG
-
RE: SI7021 Multisensor - first try
Yeah. now the new node works and the sleep current is about ~240aA.
But i still not understand why i get debug outout on serial if debug isn definded^^
-
RE: SI7021 Multisensor - first try
@m26872 said:
You also have the "define DEBUG" in the mysensors config-file. Is it that serial output you're referring to?
Yes the serial output. whats to do to put it in the mysensors config?
-
RE: SI7021 Multisensor - first try
@m26872 said:
#define DEBUG
btw. this #define DEBUG is a very cool idea!!!
But i get a serial output if DEBUG is not definded
-
RE: SI7021 Multisensor - first try
Big THX,
now i have understand how to use the si7021
Reading works great!
But the sleeping current is very high ~1500uA
-
RE: SI7021 Multisensor - first try
Thx for the comment. Could you explain it a little bit more please? I have seen the the sensorblend sketch
-
SI7021 Multisensor - first try
Hey folks,
i have just get some SI7021 modules. Now i want to replace all DHT sensors in my nodes with it.
But my problem is, that i dont understand how the si7021 is wired (PINs to read?) and used in the sketch.
old DHT sketch
new one with si7021
Any tipps for me?
regards,
n3ro -
RE: nrf really hot
Maybe its broke.... The China stuff is not everytime the same quality
Do you have another one?
-
RE: Battery Sensor with stepup and on/off transistor
@GertSanders said:
(0.8V <-> 9V)
Yes. I had a few problems with the 5v PIRs. That's why I ordered this.
-
RE: Battery Sensor with stepup and on/off transistor
@GertSanders
thxI have just ordered some SI7021 for testing.
My Pir sensors are these ones:
http://www.amazon.de/gp/product/B008EGH3FM50 Mikroampere
i dont know if this is aktive or passiv
regards,
n3ro -
RE: Battery Sensor with stepup and on/off transistor
Hey togehter,
is a battery drain graph like this normal with alkaline batteries?
regards,
n3ro -
RE: Interrupt, Perform a specific function, not the loop
This sounds great!
Do you have a code example?
-
RE: Battery Sensor with stepup and on/off transistor
@Suresh-Mali My sensor node is powered with two AAA Batts. Over the time the voltage drops down to 1,9v.
The DHT only works with ~3v. so i need the stepup only to power the dht
i use this setup with my multisensor nodes.
http://forum.mysensors.org/topic/1514/multisensor_pir_dht_ldr_battery/3Without transistor the battery is drained in ~2 month (black line)
with transistors in ~10 month -
RE: Multisensor_PIR_DHT_LDR_Battery
Hey folks,
I have just tried to reduce the sleep current of the nodes. With
*a transistor to turn on and off the stepup
*a second transistor to disconnect the ldr
*a external pullup with 680k for the pirNow I have a sleep current of 220-240uA.
Any ideas to tune it a little bit more?
Is it possible to check if the node is wake up from the interrupt or the timer?Regards
n3ro -
RE: Battery Sensor with stepup and on/off transistor
@ht81
hmm the max voltage of the NRF is 3.6v (https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf)
maybe the NRF is broker after 3.7v. i dont know...the 2N2222A turns the stepup on and off. the DHT is direct connected to the stepup.
you can read many stuff about the power consumption of NRF+Arduino in the forum. With modified fuses and cutted LED+power regulator ~40uA
-
RE: Battery Sensor with stepup and on/off transistor
@Harrdy the stepup with 5v output is much cheaper
-
RE: Battery Sensor with stepup and on/off transistor
i have only a test setup at the moment with 2 AAA batteries. So i cant give you a battery lifetime
I use a arduino 3.3v and the stepup pushes the voltage to 5v for the DHT.
-
RE: Battery Sensor with stepup and on/off transistor
I use this setup at the moment and it works. the arduino is still alive
-
RE: Battery Sensor with stepup and on/off transistor
@ht81 Hey, the NRF is directly connected to the battery. only the DHT use the stepup.
i use this stepup: http://www.banggood.com/2Pcs-500mA-DC-DC-1V-5V-Converter-Step-Up-Module-Power-Module-p-945167.html
Just put a transistor in front of the stepup. this is all
-
RE: Mailbox/Postbox Alert
@f1dev sweebe wrote a very good howto:
http://forum.pimatic.org/topic/383/tips-battery-powered-sensors
-
RE: Mailbox/Postbox Alert
I think you need the irq only for the gw. I have a receive node without irq.
Do you have changed fuses on your arduino?
And remember. All this stuff is cheap China electronic.The devices can vary consume a lot of electricity.
-
RE: Mailbox/Postbox Alert
@BulldogLowell could you please explain your changes? I don't understand everything of this
-
RE: Mailbox/Postbox Alert
@Moshe-Livne just deactivate the this lines:
//digitalWrite(MAILBOX_FRONT_PIN, HIGH);
//digitalWrite(MAILBOX_BACK_PIN, HIGH);and solder two resistor from 3.3v to pin 2 and 3.
-
RE: Mailbox/Postbox Alert
it is fixed changed internal pullup to an external with 680k. now its 32uA with both opened and 47uA with both closed
-
RE: Mailbox/Postbox Alert
Thx for the tips. I will try it.
I have just measured the current:
32uA in sleep and both opened
when one reen switch is closed: 171uA
when both closed: 309uAi use a internal pullup and dont know why the current is so high when switch is closed
-
RE: Mailbox/Postbox Alert
hmm after some days testing it works very fine, but:
the battery drains very fast and in dont know why. The Arduino sleeps the whole time and wakes up when the postman is coming (maybe 2 times a week).
The battery drains 11% in 7 Days
Any Ideas?
The power LED and regulator is cutted and the fuses are modified.
Regards
n3ro -
Mailbox/Postbox Alert
Just finished my new project.
I have added two magnetic switches to the front and the back of my postbox. Now i get a Mail if the postman was here
You need:
1x Arduino Mini Pro 3,3
1x Battery Holder (2xaaa)
1x NRF
2x Reed switches (http://www.reichelt.de/KSK-1A663-2025/3/index.html?&ACTION=3&LA=446&ARTICLE=151700&artnr=KSK+1A663+2025&SEARCH=magnet+schlie�er)
2x magnets (http://www.reichelt.de/MAGNET-M4/3/index.html?&ACTION=3&LA=446&ARTICLE=12483&artnr=MAGNET+M4&SEARCH=magnet)And this or a similar sketch: https://github.com/n3roGit/MySensors_n3ro/tree/master/Mailbox_Alert
It works great
-
RE: Windows GUI/Controller for MySensors
i dont understand how to use this...
Can somebody explain it? -
RE: Multisensor_PIR_DHT_LDR_Battery
Yes. This is a step up with a transistor for the dht.
I want to reduce the battery drain with the transistor.
http://forum.mysensors.org/topic/1446/battery-sensor-with-stepup-and-on-off-transistor
-
Multisensor_PIR_DHT_LDR_Battery
Hey Guys,
Today I have completed my first multisensor.As base I used a cheap china fire detectors and the MYS PCB board.
All components fits very well in the housing.
Unfortunately, the modified HC-SR501 do not work well with <= 3V with the DHT (delay in the sketch). Now I use this:
http://www.amazon.de/Niederspannung-PIR-Infrarot-Bewegungssensor-erkennt-Modul/dp/B008EGH3FM/ref=sr_1_1?ie=UTF8&qid=1433801387&sr=8-1&keywords=B008EGH3FMAnd it works very great!
The used Sketch is this:
wiring diagram coming soon;)
-
RE: My sensorboard MYS 1.0beta
Hey
What size are the SMD resistors and stuff?
Regards,
n3ro -
RE: Battery Sensor with stepup and on/off transistor
@ServiceXp could you already test cold start vs sleep?
-
RE: Battery Sensor with stepup and on/off transistor
@ServiceXp is use this: LINK
-
RE: Battery Sensor with stepup and on/off transistor
@hek In my tests its working with DHT11 and DHT22. Maybe a MQ-2 works too, but a MQ needs 2 minutes heatup time..
-
RE: resend if st=fail
Jeah now its working
#include <MySensor.h> #include <SPI.h> #define SENSOR_INFO "Test sensor" #define NODE_ID 200 #define CHILD_ID 1 #define OPEN 1 #define CLOSE 0 MySensor gw; MyMessage msg(CHILD_ID, V_TRIPPED); int repeat = 0; boolean sendOK = false; int repeatdelay = 0; void setup() { gw.begin(NULL, NODE_ID, false); gw.sendSketchInfo(SENSOR_INFO, "1.0"); gw.present(CHILD_ID, S_DOOR); } void loop() { resend((msg.set(OPEN)), 5); delay(500); } void resend(MyMessage &msg, int repeats) { int repeat = 1; int repeatdelay = 0; boolean sendOK = false; while ((sendOK == false) and (repeat < repeats)) { if (gw.send(msg)) { sendOK = true; } else { sendOK = false; Serial.print("FEHLER "); Serial.println(repeat); repeatdelay += 250; } repeat++; delay(repeatdelay); } }```
-
Battery Sensor with stepup and on/off transistor
Hey Guys,
Today I had an idea how you can save some power on battery sensors.
I simply connected a transistor before a StepUp converter. So the stepup and the connected sensors only supplied with power when they are needed.
My stepup + DHT11 has power consumption at 90 uA when sleeping. By disabling with the transistor it goes against 0.
Do you think that might help a little?
Best Regards,
n3ro#include <SPI.h> #include <MySensor.h> #include <DHT.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define HUMIDITY_SENSOR_DIGITAL_PIN 4 #define STEPUP_PIN 5 // Transistor connected PIN unsigned long SLEEP_TIME = 10000; // Sleep time between reads (in milliseconds) MySensor gw; DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); void setup() { gw.begin(); dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; } void loop() { stepup(true); delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); } Serial.print("T: "); Serial.println(temperature); float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); } Serial.print("H: "); Serial.println(humidity); stepup(false); gw.sleep(SLEEP_TIME); //sleep a bit } void stepup(boolean onoff) { pinMode(STEPUP_PIN, OUTPUT); // sets the pin as output Serial.print("---------- StepUp: "); if (onoff == true) { Serial.println("ON"); digitalWrite(STEPUP_PIN, HIGH); // turn on } else { Serial.println("OFF"); digitalWrite(STEPUP_PIN, LOW); // turn off } }
-
RE: resend if st=fail
@rickmontana83 said:
put the gw.send() call in gwack() and pass the msg value as a reference/pointer to gwack.
What do you mean?
Like this?void loop() { //gw.send(msg.set(OPEN)); gwresend("msg.set","OPEN"); delay(500); } void gwresend(char msgcode[],char option[]) { int repeat = 0; boolean sendOK = false; while ((sendOK == false) or (repeat <= 10)) { if (gw.send(msgcode(option)) // execute code { Serial.println("OK"); sendOK = true; } else { Serial.println("NOT OK!!"); sendOK = false; } repeat++; } }
(code is not working )
I'm very surprised that there is not already such a function.
-
Piezo Buzzer
Has someone tested a piezo-buzzer (or summer) with arduino?
i want to use THIS Buzzer for my low voltage sensor. But don't know if this is a matching component for arduino.
Regards,
n3ro -
RE: resend if st=fail
Hey
I have just build this test function to resend a signal if failed.
But i don't know how to execute the ge.send in the string ("// execute code").#include <MySensor.h> #include <SPI.h> #define SENSOR_INFO "Test sensor" #define NODE_ID 200 #define CHILD_ID 1 #define OPEN 1 #define CLOSE 0 MySensor gw; MyMessage msg(CHILD_ID, V_TRIPPED); void setup() { gw.begin(NULL, NODE_ID, false); gw.sendSketchInfo(SENSOR_INFO, "1.0"); gw.present(CHILD_ID, S_DOOR); } void loop() { gwack("gw.send(msg.set(OPEN));"); delay(500); } void gwack(char code[]) { int repeat = 0; boolean sendOK = false; Serial.println(code); // string to execute while ((sendOK == false) or (repeat <= 10)) { if (code) // execute code { Serial.println("OK"); sendOK = true; } else { Serial.println("NOT OK!!"); sendOK = false; } repeat++; } }
Any ideas?
-
RE: Bad range
@rickmontana83 YEAH!!!!! This has fixed my problem!!
Now i have much better rage with my nodes
Big THX!
-
RE: Combine multisensor with switch
@AWI you are right. i get this on the GW:
<- I_LOG_MESSAGE 0;0;3;0;9;send: 0-0-10-10 s=5,c=1,t=2,pt=0,l=1,st=fail:0
-> Sending 10;5;1;1;2;1<- I_LOG_MESSAGE 0;0;3;0;9;send: 0-0-10-10 s=5,c=1,t=2,pt=0,l=1,st=fail:1
-> Sending 10;5;1;1;2;0It is possible that the node only accept the switching signal in the "right" moment?
-
RE: Combine multisensor with switch
@AWI cool!
Now it works but i cant switch it off every time. i have to stitch it on and off again multiple times to deactivate it -
resend if st=fail
Hello everybody,
has anyone built a function that resend the signal, if "st=fail" is detected?
I've already looked at the API and ACK. But have become not really smart of it.This would be great for some devices like relay, alarm, ....
Best Regards,
n3ro -
RE: Combine multisensor with switch
Yes, i want to disable the Smoke alarm, because sometime i make really much smoke in the kitchen without any fire
-
RE: Combine multisensor with switch
Hey
Sorry my question wasn't good.Let me explain what i mean.
I have just updated my sketch in Github to make i a little bit better to understood (there is no z-wave component).I want to Build a USB-powered-sensor with the following functions:
- Read some Sensors every x Seconds (done with millis and working)
- Read a PIR (done and working without interrupt)
- Read AirQuality (implemented but never tested because i haven't this component at the moment)
- If Smoke is detected make alarm with beeper (same like the AirQuality Sensor)
- a switch to disable the beeper (i don't know how to implement this)
I hope it's better to follow.
Regards,
n3roUpdate:
This is the beeper -
Combine multisensor with switch
Hey Guys,
I want to build a USB-powered-sensor. I need to change an internal variable per switch. There is not a pin to be driven.
I have not yet understood how the interrupt and the time for reading the sensors is maintained. is that even possible?
Regards,
n3ro -
RE: Multisensor PIR problem [solved]
@rvendrame yes i think so. but now its ok
-
RE: Bad range
i have still a band range. next i will test a gw with a nrf antenna version. i hope this helps
-
RE: Multisensor PIR problem [solved]
https://github.com/n3roGit/MySensors_n3ro/tree/master/MotionSensor_DHT_light_battery_mod
now its working. when i use PIN4 for DHT.:)
-
RE: Multisensor PIR problem [solved]
@BulldogLowell the wires are OK.
In sleep the DHT cant warm-up. so the dht need 2 sec before read. when i dont use the delay i cant read it.
i dont understand why the interrupt didnt work with the enabled delay.
do you have tested on a arduino?
-
RE: Multisensor PIR problem [solved]
@BulldogLowell
when i use this sketch the PIR works but the DHT cant read:Failed reading temperature from DHT
Failed reading humidity from DHT -
RE: Multisensor PIR problem [solved]
i think millis didnt work with sleep. the counter is not increasing when sleeping..
-
RE: Multisensor PIR problem [solved]
Hey, its a good idea to send only PIR if changed!
The unused code in the sketch is because i have reduced the used functions to the minimum to debug it better. The full sketch has LDR and battery lifetime output too.i have added some extra output in the modified sketch:
#include <MySensor.h> //#include <readVcc.h> // cannot see where you are using this library yet #include <SPI.h> #include <DHT.h> #define NODE_ID 10 // ID of node unsigned long SLEEP_TIME = 10000UL; // Sleep time between reports (in milliseconds) #define CHILD_ID_PIR 1 // Id of the sensor PIR #define CHILD_ID_HUM 2 // Id of the sensor HUM #define CHILD_ID_TEMP 3 // Id of the sensor TEMP #define CHILD_ID_LIGHT 4 // Id of the sensor LIGHT #define PIR_SENSOR_DIGITAL 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT PIR_SENSOR_DIGITAL-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define HUMIDITY_SENSOR_DIGITAL_PIN 2 #define LIGHT_SENSOR_ANALOG_PIN 0 MySensor gw; // Initialize Variables MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); DHT dht; float lastTemp; float lastHum; boolean metric = true; boolean lastTripped = false; int oldBatteryPcnt; int lastLightLevel; unsigned long mytime; //int MIN_V = 2700; // empty voltage (0%) //int MAX_V = 3200; // full voltage (100%) void setup() { gw.begin(NULL, NODE_ID, false); gw.sendSketchInfo("Motion Sensor", "1.0"); // here you call it motion sensor pinMode(PIR_SENSOR_DIGITAL, INPUT_PULLUP); gw.present(CHILD_ID_PIR, S_MOTION); dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); //gw.sendSketchInfo("Humidity", "1.0"); // here you call it humidity gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; //gw.sendSketchInfo("Light Sensor", "1.0");// pick a name for your sketch, it will only be one gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop() { // why send this every time? /* boolean tripped = digitalRead(PIR_SENSOR_DIGITAL) == HIGH; Serial.print("---------- PIR: "); Serial.println(tripped); gw.send(msgPir.set(tripped ? "1" : "0")); */ boolean tripped = digitalRead(PIR_SENSOR_DIGITAL) == HIGH; if (tripped != lastTripped) // only need to update controller on a change. { gw.send(msgPir.set(tripped ? "1" : "0")); Serial.print("---------- PIR: "); Serial.println(tripped ? "tripped" : " not tripped"); lastTripped = tripped; } if ( millis() - mytime >= SLEEP_TIME ) //use UNSIGNED SUBRTACTION im your millis() timers to avoid rollover issues later on down the line { delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("---------- Temp: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("---------- Humidity: "); Serial.println(humidity); } mytime = millis(); } else { Serial.println("no millis"); } Serial.println(millis()); Serial.println(mytime); Serial.println(SLEEP_TIME); gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); // Sleep until interrupt detected from motion sensor. Send update every SLEEP_TIME. }
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
---------- PIR: not tripped
no millis
2185
0
10000
no millis
2189
0
10000
no millis
2193
0
10000
no millis
2195
0
10000
no millis
2197
0
10000
no millis
2201
0
10000
no millis
2203
0
10000
no millis
2205
0
10000
no millis
2209
0
10000
no millis
2211
0
10000
no millisYou can see that the "if millis" will never used .:(
-
RE: Multisensor PIR problem [solved]
@Sweebee thy this would be very nice
You find my sketch here:
https://github.com/n3roGit/MySensors_n3ro/tree/master/MotionSensor_DHT_light_battery_mod -
RE: Multisensor PIR problem [solved]
@n3ro said:
#define PIR_SENSOR_DIGITAL 3
-
RE: Multisensor PIR problem [solved]
@rvendrame in my last test the pir sends endless 0 and dont sleep
-
RE: Multisensor PIR problem [solved]
@Sweebee
is #define INTERRUPT PIR_SENSOR_DIGITAL-2 wrong?when i use a switch it looks OK
-
RE: Multisensor PIR problem [solved]
if i use this
#include <MySensor.h> #include <readVcc.h> #include <SPI.h> #include <DHT.h> #define NODE_ID 10 // ID of node unsigned long SLEEP_TIME = 10000; // Sleep time between reports (in milliseconds) #define CHILD_ID_PIR 1 // Id of the sensor PIR #define CHILD_ID_HUM 2 // Id of the sensor HUM #define CHILD_ID_TEMP 3 // Id of the sensor TEMP #define CHILD_ID_LIGHT 4 // Id of the sensor LIGHT #define PIR_SENSOR_DIGITAL 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT PIR_SENSOR_DIGITAL-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define HUMIDITY_SENSOR_DIGITAL_PIN 2 #define LIGHT_SENSOR_ANALOG_PIN 0 MySensor gw; // Initialize Variables MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); DHT dht; float lastTemp; float lastHum; boolean metric = true; int oldBatteryPcnt; int lastLightLevel; long mytime = 0; int MIN_V = 2700; // empty voltage (0%) int MAX_V = 3200; // full voltage (100%) void setup() { gw.begin(NULL, NODE_ID, false); //PIR // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Motion Sensor", "1.0"); pinMode(PIR_SENSOR_DIGITAL, INPUT); // sets the motion sensor digital pin as input digitalWrite(PIR_SENSOR_DIGITAL, HIGH); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_PIR, S_MOTION); //DHT dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; //LIGHT // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Light Sensor", "1.0"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop() { // Read digital motion value boolean tripped = digitalRead(PIR_SENSOR_DIGITAL) == HIGH; Serial.print("---------- PIR: "); Serial.println(tripped); gw.send(msgPir.set(tripped ? "1" : "0")); // Send tripped value to gw if ( millis() > mytime ) { //DHT delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("---------- Temp: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("---------- Humidity: "); Serial.println(humidity); } mytime = millis() + dht.getMinimumSamplingPeriod(); } // Sleep until interrupt comes in on motion sensor. Send update every two minute. gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); }
i get this output:
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=13,st=ok:Motion Sensor
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=1,c=0,t=1,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=8,st=ok:Humidity
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=2,c=0,t=7,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=3,c=0,t=6,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=12,st=ok:Light Sensor
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=4,c=0,t=16,pt=0,l=5,st=ok:1.4.1
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=3,c=1,t=0,pt=7,l=5,st=ok:17.2
---------- Temp: 17.20
send: 10-10-0-0 s=2,c=1,t=1,pt=7,l=5,st=ok:43.8
---------- Humidity: 43.80
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0 -
RE: Multisensor PIR problem [solved]
@rvendrame
i have posted it before this post:"What is this number? Did you print the milis()?
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
6608 <<<<<<"in the posted sketch the delay is inside millis
-
RE: Multisensor PIR problem [solved]
@Sweebee is it possible to fix the problem when DHT is connected to pin 4?
-
RE: Multisensor PIR problem [solved]
@rvendrame
if i use this:#include <MySensor.h> #include <readVcc.h> #include <SPI.h> #include <DHT.h> #define NODE_ID 10 // ID of node unsigned long SLEEP_TIME = 600000; // Sleep time between reports (in milliseconds) #define CHILD_ID_PIR 1 // Id of the sensor PIR #define CHILD_ID_HUM 2 // Id of the sensor HUM #define CHILD_ID_TEMP 3 // Id of the sensor TEMP #define CHILD_ID_LIGHT 4 // Id of the sensor LIGHT #define PIR_SENSOR_DIGITAL 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT PIR_SENSOR_DIGITAL-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define HUMIDITY_SENSOR_DIGITAL_PIN 2 #define LIGHT_SENSOR_ANALOG_PIN 0 MySensor gw; // Initialize Variables MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); DHT dht; float lastTemp; float lastHum; boolean metric = true; int oldBatteryPcnt; int lastLightLevel; int MIN_V = 2700; // empty voltage (0%) int MAX_V = 3200; // full voltage (100%) void setup() { gw.begin(NULL, NODE_ID, false); //PIR // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Motion Sensor", "1.0"); pinMode(PIR_SENSOR_DIGITAL, INPUT); // sets the motion sensor digital pin as input digitalWrite(PIR_SENSOR_DIGITAL, HIGH); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_PIR, S_MOTION); //DHT dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; //LIGHT // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Light Sensor", "1.0"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop() { // Measure battery float batteryV = readVcc(); int batteryPcnt = (((batteryV - MIN_V) / (MAX_V - MIN_V)) * 100 ); if (batteryPcnt > 100) { batteryPcnt = 100; } if (batteryPcnt != oldBatteryPcnt) { gw.sendBatteryLevel(batteryPcnt); // Send battery percentage oldBatteryPcnt = batteryPcnt; } Serial.print("---------- Battery: "); Serial.println(batteryPcnt); // Read digital motion value boolean tripped = digitalRead(PIR_SENSOR_DIGITAL) == HIGH; Serial.print("---------- PIR: "); Serial.println(tripped); gw.send(msgPir.set(tripped ? "1" : "0")); // Send tripped value to gw //DHT //delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("---------- Temp: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("---------- Humidity: "); Serial.println(humidity); } // Light int lightLevel = (1023 - analogRead(LIGHT_SENSOR_ANALOG_PIN)) / 10.23; //Serial.println(lightLevel); if (lightLevel != lastLightLevel) { gw.send(msgLight.set(lightLevel)); lastLightLevel = lightLevel; Serial.print("---------- Light: "); Serial.println(lightLevel); } // Sleep until interrupt comes in on motion sensor. Send update every two minute. gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); }
i get this output after starting:
sensor started, id 10
send: 10-10-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
read: 0-0-10 s=255,c=3,t=6,pt=0,l=1:M
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=13,st=ok:Motion Sensor
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=1,c=0,t=1,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=8,st=ok:Humidity
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=2,c=0,t=7,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=3,c=0,t=6,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=12,st=ok:Light Sensor
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=4,c=0,t=16,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:100
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=3,c=1,t=0,pt=7,l=5,st=ok:16.6
---------- Temp: 16.60
send: 10-10-0-0 s=2,c=1,t=1,pt=7,l=5,st=ok:43.8
---------- Humidity: 43.80
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:39
---------- Light: 39
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:37
---------- Light: 37
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:34
---------- Light: 34
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:36
---------- Light: 36
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:37
---------- Light: 37
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:38
---------- Light: 38The DHT gives only output the first start and the pir interrupt works perfect.
When delay(dht.getMinimumSamplingPeriod()); is activated the DHT works and the pit interrupts the whole time
In this configuration the arduino never sleeps ..sensor started, id 10
send: 10-10-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
read: 0-0-10 s=255,c=3,t=6,pt=0,l=1:M
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=13,st=ok:Motion Sensor
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=1,c=0,t=1,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=8,st=ok:Humidity
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=2,c=0,t=7,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=3,c=0,t=6,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=11,pt=0,l=12,st=ok:Light Sensor
send: 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 10-10-0-0 s=4,c=0,t=16,pt=0,l=5,st=ok:1.4.1
send: 10-10-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:100
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=3,c=1,t=0,pt=7,l=5,st=ok:16.5
---------- Temp: 16.50
send: 10-10-0-0 s=2,c=1,t=1,pt=7,l=5,st=ok:43.9
---------- Humidity: 43.90
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:38
---------- Light: 38
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=3,c=1,t=0,pt=7,l=5,st=ok:16.6
---------- Temp: 16.60
send: 10-10-0-0 s=2,c=1,t=1,pt=7,l=5,st=ok:43.8
---------- Humidity: 43.80
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:37
---------- Light: 37
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
send: 10-10-0-0 s=3,c=1,t=0,pt=7,l=5,st=ok:16.5
---------- Temp: 16.50
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:38EDIT: i have changed the sleeptime for testing to a shorter time
-
RE: Multisensor PIR problem [solved]
@rvendrame The DHT is on pin 2 and the pir on pin 3. i use the MYS PCB.
i suspect the delay function disturb the sleep function. if i dont use the delay, the dht cant "heat up".
far as I know the interrupt is only an internal value. right?
-
RE: Multisensor PIR problem [solved]
hmm
if is use this:#include <MySensor.h> #include <readVcc.h> #include <SPI.h> #include <DHT.h> #define NODE_ID 10 // ID of node unsigned long SLEEP_TIME = 10000; // Sleep time between reports (in milliseconds) #define CHILD_ID_PIR 1 // Id of the sensor PIR #define CHILD_ID_HUM 2 // Id of the sensor HUM #define CHILD_ID_TEMP 3 // Id of the sensor TEMP #define CHILD_ID_LIGHT 4 // Id of the sensor LIGHT #define PIR_SENSOR_DIGITAL 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT PIR_SENSOR_DIGITAL-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define HUMIDITY_SENSOR_DIGITAL_PIN 2 #define LIGHT_SENSOR_ANALOG_PIN 0 MySensor gw; // Initialize Variables MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); DHT dht; float lastTemp; float lastHum; boolean metric = true; int oldBatteryPcnt; int lastLightLevel; long mytime = 0; int MIN_V = 2700; // empty voltage (0%) int MAX_V = 3200; // full voltage (100%) void setup() { gw.begin(NULL, NODE_ID, false); //PIR // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Motion Sensor", "1.0"); pinMode(PIR_SENSOR_DIGITAL, INPUT); // sets the motion sensor digital pin as input digitalWrite(PIR_SENSOR_DIGITAL, HIGH); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_PIR, S_MOTION); //DHT dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; //LIGHT // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Light Sensor", "1.0"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop() { // Read digital motion value boolean tripped = digitalRead(PIR_SENSOR_DIGITAL) == HIGH; Serial.print("---------- PIR: "); Serial.println(tripped); gw.send(msgPir.set(tripped ? "1" : "0")); // Send tripped value to gw if ( millis() > mytime ) { //DHT delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("---------- Temp: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("---------- Humidity: "); Serial.println(humidity); } // Light int lightLevel = (1023 - analogRead(LIGHT_SENSOR_ANALOG_PIN)) / 10.23; //Serial.println(lightLevel); if (lightLevel != lastLightLevel) { gw.send(msgLight.set(lightLevel)); lastLightLevel = lightLevel; Serial.print("---------- Light: "); Serial.println(lightLevel); } // Measure battery float batteryV = readVcc(); int batteryPcnt = (((batteryV - MIN_V) / (MAX_V - MIN_V)) * 100 ); if (batteryPcnt > 100) { batteryPcnt = 100; } if (batteryPcnt != oldBatteryPcnt) { gw.sendBatteryLevel(batteryPcnt); // Send battery percentage oldBatteryPcnt = batteryPcnt; } Serial.print("---------- Battery: "); Serial.println(batteryPcnt); mytime = millis() + dht.getMinimumSamplingPeriod(); } Serial.println(mytime); // Sleep until interrupt comes in on motion sensor. Send update every two minute. gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); }
i get this output:
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
6608
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
6608
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
6608
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
6608
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
send: 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
send: 10-10-0-0 s=2,c=1,t=1,pt=7,l=5,st=fail:41.7
---------- Humidity: 41.70
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=fail:38
---------- Light: 38
---------- Battery: 100
11148
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
11148
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
11148
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
11148
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
11148
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
send: 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
---------- Battery: 100
15441
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
15441
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
15441
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=fail:0
15441
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1the pir sends 0 and didnt sleep right
-
RE: Multisensor PIR problem [solved]
@rvendrame
if i use this:#include <MySensor.h> #include <readVcc.h> #include <SPI.h> #include <DHT.h> #define NODE_ID 10 // ID of node unsigned long SLEEP_TIME = 600000; // Sleep time between reports (in milliseconds) #define CHILD_ID_PIR 1 // Id of the sensor PIR #define CHILD_ID_HUM 2 // Id of the sensor HUM #define CHILD_ID_TEMP 3 // Id of the sensor TEMP #define CHILD_ID_LIGHT 4 // Id of the sensor LIGHT #define PIR_SENSOR_DIGITAL 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT PIR_SENSOR_DIGITAL-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define HUMIDITY_SENSOR_DIGITAL_PIN 2 #define LIGHT_SENSOR_ANALOG_PIN 0 MySensor gw; // Initialize Variables MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); DHT dht; float lastTemp; float lastHum; boolean metric = true; int oldBatteryPcnt; int lastLightLevel; int MIN_V = 2700; // empty voltage (0%) int MAX_V = 3200; // full voltage (100%) void setup() { gw.begin(NULL, NODE_ID, false); //PIR // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Motion Sensor", "1.0"); pinMode(PIR_SENSOR_DIGITAL, INPUT); // sets the motion sensor digital pin as input digitalWrite(PIR_SENSOR_DIGITAL, HIGH); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_PIR, S_MOTION); //DHT dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; //LIGHT // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Light Sensor", "1.0"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop() { // Measure battery float batteryV = readVcc(); int batteryPcnt = (((batteryV - MIN_V) / (MAX_V - MIN_V)) * 100 ); if (batteryPcnt > 100) { batteryPcnt = 100; } if (batteryPcnt != oldBatteryPcnt) { gw.sendBatteryLevel(batteryPcnt); // Send battery percentage oldBatteryPcnt = batteryPcnt; } Serial.print("---------- Battery: "); Serial.println(batteryPcnt); // Read digital motion value boolean tripped = digitalRead(PIR_SENSOR_DIGITAL) == HIGH; Serial.print("---------- PIR: "); Serial.println(tripped); gw.send(msgPir.set(tripped ? "1" : "0")); // Send tripped value to gw //DHT //delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("---------- Temp: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("---------- Humidity: "); Serial.println(humidity); } // Light int lightLevel = (1023 - analogRead(LIGHT_SENSOR_ANALOG_PIN)) / 10.23; //Serial.println(lightLevel); if (lightLevel != lastLightLevel) { gw.send(msgLight.set(lightLevel)); lastLightLevel = lightLevel; Serial.print("---------- Light: "); Serial.println(lightLevel); } // Sleep until interrupt comes in on motion sensor. Send update every two minute. gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); }
the pir works fine. but the dht doesn't work.
when delay(dht.getMinimumSamplingPeriod()); is used the dht works and the pir fails.
-
RE: Multisensor PIR problem [solved]
@rvendrame do you have an idea how to do it?
-
RE: Multisensor PIR problem [solved]
I have a idea,
is it possible to build a second loop like this?
But now i have one problem... the loop2 never run...#include <MySensor.h> #include <readVcc.h> #include <SPI.h> #include <DHT.h> #include <Scheduler.h> #define NODE_ID 11 // ID of node unsigned long SLEEP_TIME = 600000; // Sleep time between reports (in milliseconds) #define CHILD_ID_PIR 1 // Id of the sensor PIR #define CHILD_ID_HUM 2 // Id of the sensor HUM #define CHILD_ID_TEMP 3 // Id of the sensor TEMP #define CHILD_ID_LIGHT 4 // Id of the sensor LIGHT #define PIR_SENSOR_DIGITAL 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT PIR_SENSOR_DIGITAL-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define HUMIDITY_SENSOR_DIGITAL_PIN 2 #define LIGHT_SENSOR_ANALOG_PIN 0 MySensor gw; // Initialize Variables MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); DHT dht; float lastTemp; float lastHum; boolean metric = true; int oldBatteryPcnt; int lastLightLevel; unsigned long time; int MIN_V = 2700; // empty voltage (0%) int MAX_V = 3200; // full voltage (100%) void setup() { gw.begin(NULL, NODE_ID, false); //PIR // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Motion Sensor", "1.0"); pinMode(PIR_SENSOR_DIGITAL, INPUT); // sets the motion sensor digital pin as input digitalWrite(PIR_SENSOR_DIGITAL, HIGH); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_PIR, S_MOTION); //DHT dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; //LIGHT // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Light Sensor", "1.0"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); Scheduler.startLoop(loop2); } void loop() { // Read digital motion value boolean tripped = digitalRead(PIR_SENSOR_DIGITAL) == HIGH; Serial.print("---------- PIR: "); Serial.println(tripped); gw.send(msgPir.set(tripped ? "1" : "0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); } void loop2() { //DHT //dht.begin(); delay(dht.getMinimumSamplingPeriod()); //delay(1000); //millis(dht.getMinimumSamplingPeriod()); //Serial.print(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("---------- Temp: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("---------- Humidity: "); Serial.println(humidity); } // Light int lightLevel = (1023 - analogRead(LIGHT_SENSOR_ANALOG_PIN)) / 10.23; //Serial.println(lightLevel); if (lightLevel != lastLightLevel) { gw.send(msgLight.set(lightLevel)); lastLightLevel = lightLevel; Serial.print("---------- Light: "); Serial.println(lightLevel); } // Measure battery float batteryV = readVcc(); int batteryPcnt = (((batteryV - MIN_V) / (MAX_V - MIN_V)) * 100 ); if (batteryPcnt > 100) { batteryPcnt = 100; } if (batteryPcnt != oldBatteryPcnt) { gw.sendBatteryLevel(batteryPcnt); // Send battery percentage oldBatteryPcnt = batteryPcnt; } Serial.print("---------- Battery: "); Serial.println(batteryPcnt); gw.sleep(SLEEP_TIME); }
i have downloaded THIS
But i get this error when compiling:
In file included from MotionSensor_DHT_light_battery_mod.ino:6:0:
Arduino\libraries\Scheduler/Scheduler.h:33:22: fatal error: WProgram.h: No such file or directory
#include <WProgram.h> -
RE: Multisensor PIR problem [solved]
@torfinn said:
dht.begin();
Hey torfinn,
i get this error when compiling:
MotionSensor_DHT_light_battery_mod.ino: In function 'void loop()':
MotionSensor_DHT_light_battery_mod.ino:109:7: error: 'class DHT' has no member named 'begin'
Fehler beim Kompilieren. -
RE: Multisensor PIR problem [solved]
can somebody help me with my sketch? i dont understand millis
-
RE: Multisensor PIR problem [solved]
ufff. to build a multisensor sketch is really hard
thx for your info!
-
RE: Multisensor PIR problem [solved]
@andriej hey,
the PIR works perfect now, but the DHT didnt update... Only the first startup of the arduino works:
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=3,c=1,t=0,pt=7,l=5,st=ok:20.5
---------- Temp: 20.50
send: 10-10-0-0 s=2,c=1,t=1,pt=7,l=5,st=ok:34.6
---------- Humidity: 34.60
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:87
---------- Light: 87
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:84
---------- Light: 84
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:88
---------- Light: 88
---------- Battery: 100
---------- PIR: 1
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:1
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:83
---------- Light: 83
---------- Battery: 100
---------- PIR: 0
send: 10-10-0-0 s=1,c=1,t=16,pt=0,l=1,st=ok:0
send: 10-10-0-0 s=4,c=1,t=23,pt=2,l=2,st=ok:87
---------- Light: 87
---------- Battery: 100
---------- PIR: 1