Sensebender Micro + rfm69w consumption?



  • @tbowmo I know you were running sensebender micro on rfm69 adapter. What was your sleep consumption please? I am getting around 90 µA and I think it should be lower.

    May be others did some tests?



  • Not sure what happened but I sorted it out.
    Sleep mode - > 24µA, peak TX -> 24mA averaging around 12-15mA
    I think this is fine.


  • Admin

    @alexsh1

    I'm still using nrf24 radios in my setup.. Only used rfm69 for testing the Sensebender Gateway.. And never got around to check on power consumption while sleeping.


  • Hardware Contributor

    RFM69 in sleep mode needs 0.1uA. I have checked sleep mode a while ago, and was approx getting that. Tested with an uCurrent device.
    perhaps your measurement tool, or something consuming power on your node.



  • @scalz ok, but what about sensebender micro AND rfm69w?
    I'm using a true RMS meter. It's not Fluke, but I do not think it can be 10 times wrong



  • Moteinos arr drawing around 19 uA in a sleep mode (mainly overheads due to onboard VR)
    So I'm not too far from that


  • Hardware Contributor

    sensebender micro is using ultra low power flash and atsha. both <1uA in deepest sleep mode. 328p is approx 0.1-0.2uA. Radio is 0.1uA.
    I'm talking about the deepest sleep mode without bod, and no wdt of course. with wdt it adds something like 5uA if i remember.
    already checked those values on my side.
    moteinos should be the same as sensebender except that there is a ldo (approx 1uA min), i don't remember the flash ic though (could draw some uA depending on the ref).
    that's a simple calc without sensors, you can have others leakage depending on the application.



  • @scalz interesting info - thanks. I think by default I have optiboot on the sensebender micro, but not sure if BOD is on.


  • Hardware Contributor

    @alexsh1 i meant no bod during sleep mode is the lowest drain. But when wake up, it's better to have bod enabled (always better to have bod on for reliability, but it uses some power in sleep mode).
    I guess you already know this. No idea why you're getting higher drain. we don't know much about your hw setup, or perhaps the burden voltage of your measurement tool..



  • @scalz I have a standard sensebender micro with default sketch (modifying node_id and rfm69w as well as singing). rfm69w is on the adapter @tbowmo developed (rfm69w to nrf24l01+ socket). Nothing extraordinary.
    Not sure what sensebender micro default BODs are - I'll try to disable them today. From my experience, this is the only way to run on batteries long term.


  • Hardware Contributor

    @alexsh1
    weird.. what you could do for testing, is check power consumption by using sketch J from Gammon.
    And add lowpowerlab lib to put the radio and flash in sleep mode too.
    You should get approx 1uA drain or less

    Below the sketch J from Gammon, you can remove the led management..

    #include <avr/sleep.h>
    
    const byte LED = 9;
      
    void wake ()
    {
      // cancel sleep as a precaution
      sleep_disable();
      // precautionary while we do other stuff
      detachInterrupt (0);
    }  // end of wake
    
    void setup () 
      {
      digitalWrite (2, HIGH);  // enable pull-up
      }  // end of setup
    
    void loop () 
    {
     
      pinMode (LED, OUTPUT);
      digitalWrite (LED, HIGH);
      delay (50);
      digitalWrite (LED, LOW);
      delay (50);
      pinMode (LED, INPUT);
      
      // disable ADC
      ADCSRA = 0;  
      
      set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
      sleep_enable();
    
      // Do not interrupt before we go to sleep, or the
      // ISR will detach interrupts and we won't wake.
      noInterrupts ();
      
      // will be called when pin D2 goes low  
      attachInterrupt (0, wake, FALLING);
      EIFR = bit (INTF0);  // clear flag for interrupt 0
     
      // turn off brown-out enable in software
      // BODS must be set to one and BODSE must be set to zero within four clock cycles
      MCUCR = bit (BODS) | bit (BODSE);
      // The BODS bit is automatically cleared after three clock cycles
      MCUCR = bit (BODS); 
      
      // We are guaranteed that the sleep_cpu call will be done
      // as the processor executes the next instruction after
      // interrupts are turned on.
      interrupts ();  // one cycle
      sleep_cpu ();   // one cycle
    
      } // end of loop
    

    For reference : https://www.gammon.com.au/forum/?id=11497



  • @scalz With this sketch, I am still getting 19 uA. Not sure, but something is not sleeping.

    With other low power boards, I am getting 5-6uA.

    EDIT: I have tried it with nrf24l01+ and still get 24uA



  • This is my Sesnebender Micro 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 - Thomas Bowman Mørch
     * 
     * DESCRIPTION
     * Default sensor sketch for Sensebender Micro module
     * Act as a temperature / humidity sensor by default.
     *
     * If A0 is held low while powering on, it will enter testmode, which verifies all on-board peripherals
     *  
     * Battery voltage is as battery percentage (Internal message), and optionally as a sensor value (See defines below)
     *
     *
     * Version 1.3 - Thomas Bowman Mørch
     * Improved transmission logic, eliminating spurious transmissions (when temperatuere / humidity fluctuates 1 up and down between measurements) 
     * Added OTA boot mode, need to hold A1 low while applying power. (uses slightly more power as it's waiting for bootloader messages)
     * 
     * Version 1.4 - Thomas Bowman Mørch
     * 
     * Corrected division in the code deciding whether to transmit or not, that resulted in generating an integer. Now it's generating floats as expected.
     * Simplified detection for OTA bootloader, now detecting if MY_OTA_FIRMWARE_FEATURE is defined. If this is defined sensebender automaticly waits 300mS after each transmission
     * Moved Battery status messages, so they are transmitted together with normal sensor updates (but only every 60th minute)
     * 
     */
    
    // Enable debug prints to serial monitor
    #define MY_DISABLED_SERIAL
    //#define MY_DEBUG
    //#define MY_DEBUG_VERBOSE_SIGNING
    
    // Define a static node address, remove if you want auto address assignment
    #define MY_NODE_ID 5
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    #define MY_RADIO_RFM69
    //#define MY_RF69_IRQ_PIN 2
    //#define MY_RF69_IRQ_NUM 1
    
    #define MY_SIGNING_ATSHA204
    #define MY_SIGNING_REQUEST_SIGNATURES
    #define MY_SIGNING_ATSHA204_PIN 17
    
    // Enable to support OTA for this node (needs DualOptiBoot boot-loader to fully work)
    #define MY_OTA_FIRMWARE_FEATURE
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <Wire.h>
    #include <SI7021.h>
    #ifndef MY_OTA_FIRMWARE_FEATURE
    #include "drivers/SPIFlash/SPIFlash.cpp"
    #endif
    #include <EEPROM.h>  
    #include <sha204_lib_return_codes.h>
    #include <sha204_library.h>
    #include <RunningAverage.h>
    #include <avr/power.h>
    
    
    #define RELEASE "1.4"
    
    #define AVERAGES 2
    
    // Child sensor ID's
    #define CHILD_ID_TEMP  1
    #define CHILD_ID_HUM   2
    // Uncomment the line below, to transmit battery voltage as a normal sensor value
    #define BATT_SENSOR    3
    
    // How many milli seconds between each measurement
    #define MEASURE_INTERVAL 500000
    
    // How many milli seconds should we wait for OTA?
    #define OTA_WAIT_PERIOD 300
    
    // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller
    #define FORCE_TRANSMIT_INTERVAL 6 
    
    // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes.
    // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement
    
    // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with
    // TEMP_TRANSMIT_THRESHOLD for temperature threshold.
    #define HUMI_TRANSMIT_THRESHOLD 0.5
    #define TEMP_TRANSMIT_THRESHOLD 0.5
    
    // Pin definitions
    //#define TEST_PIN       A0
    #define LED_PIN        A2
    #define ATSHA204_PIN   17 // A3
    
    const int sha204Pin = ATSHA204_PIN;
    atsha204Class sha204(sha204Pin);
    
    SI7021 humiditySensor;
    SPIFlash flash(8, 0x1F65);
    
    // Sensor messages
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    #ifdef BATT_SENSOR
    MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE);
    #endif
    
    // Global settings
    int measureCount = 0;
    int sendBattery = 0;
    boolean isMetric = true;
    boolean highfreq = true;
    boolean transmission_occured = false;
    
    // Storage of old measurements
    float lastTemperature = -100;
    int lastHumidity = -100;
    long lastBattery = -100;
    
    RunningAverage raHum(AVERAGES);
    
    /****************************************************
     *
     * Setup code 
     *
     ****************************************************/
    void setup() {
      
      pinMode(LED_PIN, OUTPUT);
      digitalWrite(LED_PIN, LOW);
    
      Serial.begin(115200);
      Serial.print(F("Sensebender Micro FW "));
      Serial.print(RELEASE);
      Serial.flush();
    
      // First check if we should boot into test mode
    
      //pinMode(TEST_PIN,INPUT);
      //digitalWrite(TEST_PIN, HIGH); // Enable pullup
      //if (!digitalRead(TEST_PIN)) testMode();
    
      // Make sure that ATSHA204 is not floating
      pinMode(ATSHA204_PIN, INPUT);
      digitalWrite(ATSHA204_PIN, HIGH);
      
      //digitalWrite(TEST_PIN,LOW);
      
      digitalWrite(LED_PIN, HIGH); 
    
      humiditySensor.begin();
      delay (200); 
      digitalWrite(LED_PIN, LOW);
    
      Serial.flush();
      Serial.println(F(" - Online!"));
      
      isMetric = getControllerConfig().isMetric;
      Serial.print(F("isMetric: ")); Serial.println(isMetric);
      raHum.clear();
      sendTempHumidityMeasurements(false);
      sendBattLevel(false);
      
    #ifdef MY_OTA_FIRMWARE_FEATURE  
      Serial.println("OTA FW update enabled");
    #endif
    
    }
    
    void presentation()  {
      sendSketchInfo("Sensebender Micro", RELEASE);
    
      present(CHILD_ID_TEMP,S_TEMP);
      present(CHILD_ID_HUM,S_HUM);
        
    #ifdef BATT_SENSOR
      present(BATT_SENSOR, S_POWER);
    #endif
    }
    
    
    /***********************************************
     *
     *  Main loop function
     *
     ***********************************************/
    void loop() {
      
      measureCount ++;
      sendBattery ++;
      bool forceTransmit = false;
      transmission_occured = false;
    #ifndef MY_OTA_FIRMWARE_FEATURE
      if ((measureCount == 5) && highfreq) 
      {
        clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
        highfreq = false;
      } 
    #endif
      
      if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
        forceTransmit = true; 
        measureCount = 0;
      }
        
      sendTempHumidityMeasurements(forceTransmit);
    /*  if (sendBattery > 60) 
      {
         sendBattLevel(forceTransmit); // Not needed to send battery info that often
         sendBattery = 0;
      }*/
    #ifdef MY_OTA_FIRMWARE_FEATURE
      if (transmission_occured) {
          wait(OTA_WAIT_PERIOD);
      }
    #endif
    
      sleep(MEASURE_INTERVAL);  
    }
    
    
    /*********************************************
     *
     * Sends temperature and humidity from Si7021 sensor
     *
     * Parameters
     * - force : Forces transmission of a value (even if it's the same as previous measurement)
     *
     *********************************************/
    void sendTempHumidityMeasurements(bool force)
    {
      bool tx = force;
    
      si7021_env data = humiditySensor.getHumidityAndTemperature();
      
      raHum.addValue(data.humidityPercent);
      
      float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100.0);
      float diffHum = abs(lastHumidity - raHum.getAverage());
    
      Serial.print(F("TempDiff :"));Serial.println(diffTemp);
      Serial.print(F("HumDiff  :"));Serial.println(diffHum); 
    
      if (isnan(diffHum)) tx = true; 
      if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true;
      if (diffHum > HUMI_TRANSMIT_THRESHOLD) tx = true;
    
      if (tx) {
        measureCount = 0;
        float temperature = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0;
         
        int humidity = data.humidityPercent;
        Serial.print(F("T: "));Serial.println(temperature);
        Serial.print(F("H: "));Serial.println(humidity);
        
        send(msgTemp.set(temperature,1));
        send(msgHum.set(humidity));
        Serial.println(F("Sent to GW"));
        lastTemperature = temperature;
        lastHumidity = humidity;
        transmission_occured = true;
        if (sendBattery > 60) {
         sendBattLevel(true); // Not needed to send battery info that often
         sendBattery = 0;
        }
      }
    }
    
    /********************************************
     *
     * Sends battery information (battery percentage)
     *
     * Parameters
     * - force : Forces transmission of a value
     *
     *******************************************/
    void sendBattLevel(bool force)
    {
      if (force) lastBattery = -1;
      long vcc = readVcc();
      if (vcc != lastBattery) {
        lastBattery = vcc;
    
    #ifdef BATT_SENSOR
        float send_voltage = float(vcc)/1000.0f;
        send(msgBatt.set(send_voltage,2));
    #endif
    
        // Calculate percentage
    
        vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
        
        long percent = vcc / 13.0;
        sendBatteryLevel(percent);
        transmission_occured = true;
      }
    }
    
    /*******************************************
     *
     * Internal battery ADC measuring 
     *
     *******************************************/
    long readVcc() {
      // Read 1.1V reference against AVcc
      // set the reference to Vcc and the measurement to the internal 1.1V reference
      #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
        ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
        ADMUX = _BV(MUX5) | _BV(MUX0);
      #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
        ADcdMUX = _BV(MUX3) | _BV(MUX2);
      #else
        ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      #endif  
     
      delay(2); // Wait for Vref to settle
      ADCSRA |= _BV(ADSC); // Start conversion
      while (bit_is_set(ADCSRA,ADSC)); // measuring
     
      uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
      uint8_t high = ADCH; // unlocks both
     
      long result = (high<<8) | low;
     
      result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
      return result; // Vcc in millivolts
     
    }
    
    /****************************************************
     *
     * Verify all peripherals, and signal via the LED if any problems.
     *
     ****************************************************/
    /*
    void testMode()
    {
      uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
      uint8_t ret_code;
      byte tests = 0;
      
      digitalWrite(LED_PIN, HIGH); // Turn on LED.
      Serial.println(F(" - TestMode"));
      Serial.println(F("Testing peripherals!"));
      Serial.flush();
      Serial.print(F("-> SI7021 : ")); 
      Serial.flush();
      
      if (humiditySensor.begin()) 
      {
        Serial.println(F("ok!"));
        tests ++;
      }
      else
      {
        Serial.println(F("failed!"));
      }
      Serial.flush();
    
      Serial.print(F("-> Flash : "));
      Serial.flush();
      if (flash.initialize())
      {
        Serial.println(F("ok!"));
        tests ++;
      }
      else
      {
        Serial.println(F("failed!"));
      }
      Serial.flush();
    
      
      Serial.print(F("-> SHA204 : "));
      ret_code = sha204.sha204c_wakeup(rx_buffer);
      Serial.flush();
      if (ret_code != SHA204_SUCCESS)
      {
        Serial.print(F("Failed to wake device. Response: ")); Serial.println(ret_code, HEX);
      }
      Serial.flush();
      if (ret_code == SHA204_SUCCESS)
      {
        ret_code = sha204.getSerialNumber(rx_buffer);
        if (ret_code != SHA204_SUCCESS)
        {
          Serial.print(F("Failed to obtain device serial number. Response: ")); Serial.println(ret_code, HEX);
        }
        else
        {
          Serial.print(F("Ok (serial : "));
          for (int i=0; i<9; i++)
          {
            if (rx_buffer[i] < 0x10)
            {
              Serial.print('0'); // Because Serial.print does not 0-pad HEX
            }
            Serial.print(rx_buffer[i], HEX);
          }
          Serial.println(")");
          tests ++;
        }
    
      }
      Serial.flush();
    
      Serial.println(F("Test finished"));
      
      if (tests == 3) 
      {
        Serial.println(F("Selftest ok!"));
        while (1) // Blink OK pattern!
        {
          digitalWrite(LED_PIN, HIGH);
          delay(200);
          digitalWrite(LED_PIN, LOW);
          delay(200);
        }
      }
      else 
      {
        Serial.println(F("----> Selftest failed!"));
        while (1) // Blink FAILED pattern! Rappidly blinking..
        {
        }
      }  
    }
    
    */
    
    
    


  • OK, I have just found out that others are reporting 27uA overheads so my 24uA is conservative. Another Sensebender +nrf24l01+ I have is about 24.5uA during sleeping


Log in to reply
 

Suggested Topics

  • 87
  • 5
  • 1
  • 5
  • 7
  • 7

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts