Itsy Bitsy low power mode.

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
troste
 
Posts: 4
Joined: Sat Feb 11, 2023 10:38 am

Itsy Bitsy low power mode.

Post by troste »

I got a itsy bitsy product number 4481 and SHT31 product number 2857

Which low power states does it support?

How do you enter this states?

I want to measure and log to a file in the flash each 15 minuttes.
Running on a battery I want to use as little energy as possible.

At the moment I am at 2.5 mA using delay in the main loop.

Code: Select all

#include <Arduino.h>
#include <Wire.h>
#include <SdFat.h>
#include <RTClib.h>
#include <Adafruit_SPIFlash.h>
#include <Adafruit_SHT31.h>
#include "flash_config.h"

Adafruit_SPIFlash flash(&flashTransport);
Adafruit_SHT31 sht31 = Adafruit_SHT31(); 
FatVolume fatfs;
RTC_Millis rtc;

#define FILE_NAME "Fre01.dat"
#define useSerial 0

uint8_t freId = 1;                                 // Id number;
unsigned long loopTime = 15*60*1000;  // Looptime in milliseconds
bool useTemp = true;

DateTime nowTime;
DateTime startTime;

void readWriteTempHumid() {
  uint8_t temp = 110;
  uint8_t humid = 120;

  if (useTemp)
  {
    if (! sht31.begin(0x44)) {   
#ifdef useSerial 
        Serial.println("Couldn't find SHT31");
#endif              
      while (1) delay(1);
    }  
    temp  = round(sht31.readTemperature());
    humid = round(sht31.readHumidity());
    sht31.reset();
  }
  

  
#ifdef useSerial    
   nowTime = rtc.now();
   char buf[] = "YYMMDD-hh:mm:ss";
   Serial.print("Time ");
   Serial.print(nowTime.toString(buf));
   Serial.print("  ");
   Serial.print("Temp *C = "); 
   Serial.print(temp); 
   Serial.print("  ");
   Serial.print("Humid. % = "); 
   Serial.println(humid);   
#endif
   
  File32 dataFile = fatfs.open(FILE_NAME, FILE_WRITE);
  dataFile.print(temp);
  dataFile.print(",");
  dataFile.println(humid);
  dataFile.close();
}

void initSerial() {  
#ifdef useSerial 
  Serial.begin(115200);             // Open serial communications.
  while (!Serial) {delay(10); }     // wait for serial port to connect. Needed for native USB port only
  Serial.println("Serial is running.");  
#endif
}

void initFlash() {    
  flash.begin();                    // Init external flash
  if ( !fatfs.begin(&flash) ) {     // Open file system on the flash
#ifdef useSerial 
         Serial.println("Error: filesystem is not existed. Please try SdFat_format example to make one.");
#endif
    while(1)
    {
      yield();
      delay(1);
    }
  }
#ifdef useSerial 
    Serial.println("Filesystem is running.");
#endif
}

void initClock() {
  startTime = DateTime(F(__DATE__), F(__TIME__));
  rtc.adjust(startTime);  
}

void initFile() {   
  char buf[] = "YYMMDD-hh:mm:ss";
  File32 dataFile = fatfs.open(FILE_NAME, FILE_WRITE);
  dataFile.print("Id  nummer : " );
  dataFile.println(freId);
  dataFile.print ("Start tid : "); 
  dataFile.println(startTime.toString(buf));
  dataFile.print ("Loop tid i minutter : "); 
  dataFile.println(loopTime/60000);
  dataFile.close();
}

void setup() {
  initSerial();
  initFlash();
  initClock();
  initFile();
}

void loop() {  
  readWriteTempHumid(); 
  delay(loopTime);
}


User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Itsy Bitsy low power mode.

Post by mikeysklar »

Checkout SystemOff() and WaitForEvent().

https://github.com/adafruit/Adafruit_nR ... ing.c#L102

There is also the low power timer breakout to consider TLP5110.

https://www.adafruit.com/product/3435

User avatar
troste
 
Posts: 4
Joined: Sat Feb 11, 2023 10:38 am

Re: Itsy Bitsy low power mode.

Post by troste »

Thank you.

I think WaitForEvent() is the way to go.
How do I set an event using the internal clock millis?

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Itsy Bitsy low power mode.

Post by mikeysklar »

Before getting into WaitForEvent(), try using delay() with your 15 minute (900 second) wait period.

Code: Select all

delay(900000);
The delay() code should also call WaitForEvent() on it’s own (put the processor into low power mode) so you don’t have to setup any callbacks for event triggers.

Some more examples and info for WaitForEvent() should you go that route.

viewtopic.php?t=128823&start=60
https://github.com/adafruit/Adafruit_nR ... itforevent

User avatar
troste
 
Posts: 4
Joined: Sat Feb 11, 2023 10:38 am

Re: Itsy Bitsy low power mode.

Post by troste »

Thanks

I want to measure and log to a file in the flash each 15 minuttes.
Running on a battery I want to use as little energy as possible.

At the moment I am at 2.5 mA using delay in the main loop.

So I am already using this low power state in my program above?
loopTime is 15*60*1000 = 900 000 millis.

User avatar
languer
 
Posts: 102
Joined: Fri May 17, 2013 2:02 pm

Re: Itsy Bitsy low power mode.

Post by languer »

You may want to check out "ArduinoLowPower.h". That library appears to work with SAMD, NRF52 architectures.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Itsy Bitsy low power mode.

Post by mikeysklar »

2.5mA is still really high.

What do you see as a baseline current draw with your hardware connected, but just running this:

Code: Select all

void setup() {
	suspendLoop();
}

void loop() {
}
If you really want to maximize battery consider the TLP5110. It is kind of a hack to cut power to everything, but it will get you down to 15nA.

User avatar
troste
 
Posts: 4
Joined: Sat Feb 11, 2023 10:38 am

Re: Itsy Bitsy low power mode.

Post by troste »

With just the itsy bitsy I am down to 0.90 mA.
Using this code.

void setup() {
suspendLoop();
}

void loop() {
}

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Itsy Bitsy low power mode.

Post by mikeysklar »

You can see how far you get with the ArduinoLowPower.h that @languer mentioned. I’ve not tried that one.

Otherwise the TLP5110 makes a lot more sense if the controller is going to draw near 1mA in idle mode.

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”