กลับไปหน้ารวมไฟล์
low-power-library-for-arduino-c33-6a7c6a-en.md

Micro-Ampere Engineering: Low Power CPU Sleep

Running an Arduino on a 9V battery normally kills the battery in 48 hours because the 16MHz processor is literally running at a million miles an hour even when it does absolutely nothing. The Low Power Library for Arduino C33 forces the programmer to abandon the delay() function entirely, replacing it with massive, complex ATmega register-level "Sleep States" that plummet electrical consumption down to fractions of a Micro-Amp!

invisible_mess_glasses_relay_schema_1772681179521.png

The Sleep Routine (Avr/Sleep.h & LowPower.h)

To create a battery-powered device that lasts for 2 years on two AA batteries, you must plunge the processor into SLEEP_MODE_PWR_DOWN.

  1. The Architecture Trap: When you put an Arduino to "Sleep," it literally dies. It stops executing code entirely!
  2. Standard millis() timers will freeze because the timer hardware is shut down to save power!
  3. The LowPower Execution:
#include <LowPower.h>

void loop() {
  readSensorAndSaveToSDCard();
  // Violently shut down the entire CPU for exactly 8 Seconds!
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
  // Code resumes EXACTLY here 8 seconds later!
}
  1. By shutting down the Analog-to-Digital Converter (ADC_OFF) and the Brown-Out Detector (BOD_OFF), the Arduino drops from 50,000 uA to an unbelievable 8 uA!

Waking via Hardware Interrupts

Sometimes 8 seconds is too long. If someone presses a button or an alarm triggers, the CPU must wake up instantly from deep comma!

  • You must use attachInterrupt(0, wakeUpCore, LOW).
  • When the CPU is deeply asleep, it listens purely to Pin 2 physically.
  • If Pin 2 is grounded (Button pushed), the processor physically snaps awake in a nanosecond, runs the wakeUpCore interrupt, and resumes executing the main loop()!

Power Optimization Core Kit

  • Arduino Pro Mini or C33 (Do NOT use an Uno or Mega! They have massive, terrible 5V linear regulators that draw 20mA of power constantly, completely ruining the sleep function. A Pro Mini has almost no extra parts!).
  • LowPower.h Library (A brilliant simplification of the agonizingly complex native avr/sleep.h registers).
  • A generic Multi-meter capable of measuring single-digit MicroAmps (uA).
  • Coin Cell CR2032 or Dual AA Battery Pack.

ข้อมูล Frontmatter ดั้งเดิม

title: "Low Power library for Arduino C33"
description: "Micro-Ampere conservation! Obliterate the terrible default power consumption of standard Arduinos by manually commanding the silicon processor registers to violently go to sleep and shut down clock cycles."
category: "Tools & Equipment"
difficulty: "Advanced"