🛠 Fonctionner sur batterie LiPo et économiser l'énergie

Arduino MKR WiFi 1010 · avance · Schéma : IMG-mkr-wifi-1010-avance-3-mkrwifi-batterie-sommeil.svg — MKR WiFi 1010 alimentée par une batterie LiPo mono-élément via le connecteur JST, circuit de charge BQ24195L, LED ON éteinte sur batterie, cycle réveil par interruption externe vers le SAMD21 en sommeil.

Objectives

Power the MKR WiFi 1010 with a single-cell 3.7 V LiPo (JST connector, ≥1024 mAh recommended) using the onboard charger — the PMIC is the TI BQ24195L (enable with the flag -DUSE_BQ24195L_PMIC) — and build an energy-efficient cycle: measure, transmit a WiFi burst, and sleep (__WFI) until an external interrupt. Critical reminders: the ON LED stays off when running on battery (5 V rail) and VIN accepts only regulated 5–6 V, not the raw 6–12 V used by Arduino AVR boards.

Hardware

Complete code

#include <WiFiNINA.h>
const uint8_t PIN_WAKE = A1;   // pin 16, interruption externe possible

void setup {
  Serial.begin(115200);
  pinMode(PIN_WAKE, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(PIN_WAKE), reveil, FALLING);
}

void reveil { /* reveille le SAMD21 via __WFI */ }

void loop {
  // 1) Rafale : lecture capteur + envoi rapide
  Serial.println("mesure...");
  // ... lecture ADC, connexion WiFi, envoi, WiFi.end ...
  WiFi.disconnect;
  WiFi.end;                    // coupe la radio NINA, gros gain

  // 2) Sommeil : le CPU attend l'interruption (broche 0,1,4,5,6,7,8,9,
  //    16/A1, 17/A2 supportent les interruptions externes).
  noInterrupts;
  if (digitalRead(PIN_WAKE) == HIGH) {  // pas d'appui deja en cours
    __WFI;
  }
  interrupts;
  delay(100);
}

Expected verification

On battery, the board works even though the ON LED is off (normal behavior, official FAQ). The button wakes the board: the monitor (if USB is connected for testing) displays a new measurement. When unplugging USB, the measurable current drops after WiFi.end — the radio is the primary power consumer.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials