STM32L476RG for low power application

All about boards manufactured by ST
Post Reply
paulportohernan
Posts: 10
Joined: Sun Dec 20, 2020 4:32 pm
Answers: 1

STM32L476RG for low power application

Post by paulportohernan »

im trying to use my new nucleo-64 for a low power application (trying to make it run on batteries for months, having it in sleep mode most of the time waking it up periodically to read sensors and log data). but i need to clarify some doubts:
1) what would be the best voltage to drive it? 1.8 o 3.3v? im currently going for 3.3v.
2) how could i read with accuracy the voltage of the battery? is there an internal voltage reference like in the arduino pro mini that has an 1.1v reference?
3) how could i read the internal temperature sensor? where could i find examples for this chip and board?
thank you
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: STM32L476RG for low power application

Post by GonzoG »

1. the lower the voltage the lower current consumption. (STM32L476 datasheet pages from 124)

2 and 3. There is internal voltage reference (datasheet page 122) but not like Arduino. You cannot switch ADC reference voltage in program.
An example how to use internal voltage reference to measure ADC Vref and whow to read internal temperature is on wiki: https://github.com/stm32duino/wiki/wiki/API#analog

Code: Select all

#include "stm32yyxx_ll_adc.h"

/* Values available in datasheet */
#define CALX_TEMP 25
#if defined(STM32F1xx)
#define V25       1430
#define AVG_SLOPE 4300
#define VREFINT   1200
#elif defined(STM32F2xx)
#define V25       760
#define AVG_SLOPE 2500
#define VREFINT   1210
#endif

/* Analog read resolution */
#define LL_ADC_RESOLUTION LL_ADC_RESOLUTION_12B
#define ADC_RANGE 4096

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  analogReadResolution(12);
}

static int32_t readVref()
{
#ifdef __LL_ADC_CALC_VREFANALOG_VOLTAGE
  return (__LL_ADC_CALC_VREFANALOG_VOLTAGE(analogRead(AVREF), LL_ADC_RESOLUTION));
#else
  return (VREFINT * ADC_RANGE / analogRead(AVREF)); // ADC sample to mV
#endif
}

#ifdef ATEMP
static int32_t readTempSensor(int32_t VRef)
{
#ifdef __LL_ADC_CALC_TEMPERATURE
  return (__LL_ADC_CALC_TEMPERATURE(VRef, analogRead(ATEMP), LL_ADC_RESOLUTION));
#elif defined(__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS)
  return (__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(AVG_SLOPE, V25, CALX_TEMP, VRef, analogRead(ATEMP), LL_ADC_RESOLUTION));
#else
  return 0;
#endif
}
#endif

static int32_t readVoltage(int32_t VRef, uint32_t pin)
{
  return (__LL_ADC_CALC_DATA_TO_VOLTAGE(VRef, analogRead(pin), LL_ADC_RESOLUTION));
}

// the loop routine runs over and over again forever:
void loop() {
  // print out the value you read:
  Serial.print("VRef(mv)= ");
  int32_t VRef = readVref();
  Serial.print(VRef);

#ifdef ATEMP
  Serial.print("\tTemp(°C)= ");
  Serial.print(readTempSensor(VRef));
#endif
#ifdef AVBAT
  Serial.print("\tVbat(mv)= ");
  Serial.print(readVoltage(VRef, AVBAT));
#endif

  Serial.print("\tA0(mv)= ");
  Serial.println(readVoltage(VRef, A0));
  delay(200);
}

But Nucleo-64 boards have ST-link on them. You need to make sure you won't power it as it draws quite some current.
paulportohernan
Posts: 10
Joined: Sun Dec 20, 2020 4:32 pm
Answers: 1

Re: STM32L476RG for low power application

Post by paulportohernan »

thank you GonzoG i am now able to read the battery voltage with accuracy.

my next problem is decreasing the current drawn by the circuit.
currently, after i call to LowPower.deepSleep(60000*suenno_minutos);
the current lower to a 500uA. this seem too much current. how could i lower this?
currently i open the 0 ohm jumpers between the module and the stlink (nRST Rx Tx Swo), remove the 2 STlink black jumpers ( TCK/SWCLK , TMS/SWDIO ), remove the SB2 jumper to isolate the regulator on the board from the rest of the circuit. im using an external LDO regulator... what else could i do?
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”