🛠 Fonctionnement sur batterie LiPo et sommeil profond

Arduino Nicla Vision · avance · Schéma : IMG-nicla-vision-avance-2-niclavision-sommeil-bas-courant.svg — Nicla Vision alimenté par une batterie LiPo sur ses pads JST, chronologie éveil court / sommeil profond entre deux appuis bouton

Objectives

Power the Nicla Vision autonomously via a LiPo battery and extend battery life by putting the STM32H747 into deep sleep between events, with wake-up triggered by a button.

Hardware

Full code

// Sommeil profond STM32H747 via Mbed, reveil par EXTI sur bouton D0
// > 
#include "mbed.h"

const pin_t BUTTON = D0;
volatile bool reveille = false;

void onReveil { reveille = true; }

void setup {
  pinMode(LED_BUILTIN, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(BUTTON), onReveil, FALLING);
}

void loop {
  // 1) tache breve : signal d vie
  digitalWrite(LED_BUILTIN, LOW); delay(50);
  digitalWrite(LED_BUILTIN, HIGH);

  // 2) extinction des peripheriques inutiles pendant le sommeil
  //    (couper camera, radio si initialises : les debrancher explicitement)

  // 3) sommeil profond : M7 et horloges principales a l arret
  reveille = false;
  while (!reveille) {
    sleep_deeplow;   // retourne au premier evenement EXTI
    delayMicroseconds(200); // anti-rebond grossier
  }
  delay(300);          // laisse le temps au rebond de retomber
}

Expected verification

Between two presses, the LED remains off and the measurable current drops significantly. Each press produces a 50 ms flash. The millis clock continues via the ticker, but the original RTC runs on LSI: the MCUboot is compiled with lse_available=false and re-clocks the RTC from the external LSE to the LSI on every hard reset — the calendar is therefore lost upon reflashing, which must be taken into account for log timestamping.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials