Problem with optimizing power consumption

  • Hi,

    i´ve made a sensor with the following hardware:

    Arduino Mini Pro 3,3v 8Mhz: removed regulator, removed power-LED
    NRF24L01+ Tranceiver
    Water-Flow Sensor

    The Flow-Sensor works, but now i want to power it with a battery:
    In measuring mode, the consumption is 19mA, when entering gw.sleep the power consumption of the Sensor reduces to 2mA.
    (also if I disconnect the Flow Sensor, and only the Transceiver is connected to the Arduino, it is still 2mA)
    Is there a way to optimize the power consumption more?
    I´ve heard about 120uA in sleep mode?
    Maybe the gw.sleep does not turn of the ADC, SPI, BOD, like the LowPower library?
    BTW, when i try to include the LowPower library, the arduino IDE says, it is not possible to compile LowPower for Arduino Pro Mini.

    Here is my code:

    // Sleep Mode Libraries laden
    #include <avr/sleep.h>
    #include <avr/power.h> 
    // MySensor Library hinzufügen
    #include <SPI.h>
    #include <MySensor.h> 
    #define CHILD_ID 0   // Id of the sensor child
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    int oldBatteryPcnt = 0;
    MySensor gw;
    MyMessage flowMsg(CHILD_ID,V_FLOW);
    MyMessage volumeMsg(CHILD_ID,V_VOLUME);
    volatile int NbTopsFan; //measuring the rising edges of the signal
    float Calc;                               
    int hallsensor = 3;    //The pin location of the sensor
    unsigned int flowMilliLitres;
    unsigned int lastFlowVal;
    long totalMilliLitres;
    long lastTotalVal;
    void rpm ()     //This is the function that the interupt calls 
      NbTopsFan++;  //This function measures the rising and falling edge of the hall effect sensors signal
    // The setup() method runs once, when the sketch starts
    void setup() //
      // Start Gateway Kommunikation
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Water Flow Sensor", "1.0");     
      // Register all sensors to gw (they will be created as child devices)  
      gw.present(CHILD_ID, S_WATER);
      pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
      Serial.begin(115200); //This is the setup function where the serial port is initialised,
      attachInterrupt(1, rpm, RISING); //and the interrupt is attached 1 = Digital Pin 3!
      // Batteriestatus
      // use the 1.1 V internal reference
      #if defined(__AVR_ATmega2560__)
    // the loop() method runs over and over again,
    // as long as the Arduino has power
    void loop ()    
      NbTopsFan = 0;   //Set NbTops to 0 ready for calculations
      sei();      //Enables interrupts
     if(flowMilliLitres == 0){
        delay (500);
      delay (1000);   //Wait 1 second
      cli();      //Disable interrupts
      Calc = (NbTopsFan / 7.5); //(Pulse frequency) / 7.5Q, = flow rate in L/min 
      Serial.print (Calc); //Prints the number calculated above
      Serial.print (" L/min\r\n"); //Prints "L/min" and returns a  new line
      int val=(int)Calc;
      // Divide the flow rate in litres/minute by 60 to determine how many litres have
      // passed through the sensor in this 1 second interval, then multiply by 1000 to
      // convert to millilitres.
      flowMilliLitres = (Calc / 60) * 1000;
      // Add the millilitres passed in this second to the cumulative total
      totalMilliLitres += flowMilliLitres;
      // Print the number of litres flowed in this second
      Serial.print("  Current Liquid Flowing: ");             // Output separator
      if(lastFlowVal != flowMilliLitres){
        lastFlowVal = flowMilliLitres;
      // Print the cumulative total of litres flowed since starting
      Serial.print("  Output Liquid Quantity: ");             // Output separator
      if(lastTotalVal != totalMilliLitres){
        lastTotalVal = totalMilliLitres;
        //Starting at the first byte on the eeprom.   
        //EEPROMWritelong(address, totalMilliLitres);
      // get the battery Voltage
       int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef DEBUG
       // 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.println(" V");
       Serial.print("Battery percent: ");
       Serial.println(" %");

    Would be nice to get some tipps for reducing the power consumption more, thanks!

  • Mod

    @vga did you try searching the forum first?
    There are numerous topics on power consumption in sleep mode, containing many tips!

  • yes, i used the search function, but there are no tips which are helpful for my problem.
    While sleep mode, using gw.sleep, the power consumption is still 2mA.

  • Hero Member

    @vga The gw.sleep() lets you go as low as 2uA so there must be something else in your circuit which still consumes.. Maybe (internal) pull-ups?

  • @AWI you are right. My fault, I checked again my wiring. the flow sensor is connected to vcc, so it consumes permanently. disconnected and restarted the arduino, the consumption in sleep is 0,1mA.

    so i tried to connect the flow sensor to a digital pin, set it to output mode and put it HIGH.
    When it go to sleep i set it to LOW.

    But I fail to see that it wake up again with interruptpin, when sensor change, but if it has no power, of course it can not change! 😏

    any idea how to make the best of it?
    timer interrupt is no alternative, cause of possible missing sensor activity.

  • Hero Member

    @vga What kind of flow sensor are you using? If you could use a passive type (i.e. reed contact) that would make the difference..

  • i am using this sensor:
    Do you know a "reed Sensor" for such a my sensor project?

  • Hero Member

    @vga The sensor you are referring to is working with "hall" effect. I can't find the internal schematics of the thing but I assume there are some active components to give you a nice square wave output. Another principle would be a magnet with reed (magnetic) contact which you can read with minimal current.
    You can find the " rest" current by measuring the power line of the sensor .

Log in to reply





Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.