• Solar Panel and power bank

    Michael Wen07/10/2016 at 22:58 0 comments

    There is another problem to use USB battery (power bank) with Arduino and other dev-boards:

    Most USB battery will disable output while charging, which means you can not use Solar panel with USB battery and Arduino, when Solar panel is charging the USB battery, USB battery will cut off the power to Arduino (or other boards).

    I'v been thinking for a long time on how to solve this problem with a simple solution. Welcome to any suggestions.

  • Atmega88V BOD and sleep power consumption

    Michael Wen07/09/2016 at 14:29 0 comments

    After disable BOD in Arduino code, I got much better results:

    I used to need 1000 uF capacity, now 100 uF can power Atmega88V for few minutes.

  • Arduino Source Code

    Michael Wen07/07/2016 at 15:37 0 comments

    #include <avr/sleep.h>
    #include <avr/power.h>
    #include <avr/wdt.h>
    #include <EEPROM.h>
    
    // Utility macros
    #define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (before power-off)
    #define adc_enable()  (ADCSRA |=  (1<<ADEN)) // re-enable ADC
    
    #define BODS 7                     //BOD Sleep bit in MCUCR
    #define BODSE 2                    //BOD Sleep enable bit in MCUCR
    
    /** the current address in the EEPROM (i.e. which byte we're going to write to next) **/
    int addr = 0;
    
    #define LED_PIN (13)
    #define USB_PIN (9)
    
    volatile int f_wdt=1;
    
    
    
    /***************************************************
     *  Name:        ISR(WDT_vect)
     *
     *  Returns:     Nothing.
     *
     *  Parameters:  None.
     *
     *  Description: Watchdog Interrupt Service. This
     *               is executed when watchdog timed out.
     *
     ***************************************************/
    ISR(WDT_vect)
    {
      if(f_wdt == 0)
      {
        f_wdt=1;
      }
    //  else
    //  {
    //    Serial.println("WDT Overrun!!!");
    //  }
    
    }
    
    
    /***************************************************
     *  Name:        enterSleep
     *
     *  Returns:     Nothing.
     *
     *  Parameters:  None.
     *
     *  Description: Enters the arduino into sleep mode.
     *
     ***************************************************/
    void enterSleep(void)
    {
      //set_sleep_mode(SLEEP_MODE_PWR_SAVE);   /* EDIT: could also use SLEEP_MODE_PWR_DOWN for lowest power consumption. */
      set_sleep_mode(SLEEP_MODE_PWR_DOWN);
      sleep_enable();
      
      /* Now enter sleep mode. */
      sleep_mode();
      
      /* The program will continue from here after the WDT timeout*/
      sleep_disable(); /* First thing to do is disable sleep. */
      
      /* Re-enable the peripherals. */
      power_all_enable();
    }
    
    
    
    /***************************************************
     *  Name:        setup
     *
     *  Returns:     Nothing.
     *
     *  Parameters:  None.
     *
     *  Description: Setup for the serial comms and the
     *                Watch dog timeout. 
     *
     ***************************************************/
    void setup()
    {
      //digitalWrite(0, LOW);
      //digitalWrite(1, LOW);
      
      pinMode(LED_PIN, OUTPUT);
      digitalWrite(LED_PIN, LOW);
      
      adc_disable();
      
      // turn bod off
      // bod consume 22 uA
       MCUCR |= (1<<BODS) | (1<<BODSE);
       MCUCR &= ~(1<<BODSE);  // must be done right before sleep  
      
      int val = EEPROM.read(addr);
      if(val==255){
        EEPROM.write(addr, 0);
      }
      //Serial.begin(9600);
      //Serial.println("Initialising...");
      //delay(100); //Allow for serial print to complete.
    
      //pinMode(LED_PIN,OUTPUT);
    
      /*** Setup the WDT ***/
      
      /* Clear the reset flag. */
      MCUSR &= ~(1<<WDRF);
      
      /* In order to change WDE or the prescaler, we need to
       * set WDCE (This will allow updates for 4 clock cycles).
       */
      WDTCSR |= (1<<WDCE) | (1<<WDE);
    
      /* set new watchdog timeout prescaler value */
      WDTCSR = 1<<WDP0 | 1<<WDP3; /* 8.0 seconds */
      
      /* Enable the WD interrupt (note no reset). */
      WDTCSR |= _BV(WDIE);
      
      //Serial.println("Initialisation complete.");
      //delay(100); //Allow for serial print to complete.
    }
    
    
    /***************************************************
     *  Name:        enterSleep
     *
     *  Returns:     Nothing.
     *
     *  Parameters:  None.
     *
     *  Description: Main application loop.
     *
     ***************************************************/
    void loop()
    {
      if(f_wdt == 1)
      {
        int val = EEPROM.read(addr);
        //int ret;
        /* Toggle the LED */
        //ret = digitalRead(LED_PIN);
        //digitalWrite(LED_PIN, !ret);
    
    //    if(ret==HIGH){
    //      digitalWrite(USB_PIN, HIGH);
    //      delay(100);
    //      digitalWrite(USB_PIN, LOW);
    //    }
    
        val++;
    
        if(val>23){
          digitalWrite(USB_PIN, HIGH);
          delay(7000);
          digitalWrite(USB_PIN, LOW);
          EEPROM.write(addr, 0);
        }else{
          EEPROM.write(addr, val);
        }
    
        /* Don't forget to clear the flag. */
        f_wdt = 0;
    
        /* Re-enter sleep mode. */
        enterSleep();
      }
      else
      {
        /* Do nothing. */
      }
    }
    

  • NodeLP test

    Michael Wen07/06/2016 at 18:16 0 comments

    It took a whole month to test the NodeLP, and the results are promising, it more than doubled the run-time of my NodeUSB sensor!

    Use NodeLP without change anything for existing setup, I am able to run the WiFi sensor for 30 days using 1500 mAh power bank. All I need to do is plug the NodeLP between the battery and NodeUSB.

    6/1/2016, 3:07:57 PM [('s', u'bmp085si7021'), ('t', u'20.87'), ('h', u'53.86'), ('st', u'20.7'), ('ap', u'98353'), ('ip', u'192.168.1.126'), ('v', u'855')]
    6/6/2016, 11:58:42 PM [('s', u'bmp085si7021'), ('t', u'15.28'), ('h', u'85.11'), ('st', u'15.1'), ('ap', u'96570'), ('ip', u'192.168.1.126'), ('v', u'826')]
    6/10/2016, 8:52:29 AM [('s', u'bmp085si7021'), ('t', u'20.37'), ('h', u'43.79'), ('st', u'20.2'), ('ap', u'98447'), ('ip', u'192.168.1.127'), ('v', u'807')]
    6/18/2016, 7:13:20 PM [('s', u'bmp085si7021'), ('t', u'29.63'), ('h', u'32.67'), ('st', u'29.5'), ('ap', u'98791'), ('ip', u'192.168.1.127'), ('v', u'787')]
    6/20/2016, 11:20:08 PM [('s', u'bmp085si7021'), ('t', u'22.56'), ('h', u'50.35'), ('st', u'22.4'), ('ap', u'97580'), ('ip', u'192.168.1.127'), ('v', u'780')]
    6/22/2016, 9:22:40 AM [('s', u'bmp085si7021'), ('t', u'21.16'), ('h', u'53.41'), ('st', u'21'), ('ap', u'97821'), ('ip', u'192.168.1.127'), ('v', u'778')]
    6/25/2016, 6:09:47 PM [('s', u'bmp085si7021'), ('t', u'28.19'), ('h', u'35.39'), ('st', u'28.1'), ('ap', u'98550'), ('ip', u'192.168.1.127'), ('v', u'763')]
    6/27/2016, 2:34:54 PM [('s', u'bmp085si7021'), ('t', u'30.35'), ('h', u'44.40'), ('st', u'30.2'), ('ap', u'97707'), ('ip', u'192.168.1.127'), ('v', u'756')]
    6/28/2016, 6:17:36 PM [('s', u'bmp085si7021'), ('t', u'20.84'), ('h', u'65.99'), ('st', u'20.7'), ('ap', u'97972'), ('ip', u'192.168.1.127'), ('v', u'750')]
    6/29/2016, 4:00:05 PM [('s', u'bmp085si7021'), ('t', u'25.68'), ('h', u'38.99'), ('st', u'25.6'), ('ap', u'98067'), ('ip', u'192.168.1.127'), ('v', u'723')]
    6/30/2016, 5:25:04 PM [('s', u'bmp085si7021'), ('t', u'26.63'), ('h', u'34.33'), ('st', u'26.5'), ('ap', u'97978'), ('ip', u'192.168.1.127'), ('v', u'630')]