Arduino Nano 33 BLE power consumption optimization

Greetings everyone!

I am working on building a sensor using Arduino Nano 33 BLE that will measure temperature using two thermistors and angle changes. The measured values will be transmitted over Bluetooth to a smartphone every minute. I have written the code for temperature and angle measurements, as well as remote data transfer. However, I need this sensor to operate for 10 to 21 days on a 3.7v 250mAH battery. To achieve this, I planned to use the Arduino low-power library.

Unfortunately, I have not been able to find a library that is compatible with this Arduino board, nor have I found an example of how to put the board into sleep mode and then measure values every minute. I am aware of the option to power the board directly from a 3.3v source by cutting the 3.3V pads on the back of the board, disabling the power indication diode and turning off the sensors/the I2C pull-up resistors.

I would appreciate any suggestions or solutions to this problem. The full code of the sketch is below:

`#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>
//These  values are in the datasheet
#define RT0 100000   // Ω
#define B 4600      //  K
//--------------------------------------
#define VCC 3.3    //Supply  voltage
#define R 100000  //R=100KΩ
//Variables`your text`
float RT, VR, ln, TX0, TX1,  T0, VRT1, VRT0;
unsigned long last_time;
float x, y, z,angleX,angleY;
// Define the BLE service and characteristic
BLEService greetingService("180C");
BLEStringCharacteristic greetingCharacteristic("2A56", BLERead | BLENotify, 30);
void setup() {
  // Initialize BLE
BLE.begin();

  // Set up the service and characteristic
greetingCharacteristic.setValue("Hi");
greetingService.addCharacteristic(greetingCharacteristic);
BLE.addService(greetingService);

  // Start advertising the service
BLE.advertise();
Serial.begin(9600);
  T0 = 25 + 273.15;  
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
Serial.print("Accelerometer sample rate = ");
Serial.print(IMU.accelerationSampleRate());
Serial.println("Hz");
   // Set the initial rotation angles to 0
  angleX = 0;
  angleY = 0;
}
void loop() {
if (millis()-60000>last_time){
  last_time=millis();
  VRT0 = analogRead(A0);              //Acquisition analog value of VRT
Serial.println(analogRead(A0));
  VRT0  = (3.30 / 1023.00) * VRT0;      //Conversion to voltage
  VR = VCC - VRT0;
  RT = VRT0 / (VR / R);               //Resistance of RT
  ln = log(RT / RT0);
  TX0 = (1 / ((ln / B) + (1 / T0))); //Temperature from thermistor
  TX0 =  TX0 - 273.15;                 //Conversion to Celsius
Serial.print("Temperature1:");
Serial.print("\ ");
Serial.print(TX0);
Serial.println("\ C");
  VRT1 = analogRead(A1);              //Acquisition analog value of VRT
Serial.println(analogRead(A1));
  VRT1  = (3.30 / 1023.00) * VRT1;      //Conversion to voltage
  VR = VCC - VRT1;
  RT = VRT1 / (VR / R);               //Resistance of RT
  ln = log(RT / RT0);
  TX1 = (1 / ((ln / B) + (1 / T0))); //Temperature from thermistor
  TX1 =  TX1 - 273.15;                 //Conversion to Celsius
Serial.print("Temperature2:");
Serial.print("\ ");
Serial.print(TX1);
Serial.println("\ C");
IMU.readAcceleration(x, y, z);
Serial.print("x=");
Serial.print(x);
Serial.print("y=");
Serial.print(y);
Serial.print("z=");
Serial.print(z);
    // Calculate the rotation angles using the atan2 function
    angleX = atan2(y, z) * 180 / PI;
    angleY = atan2(x, sqrt(y * y + z * z)) * 180 / PI;
    // Map the rotation angles to the range [0, 360]
    angleX = fmod(angleX + 360, 360);
    angleY = fmod(angleY + 360, 360);

  // Print the rotation angles
Serial.print("Rotation X: ");
Serial.print(angleX);
Serial.print(" degrees, Rotation Y: ");
Serial.print(angleY);
Serial.println(" degrees");

  BLEDevice central = BLE.central();
if (central) {
    // Send the value of x to the connected device
    String message = String(TX0)+"/"+String(TX1)+"/"+String(angleX)+"/"+String(angleY);
greetingCharacteristic.writeValue(message);
}
}
}`

Use the "LowPower.h" library:
#include <LowPower.h>

Put that at the beginning and then put the following command in the place of whatever command you used to delay the 1 minute interval:
LowPower.idle(SLEEP_60S, [whatever you want off]_OFF)

How it works:
The "LowPower" library allows your arduino to reduce its power consumption. Since you want a 1 minute interval, the "SLEEP_60S" puts your arduino to sleep for 60 seconds. You place whatever you want off in the "[whatever you want off]" to further reduce power consumption. Tell me if there you experience any problems with this solution.

The simplest option, that also saves the most energy, is to use a power timer. You can have the entire system powered up every 10 minutes, every hour, etc. then power down again.

Example: Overview | Adafruit TPL5110 Power Timer Breakout | Adafruit Learning System

I need this sensor to operate for 10 to 21 days on a 3.7v 250mAH battery.

Assuming 10 days, that means the average current draw has to be less than 250 mAh/(240 h) or less than about 1 mA. To take into account battery aging and seller exaggeration, reduce that average to 0.5 mA.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.