3 in 1 incl battery monitor
-
@the-cosmic-gate Did you solved your power consumption issue ?
-
@the-cosmic-gate Did you solved your power consumption issue ?
@carlierd said:
@the-cosmic-gate Did you solved your power consumption issue ?
Not yet, this because we moved to oneother house and didn't have the time now .
Also i had to disconnect and reconect all te sensors and domotica in this new house -
I just finished my first motion sensor node and the power consumption in idle is about 75uA. Could be better but not too bad ;)
The only thing is that the range is a little bit low for good detection. It's between 1 and 3 meters ...David.
@carlierd said:
I just finished my first motion sensor node and the power consumption in idle is about 75uA. Could be better but not too bad ;)
The only thing is that the range is a little bit low for good detection. It's between 1 and 3 meters ...David.
Hello David
Could you share what and how ? :)
Thnx
-
Hello,
This is the code I use but it's not perfect especially with the battery report.
The principle is as follow when the sensor start:
- node in sleep mode with interrupt enable
- if a move is detected, the detection is reported to the gateway
- the node then go in sleep mode WITHOUT interrupt for 5 minutes
- then the node return to sleep mode with interrupt enable
This is to avoid having many report (and power consumption) to the gateway.
The code (not perfect ! I have to rework on it but it's ok for the moment):
/** * 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. * */ /**************************************************************************************/ /* Motion sensor. */ /* */ /* Version : 1.1.5 */ /* Date : 30/01/2016 */ /* Modified by : David Carlier */ /**************************************************************************************/ /* --------------- */ /* RST | | A5 */ /* RX | | A4 */ /* TX | ARDUINO | A3 */ /* RFM69 (DIO0) --------- D2 | UNO | A2 */ /* Motion --------- D3 | | A1 */ /* Power --------- D4 | ATMEGA 328p | A0 */ /* +3v --------- VCC | | GND --------- GND */ /* GND --------- GND | 8MHz int. | REF */ /* OSC | | VCC --------- +3v */ /* OSC | | D13 --------- RFM69 (SCK) */ /* D5 | | D12 --------- RFM69 (MISO) */ /* D6 | | D11 --------- RFM69 (MOSI) */ /* D7 | | D10 --------- RFM69 (NSS) */ /* D8 | | D9 */ /* --------------- */ /* */ /* +3v = 2*AA */ /* */ /**************************************************************************************/ #include <SPI.h> #include <MySensor.h> #include <MyTransportRFM69.h> #include <MySigningAtsha204Soft.h> //Constants #define SKETCH_NAME "Motion Sensor" #define SKETCH_VERSION "1.1.5" #define CHILD_ID 0 #define CHILD_ID_VOLTAGE 1 #define DIGITAL_INPUT_SENSOR 3 #define BATTERY_REPORT_CYCLE 4 //Report each hour (4 * 15') //Misc. variables uint8_t switchState = 2; unsigned long SLEEP_TIME = 820000; // Sleep time between reads (in milliseconds) (close to 15') unsigned long SLEEP_TIME2 = 275000; // Sleep time after int. (in milliseconds) (close to 5') uint8_t cycleInProgress = 0; uint8_t firstReportDone = 0; uint8_t firstReportWithZeroDone = 0; //Construct MySensors library MySigningAtsha204Soft signer; MyHwATMega328 hw; MyTransportRFM69 transport; MySensor node(transport, hw, signer); MyMessage msgSwitch(CHILD_ID, V_TRIPPED); MyMessage msgVolt(CHILD_ID_VOLTAGE, V_VOLTAGE); /**************************************************************************************/ /* Initialization */ /**************************************************************************************/ void setup() { //Get time (for setup duration) #ifdef DEBUG unsigned long startTime = millis(); #endif //Start MySensors and send the Sketch Version Information to the Gateway node.begin(); node.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); //Setup the button pinMode(DIGITAL_INPUT_SENSOR, INPUT); //Register all sensors node.present(CHILD_ID, S_MOTION); node.present(CHILD_ID_VOLTAGE, S_MULTIMETER); //Print setup debug #ifdef DEBUG int duration = millis() - startTime; Serial.print("[Setup duration: "); Serial.print(duration, DEC); Serial.println(" ms]"); #endif } /**************************************************************************************/ /* Main loop */ /**************************************************************************************/ void loop() { //Get time (for a complete loop) #ifdef DEBUG unsigned long startTime = millis(); #endif //Read digital motion value uint8_t value = digitalRead(DIGITAL_INPUT_SENSOR); //Get voltage for battery capacity report (add 0.1v to the read value) float realVoltage = (getVoltage() / 100.0) + 0.1; int batteryPcnt = realVoltage * 100 / 3.0; if (batteryPcnt > 100) {batteryPcnt = 100;} //Check is state change if (value != switchState) { //Report result if not first loop if (firstReportDone != 0) { node.send(msgSwitch.set(value==HIGH ? 1 : 0)); } //Store result switchState = value; } //Report data to the gateway each hour if (cycleInProgress >= BATTERY_REPORT_CYCLE || firstReportDone == 0) { node.send(msgSwitch.set(value==HIGH ? 1 : 0)); node.send(msgVolt.set(realVoltage, 2)); node.sendBatteryLevel(batteryPcnt); cycleInProgress = 0; firstReportDone = 1; } //Change cycle number cycleInProgress++; //Print debug #ifdef DEBUG Serial.print("Value is "); Serial.print(value, 1); Serial.print(" "); Serial.print("Cycle is "); Serial.print(cycleInProgress, 1); Serial.print(" "); Serial.print(realVoltage); Serial.print(" v"); int duration = millis() - startTime; Serial.print(" "); Serial.print("["); Serial.print(duration, DEC); Serial.println(" ms]"); Serial.flush(); #endif //Check if the motion was triggered and if it's not the first report if (switchState == 0 && firstReportWithZeroDone == 1) { //Sleep 5' without interrupt node.sleep(SLEEP_TIME2); } //Check if it's the first loop if (switchState == 0 && firstReportWithZeroDone == 0) { firstReportWithZeroDone = 1; } //Sleep until something happens with the sensor node.sleep(DIGITAL_INPUT_SENSOR-2, CHANGE, SLEEP_TIME); } /**************************************************************************************/ /* Allows to get the real Vcc (return value * 100). */ /**************************************************************************************/ int getVoltage() { const long InternalReferenceVoltage = 1056L; ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0); delay(50); // Let mux settle a little to get a more stable A/D conversion //Start a conversion ADCSRA |= _BV( ADSC ); //Wait for it to complete while (((ADCSRA & (1<<ADSC)) != 0)); //Scale the value int result = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L; return result; }On one sensor I tweak the PIR (remove regulator and diode) but on a second one, I just plug the 3 v to the H pin (see other topic on the forum).
Working correctly for the moment (one month) but it depends on the presence in the house.
David.
-
@ Carlied,
What code is better that one of you or the one from cosmi gate?
What are the different thing? Is your code check'the battery status?
And i get a error:
no matching function for call to 'MySensor::MySensor(MyTransportRFM69&, MyHwATMega328&, MySigningAtsha204Soft&)' -
The error is because I enable the signing function !
Remove the following line:MySigningAtsha204Soft signer;And replace
MySensor node(transport, hw, signer);by
MySensor node(transport, hw);I don't know who had the best sketch.
I measure internal battery status using the 1.1 reference.David.
-
@the-cosmic-gate Nothing special. I made a big sketch, which contains 7-8 sensors (DHT, Si7021, MQ-2/9, PIR, Door magnet, Light, battery) reading code because I would like to upload the same sketch to all nodes and configurate it on controller side, which sensors is on the node and need to read.
But currently I reached the limit with I2C includes, so I need to think over this solution.@icebob said:
@the-cosmic-gate Nothing special. I made a big sketch, which contains 7-8 sensors (DHT, Si7021, MQ-2/9, PIR, Door magnet, Light, battery) reading code because I would like to upload the same sketch to all nodes and configurate it on controller side, which sensors is on the node and need to read.
But currently I reached the limit with I2C includes, so I need to think over this solution.Dear..
Did you finish your big code.... -
Hello,
9v means that you are using a voltage regulator which probably consumes a lot of power.
Why not using AA or AAA battery directly connected to Vcc ?David
@carlierd said:
Hello,
9v means that you are using a voltage regulator which probably consumes a lot of power.
Why not using AA or AAA battery directly connected to Vcc ?David
Motion and DHT needed 5volt i wash thinking..?
So 9 @ the vcc should be strong enough i was thinking.
And i do have @ the same time 3.5 for the radioAre the extern step up better than the step down on a nano?
-
The motion can be adapt to run on 3v easily (connect the Vcc to the H pad if available. You can find information on the forum). The DHT could also run on 3v. I have several nodes like that. No problem.
Can't reply for the step-up because I don't use it.David.
-
The motion can be adapt to run on 3v easily (connect the Vcc to the H pad if available. You can find information on the forum). The DHT could also run on 3v. I have several nodes like that. No problem.
Can't reply for the step-up because I don't use it.David.
@carlierd said:
The motion can be adapt to run on 3v easily (connect the Vcc to the H pad if available. You can find information on the forum). The DHT could also run on 3v. I have several nodes like that. No problem.
Can't reply for the step-up because I don't use it.David.
@ David
How long is the 3v battery running whit this option?
-
i'am back in business after the "big move" and going to try again to get this 4:1 sensor working for a long time uning 2 x AA batteries.
If someone has some new input, please let me know :) and feel free to change the sketch -
i'am back in business after the "big move" and going to try again to get this 4:1 sensor working for a long time uning 2 x AA batteries.
If someone has some new input, please let me know :) and feel free to change the sketch@the-cosmic-gate
Hello,
Motion nodes are still working correctly. The oldest node started the 4 of February is still at 3,29v. My other nodes (temp / humidity / light) are also working correctly but I will replace DHT22 for another sensor.David.
-
Hey @carlierd Just curious if you are still using a DHT22 with your sketch? Have you modified the code much from the above? I am looking at implementing something similiar ( identical actually ) and was wondering if much has changed for you over the last few months?
Thanks!