Thank you @TheoL !
It's working fine with your change.
chatainsim
@chatainsim
Best posts made by chatainsim
-
RE: Trying to build a Door and Sound sensors
Latest posts made by chatainsim
-
RE: Sensors stop working after some time
@TheoL I'll try with other Dupont cables.
My gateway was at first working with a normal NRF24L01+ radio and there was the same issue so I decided to switch to the + pa +lna instead. -
RE: Sensors stop working after some time
Thank you @TheoL
Here is the Humidity Temp node sketch:/** * 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 * This sketch provides an example how to implement a humidity/temperature * sensor using DHT11/DHT-22 * http://www.mysensors.org/build/humidity */ #include <SPI.h> #include <MySensor.h> #include <DHT.h> //Sensor ID1 ID2 //Temp Salon T: 10 H: 11 //Temp Balcon T: 12 H: 13 //Temp SDB T: 14 H: 15 //Temp Bebe T: 16 H:17 //Temp Chambre T:18 H:19 #define CHILD_ID_HUM 15 #define CHILD_ID_TEMP 14 #define HUMIDITY_SENSOR_DIGITAL_PIN 3 unsigned long SLEEP_TIME = 30000; // 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() { 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); } gw.sleep(SLEEP_TIME); //sleep a bit }
The antenna is powered by the Arduino Nano itself.
But if the problem is the gateway, so there should be an issue with all sensors at the same time ? -
RE: Sensors stop working after some time
Hello @TheoL
I'm using DHT-11, DHT-22, BH1750, HC-SR501, Relay and SCT-013-030.
For all sensors except SCT-013-030, I'm using MySensors sketch.
And for the SCT-013-030 here is the sketch:// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3 ***/ #include <SPI.h> #include <MySensor.h> #include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; // Create an instance #define CHILD_ID 99 #define PIN_ANALOG_I A2 MySensor gw; unsigned long lastSend; unsigned long lastSend2; unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway. unsigned long SEND_FREQUENCY2 = SEND_FREQUENCY / 25; int index = 0; double Irms=0; double power; boolean pcReceived = false; boolean onyva=true; boolean debug=false; float nrj=0, old_nrj; MyMessage IrmsMsg(CHILD_ID,V_WATT); MyMessage kWhMsg(CHILD_ID,V_KWH); MyMessage pcMsg(CHILD_ID,V_VAR1); void incomingMessage(const MyMessage &message) { if (message.type==V_VAR1) { nrj = old_nrj = message.getFloat(); Serial.print("Received last nrj count from gw:"); Serial.println(nrj); pcReceived = true; } } void setup() { gw.begin(incomingMessage); gw.sendSketchInfo("Energy Meter", "1.0"); // Send the sketch version information to the gateway and Controller gw.present(CHILD_ID, S_POWER); // Register this device as power sensor gw.request(CHILD_ID, V_VAR1); emon1.current(PIN_ANALOG_I, 30.0); // Current: input pin, calibration. } void loop() { if (debug) Serial.println("Starting..."); if (onyva) gw.process(); onyva = false; unsigned long now = millis(); //unsigned long now2 = millis(); bool sendTime2 = now - lastSend2 > SEND_FREQUENCY2; if (sendTime2) //calcul Irms moy { if (index==0) Irms=emon1.calcIrms(1480); else { index++; Irms = (index*Irms+emon1.calcIrms(1480))/(index+1); } lastSend2 = now; } bool sendTime = now - lastSend > SEND_FREQUENCY; if (debug) Serial.print("DEBUG: "); if (debug) Serial.println(Irms*232.0); if (sendTime && pcReceived) { power = Irms*232.0; if (debug) Serial.println("Sending data ..."); gw.send(IrmsMsg.set(power,1)); Serial.println(Irms*232.0); nrj += (power*SEND_FREQUENCY/1000)/3.6E6; gw.send(kWhMsg.set(nrj,5)); gw.send(pcMsg.set(nrj,5)); lastSend = now; index = 0; old_nrj=nrj; onyva=true; } else if (sendTime && !pcReceived) { if (debug) Serial.println("DEBUG AGAIN ..."); gw.request(CHILD_ID, V_VAR1); lastSend=now; index=0; onyva=true; } }
The Relay never fail and I've setup the BH1750 only one week ago without issue for now.
For the Relay, I'm using an Arduino Uno and Arduino nano for all other sensors.
The gateway (serial) is an Arduino Nano with NRF24L01+PA+LNA Antenna version.With Domoticz 3.5502 under Linux.
Thank you !
-
RE: Sensors stop working after some time
@TheoL So I've tried with different adapter but it's still the same issue.
It's working fine for 1 or 2 week than sensors stop working.
I have to clear eeprom then upload the sketch again.
I will try with mysensors 2.0 to see if something change.
Do you know if it's possible to maybe only clean eeprom without having to plug arduino to a computer ? Maybe only with the button on the arduino nano ? -
RE: Sensors stop working after some time
Thanks @TheoL I will look into it.
Regarding the capacitor, I've mounted them like @petewill did in his videos.And for the outlet I use one per rooms for the temp/humidity sensors.
Same for the power adapter, they are all different, for old iPhone charger or chromecast power adapter but this strange behavior still appear.I'll keep you posted !
Thank you.
-
RE: Sensors stop working after some time
Has you can see, only humidity is reported:
2016-04-24 00:17:38.627 (MySensors) Humidity (Hum) 2016-04-24 00:17:47.120 (MySensors) Humidity (Hum) 2016-04-24 00:17:50.172 (MySensors) Humidity (Hum) 2016-04-24 00:18:03.057 (MySensors) Humidity (Hum) 2016-04-24 00:18:11.975 (MySensors) Humidity (Hum) 2016-04-24 00:18:21.601 (MySensors) Humidity (Hum) 2016-04-24 00:18:38.708 (MySensors) Humidity (Hum) 2016-04-24 00:18:45.324 (MySensors) Humidity (Hum) 2016-04-24 00:18:45.491 (MySensors) Humidity (Hum) 2016-04-24 00:18:53.029 (MySensors) Humidity (Hum) 2016-04-24 00:19:14.361 (MySensors) Humidity (Hum) 2016-04-24 00:19:20.774 (MySensors) Humidity (Hum)
But they are hum+temp sensors with a DHT22.
Then it's start working again ... almost:
2016-04-24 00:21:01.322 (MySensors) Temp + Humidity (Salle de bain) 2016-04-24 00:21:04.879 (MySensors) Temp + Humidity (Salon) 2016-04-24 00:21:06.602 (MySensors) Humidity (Hum)
-
Sensors stop working after some time
Hello,
I have an issue with my sensors.
After some time they are stop working.
The only way I've found is to clear the eeprom then upload my sketch again.
I'm using Arduino nano with 4.7uF capacitor.The gateway use a NRF24L01+PA+LNA Antenna version with capacitor too.
I've already change all my NRF24 on all node but same thing happen.
I even change all Arduino nano.For the Humidity sensors, sometimes gateway only get temperature or humdity then both are getting again.
Some sensors closer to the gateway stop working first so I think this is not a distance issue.
The farthest sensors is at less than 20 meters from the gateway.Can you help me with this ?
Thank you.
Regards,
-
RE: Trying to build a Door and Sound sensors
Thank you @TheoL !
It's working fine with your change. -
RE: Trying to build a Door and Sound sensors
Thanks @TheoL , I've tried with 10ms but the door sensor doesn't detect the opening.
No, I haven't added a pullup resistor to the door sensor.
I'll try your change. -
Trying to build a Door and Sound sensors
Hello,
I'm trying to build a door and sound sensors with the same arduino.
But I have some issue.
Code seems fine but when the door is open status is changing every time from 1 to 0 to 1 to 0 ...
But when door is closed it's not happening.Can you help me with this ?
Here is my code: (I've commented the gw.send so gateway is not flood)
// Sound sensor come fome: // From Henry's Bench // http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-sound-detection-sensor-tutorial-and-user-manual/ // Arduino Sound Detection Sensor Module // Door sensor come from: // #include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define ID 100 #define CHILD_ID 101 #define OPEN 1 #define CLOSE 0 #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch #define SOUND_PIN 5 // Arduino Digital I/O pin for sound sensor MySensor gw; Bounce debouncer = Bounce(); int oldValue=-1; MyMessage msgring(ID, V_TRIPPED); MyMessage msgdoor(CHILD_ID,V_TRIPPED); int soundDetectedVal = HIGH; // This is where we record our Sound Measurement boolean bAlarm = false; unsigned long lastSoundDetectTime; // Record the time that we measured a sound int soundAlarmTime = 500; // Number of milli seconds to keep the sound alarm high void setup () { Serial.begin(115200); gw.begin(); pinMode(SOUND_PIN,INPUT) ; // input from the Sound Detection Module pinMode(BUTTON_PIN,INPUT); debouncer.attach(BUTTON_PIN); debouncer.interval(5); gw.present(ID, S_DOOR); gw.present(CHILD_ID, S_DOOR); } void loop () { soundDetectedVal = digitalRead (SOUND_PIN) ; // read the sound alarm time debouncer.update(); int value = debouncer.read(); if (value != oldValue) { Serial.print("Door value: "); Serial.println(value); //gw.send(msgdoor.set(value==HIGH ? 1 : 0)); oldValue = value; } if (soundDetectedVal == LOW) // If we hear a sound { lastSoundDetectTime = millis(); // record the time of the sound alarm // The following is so you don't scroll on the output screen if (!bAlarm){ Serial.println("LOUD, LOUD"); //gw.send(msgring.set(OPEN)); bAlarm = true; } } else { if( (millis()-lastSoundDetectTime) > soundAlarmTime && bAlarm){ Serial.println("quiet"); //gw.send(msgring.set(CLOSE)); bAlarm = false; } } }
Sound and soor sensor are connected to the same ground.
Here is the output:
send: 18-18-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0 send: 18-18-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4 send: 18-18-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0 read: 0-0-18 s=255,c=3,t=6,pt=0,l=1,sg=0:M sensor started, id=18, parent=0, distance=1 send: 18-18-0-0 s=100,c=0,t=0,pt=0,l=0,sg=0,st=ok: send: 18-18-0-0 s=101,c=0,t=0,pt=0,l=0,sg=0,st=ok:
Door is lock:
Door value: 0
Testing sound sensor, working fine:
LOUD, LOUD quiet LOUD, LOUD quiet
Door is open it's flapping:
Door value: 1 Door value: 0 Door value: 1 Door value: 0 Door value: 1 Door value: 0 Door value: 1
Thank you !