Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. 3 in 1 incl battery monitor

3 in 1 incl battery monitor

Scheduled Pinned Locked Moved My Project
60 Posts 11 Posters 30.0k Views 12 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • the cosmic gateT Offline
    the cosmic gateT Offline
    the cosmic gate
    wrote on last edited by
    #21

    Running the sketch for 1 Monty (+-), and the AA batteries are dead empty ?
    I did all the "possible" mods on the arduino ( cut the LED an V ) , what can i do to make this sketch run langer on this 2AA batteries ?
    Something in the sketch , some fine tuning or something else ?
    When read the arduino hardware tweaking topics on different forums they dat that running for 1 year ( and more) is possible but how ;-)?

    There's more than meets the eye

    1 Reply Last reply
    0
    • carlierdC Offline
      carlierdC Offline
      carlierd
      wrote on last edited by
      #22

      Hello,

      Did you measured the current of your circuit ?
      What motion sensor are you using ? This component may consume a lot of current. Did you check this post ?

      If you wake-up the arduino every 30 seconds for measurement it's a problem. Every 5 minutes is the minimum I think. I have connected the Vcc pin of the DHT sensors and the Vcc of the LDR to a digital pin of the arduino and when a measurement is done I set the PIN to the HIGH state.

      First measurement of my sensor gives an IDLE current consumption close to 5uA which is really correct according to elements connected to the arduino (RFM69HW, DHT22 and LDR).

      David.

      the cosmic gateT 1 Reply Last reply
      0
      • bjacobseB Offline
        bjacobseB Offline
        bjacobse
        wrote on last edited by
        #23

        Yes as Carlierd writes, it's important that the Arduino are controlling the voltage to the external components, like DHT.
        I might have overlooked, but which component are you using for motion sensing? maybe this component is also power-hungry

        1 Reply Last reply
        0
        • icebobI Offline
          icebobI Offline
          icebob
          wrote on last edited by
          #24

          @the-cosmic-gate Now I measured my dev circuit (Arduino Nano from China (cutted power led and desoldered regulator) + DHT22 + PIR + Battery measure resistor divider) and in gw.sleep (with 1 interrupt for PIR) the power comsumption is ~90uA.
          DSC_9591_rs.jpg
          It wakes up every minutes, measuring and sending (~100ms and 5 - 20mA).
          So 100ms with 20mA and 59900ms with 0.09mA. The average current is 120uA and with 2 AA battery it is about 2 years.
          ardu_batt.png

          1 Reply Last reply
          0
          • E Offline
            E Offline
            ericvdb
            wrote on last edited by
            #25

            @icebob,
            whats that app you are using to do the battery calculations?

            1 Reply Last reply
            0
            • carlierdC Offline
              carlierdC Offline
              carlierd
              wrote on last edited by
              #26

              @icebob
              100ms for measurement and transmission seems very small ! I am at approximately 1500ms.
              Give me your secret now !! ;)

              1 Reply Last reply
              0
              • icebobI Offline
                icebobI Offline
                icebob
                wrote on last edited by
                #27

                @ericvdb http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en545243. It's specified for PIC, but I select SLEEP mode in every cycle, so I can use for any uC.

                @carlierd: I have no extra secret. If I measure 3-4 sensor and every values is changed, the loop time is 100ms. Best case is 10-20ms (if every sensors is unchanged). I'm not using delay in the loop.

                1 Reply Last reply
                0
                • carlierdC Offline
                  carlierdC Offline
                  carlierd
                  wrote on last edited by
                  #28

                  @icebob: It's true that as I used signing feature, transmission is longer ! and in order to increase a little bit more I send every measure even if they not changed. I will probably upgrade my sketch to add a one-hour message at minimum and do not transfer mesure without change !

                  1 Reply Last reply
                  0
                  • carlierdC carlierd

                    Hello,

                    Did you measured the current of your circuit ?
                    What motion sensor are you using ? This component may consume a lot of current. Did you check this post ?

                    If you wake-up the arduino every 30 seconds for measurement it's a problem. Every 5 minutes is the minimum I think. I have connected the Vcc pin of the DHT sensors and the Vcc of the LDR to a digital pin of the arduino and when a measurement is done I set the PIN to the HIGH state.

                    First measurement of my sensor gives an IDLE current consumption close to 5uA which is really correct according to elements connected to the arduino (RFM69HW, DHT22 and LDR).

                    David.

                    the cosmic gateT Offline
                    the cosmic gateT Offline
                    the cosmic gate
                    wrote on last edited by the cosmic gate
                    #29

                    @carlierd said:

                    Hello,

                    Did you measured the current of your circuit ?
                    What motion sensor are you using ? This component may consume a lot of current. Did you check this post ?

                    If you wake-up the arduino every 30 seconds for measurement it's a problem. Every 5 minutes is the minimum I think. I have connected the Vcc pin of the DHT sensors and the Vcc of the LDR to a digital pin of the arduino and when a measurement is done I set the PIN to the HIGH state.

                    First measurement of my sensor gives an IDLE current consumption close to 5uA which is really correct according to elements connected to the arduino (RFM69HW, DHT22 and LDR).

                    David.

                    Hello David,
                    I tried to meassure , but didn't have the right stuff to do this good enough.
                    The parts i use for this "project": DHT-22 (connected to D4), HC-SR501 (connected to D3)and connected to the 3.3V pin post , the VVC is connected to the VVC of the arduino pro mini 8 Mhz /3.3 V .
                    And use the sketch as above:

                    #include <SPI.h>
                    #include <MySensor.h>  
                    #include <DHT.h>  
                    
                    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
                    
                    #define CHILD_ID_HUM 0
                    #define CHILD_ID_TEMP 1
                    #define CHILD_ID_MOT 2   // Id of the sensor child
                    
                    #define HUMIDITY_SENSOR_DIGITAL_PIN 4
                    #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)
                    
                    unsigned long SLEEP_TIME = 30000UL; // Sleep time between reads (in milliseconds)
                    int oldBatteryPcnt = 0;
                    
                    MySensor gw;
                    DHT dht;
                    float lastTemp = 0 ;
                    float lastHum = 0 ;
                    boolean lastTripped = false ;
                    boolean metric = true; 
                    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
                    MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED);
                    
                    void setup()  
                    { 
                       // use the 1.1 V internal reference
                    #if defined(__AVR_ATmega2560__)
                       analogReference(INTERNAL1V1);
                    #else
                       analogReference(INTERNAL);
                    #endif
                      gw.begin();
                      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
                    
                      // Send the Sketch Version Information to the Gateway
                      gw.sendSketchInfo("Humidity/Motion", "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_HUM, S_HUM);
                      gw.present(CHILD_ID_TEMP, S_TEMP);
                      gw.present(CHILD_ID_MOT, S_MOTION);
                       
                      metric = gw.getConfig().isMetric;
                    }
                    
                    void loop()      
                    
                    {  
                      // get the battery Voltage
                       int sensorValue = analogRead(BATTERY_SENSE_PIN);
                       #ifdef DEBUG
                       Serial.println(sensorValue);
                       #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
                       float batteryV  = sensorValue * 0.003363075;
                       int batteryPcnt = sensorValue / 10;
                    
                       #ifdef DEBUG
                       Serial.print("Battery Voltage: ");
                       Serial.print(batteryV);
                       Serial.println(" V");
                    
                       Serial.print("Battery percent: ");
                       Serial.print(batteryPcnt);
                       Serial.println(" %");
                       #endif
                    
                       if (oldBatteryPcnt != batteryPcnt) {
                         // Power up radio after sleep
                         gw.sendBatteryLevel(batteryPcnt);
                         oldBatteryPcnt = batteryPcnt;
                       }
                         
                         
                      // Read digital motion value
                      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
                      
                      if (tripped != lastTripped ) {      
                        Serial.println(tripped);
                        gw.send(msgMot.set(tripped?"1":"0"));  // Send tripped value to gw 
                      }
                      delay(dht.getMinimumSamplingPeriod());
                    
                      float temperature = dht.getTemperature();
                      float humidity = dht.getHumidity();
                      
                      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);
                      }
                      
                      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);
                      }
                    
                       if (oldBatteryPcnt != batteryPcnt) {
                         // Power up radio after sleep
                         gw.sendBatteryLevel(batteryPcnt);
                         oldBatteryPcnt = batteryPcnt;
                       }
                      
                     
                      // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
                      gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
                    }
                    

                    So how do you connect the DHT / SR501 to the digital pin, and what's the sketch you're using ?

                    There's more than meets the eye

                    1 Reply Last reply
                    0
                    • carlierdC Offline
                      carlierdC Offline
                      carlierd
                      wrote on last edited by
                      #30

                      Hello,

                      You need to power the motion sensor all time as you want to detect any mouvement and not only every 2 minutes.

                      Caution, in your sketch, the battery level is sent at the beginning and at the end.

                      Did you tweak the motion sensor ?? Not tested yet but it seems that modification could (must ?) be done to reduce power consumption (LINK).

                      Why do you wake-up the arduino every 30 seconds ? For temperature, every 5 or 15 minutes is enough.

                      the cosmic gateT 1 Reply Last reply
                      0
                      • carlierdC Offline
                        carlierdC Offline
                        carlierd
                        wrote on last edited by
                        #31

                        @icebob: is you motion sensor often triggered ? I mean, is the sensor placed somewhere where there is a lot of mouvement ? I tried to do such sensor some months ago but my sensors was very often triggered on finally the time is sleep was small and my battery decreased very quickly !

                        1 Reply Last reply
                        0
                        • icebobI Offline
                          icebobI Offline
                          icebob
                          wrote on last edited by
                          #32

                          Currently I'm developing my boards, so there is no live device/sensor in my home. But in the future I plan to make a custom controller, and it will turn on/off the PIR sensors on the nodes, depending on the house is armed or not. So if I'm at home, PIR sensor won't watching. (It's just a plan for the present)

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            Heizelmann
                            wrote on last edited by
                            #33

                            I am new in this forum so may be what I will tell here is posted already somewhere else.
                            Firstly I would measure the battery voltage at the end after sending some values to see the voltage after some stress. Often it is the case for a nearly empty battery that it shows a relaxed high voltage after a long sleep and the break down on some stress. I think it is better to measure the lower level.
                            Secondly for a motion sensor I would implement a wakeup on a pin change interrupt. As a stand-alone sensor this would be optimal for battery life time. In combination the other components you can use a large cycle time for getting temperature humidity and so on and for the motion sensor you get an intermediate interrupt on demand. If those event are too often for your desire, you can check it against time or count of last event and go back to sleep without sending.

                            1 Reply Last reply
                            0
                            • carlierdC carlierd

                              Hello,

                              You need to power the motion sensor all time as you want to detect any mouvement and not only every 2 minutes.

                              Caution, in your sketch, the battery level is sent at the beginning and at the end.

                              Did you tweak the motion sensor ?? Not tested yet but it seems that modification could (must ?) be done to reduce power consumption (LINK).

                              Why do you wake-up the arduino every 30 seconds ? For temperature, every 5 or 15 minutes is enough.

                              the cosmic gateT Offline
                              the cosmic gateT Offline
                              the cosmic gate
                              wrote on last edited by
                              #34

                              @carlierd said:

                              Hello,

                              You need to power the motion sensor all time as you want to detect any mouvement and not only every 2 minutes.

                              Caution, in your sketch, the battery level is sent at the beginning and at the end.

                              Did you tweak the motion sensor ?? Not tested yet but it seems that modification could (must ?) be done to reduce power consumption (LINK).

                              Why do you wake-up the arduino every 30 seconds ? For temperature, every 5 or 15 minutes is enough.

                              Sure i modded the motion sensor as shown in the hyperlink , modded it this way :
                              upload-91e4fc48-511f-46de-8512-a86c74023af3.JPG
                              I don't know why i wake-up this arduino every 30 seconds, the sketch was fabricated by combine 2 or 3 other sketches to this one ( with help from @AWI )
                              So if there are some tweaking thing to do, do not hesitate and change the sketch as you think it must be

                              @icebob what's the sketch you using /testing ?

                              There's more than meets the eye

                              AWIA 1 Reply Last reply
                              0
                              • the cosmic gateT the cosmic gate

                                @carlierd said:

                                Hello,

                                You need to power the motion sensor all time as you want to detect any mouvement and not only every 2 minutes.

                                Caution, in your sketch, the battery level is sent at the beginning and at the end.

                                Did you tweak the motion sensor ?? Not tested yet but it seems that modification could (must ?) be done to reduce power consumption (LINK).

                                Why do you wake-up the arduino every 30 seconds ? For temperature, every 5 or 15 minutes is enough.

                                Sure i modded the motion sensor as shown in the hyperlink , modded it this way :
                                upload-91e4fc48-511f-46de-8512-a86c74023af3.JPG
                                I don't know why i wake-up this arduino every 30 seconds, the sketch was fabricated by combine 2 or 3 other sketches to this one ( with help from @AWI )
                                So if there are some tweaking thing to do, do not hesitate and change the sketch as you think it must be

                                @icebob what's the sketch you using /testing ?

                                AWIA Offline
                                AWIA Offline
                                AWI
                                Hero Member
                                wrote on last edited by mfalkvidd
                                #35

                                @the-cosmic-gate No specific reason to have a 30 second interval. You can just change the SLEEP_TIME to whatever eg. 5 minutes == 300000UL. The pin change interrupt is present in the code..

                                gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
                                
                                1 Reply Last reply
                                0
                                • the cosmic gateT Offline
                                  the cosmic gateT Offline
                                  the cosmic gate
                                  wrote on last edited by
                                  #36

                                  @icebob could you share us you're code ?

                                  There's more than meets the eye

                                  1 Reply Last reply
                                  0
                                  • icebobI Offline
                                    icebobI Offline
                                    icebob
                                    wrote on last edited by
                                    #37

                                    @the-cosmic-gate sorry, I'm working a big complex sketch, I can't share my code currently.

                                    the cosmic gateT 1 Reply Last reply
                                    0
                                    • icebobI icebob

                                      @the-cosmic-gate sorry, I'm working a big complex sketch, I can't share my code currently.

                                      the cosmic gateT Offline
                                      the cosmic gateT Offline
                                      the cosmic gate
                                      wrote on last edited by
                                      #38

                                      @icebob said:

                                      @the-cosmic-gate sorry, I'm working a big complex sketch, I can't share my code currently.

                                      Big and complex sounds interesting :)
                                      Could you maybe share us a sneak peak ;-)

                                      There's more than meets the eye

                                      1 Reply Last reply
                                      0
                                      • icebobI Offline
                                        icebobI Offline
                                        icebob
                                        wrote on last edited by
                                        #39

                                        @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.

                                        D 1 Reply Last reply
                                        0
                                        • carlierdC Offline
                                          carlierdC Offline
                                          carlierd
                                          wrote on last edited by
                                          #40

                                          @the-cosmic-gate Did you solved your power consumption issue ?

                                          the cosmic gateT 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular