Power Save

This library allows users to save power. The microcontroller operates based on a clock signal. It operates faster when the frequency of the clock is high. But this causes high consumption. For example, in the case of using dry-cell, the system turns off earlier. An efficient way to operate longer would be to stop the clock or make the clock slower. For example, when you measure the temperature every 1 minute, you stop the clock every time.

setPowerManagementMode

Description

Specifies power management mode.

Syntax

setPowerManagementMode(mode)
setPowerManagementMode(mode, lower, upper)

Parameters

mode:
  PM_NORMAL_MODE(Normal Mode)
  PM_STOP_MODE(Enter to stop mode when delay() function is called)
  PM_SNOOZE_MODE(Enter to snooze mode analogRead() function is called
lower: 0 to 1023 (low side of the AD conversion range, lower 2 bits are ignored.)
upper: 0~1023 (high side of the AD conversion range, lower 2 bits are ignored.)

Returns

None

getPowerManagementMode

Description

Checks the current power management mode.

Syntax

unsigned char getPowerManagementMode()

Parameters

None

Returns

PM_NORMAL_MODE, PM_STOP_MODE, PM_SNOOZE_MODE

setOperationClockMode

Description

Sets the operation clock of the CPU and peripherals

Syntax

setOperationClockMode(unsigned char mode)

Parameters

mode:
  CLK_HIGH_SPEED_MODE(high speed, 32MHz)
  CLK_LOW_SPEED_MODE(low speed, 32.768kHz)

Returns

None

Remark

When you set STOP/SNOOZE mode, do not select the CLK_LOW_SPEED_MODE. That operation is ignored.

getOperationClockMode

Description

Checks the current clock mode.

Syntax

unsigned char getOperationClockMode()

Parameters

None

Returns

CLK_HIGH_SPEED_MODE, CLK_LOW_SPEED_MODE


Example

This example uses SNOOZE mode. A2 is output when A2 becomes 0 to 100.


        #include <Arduino.h>
        void setup()
        {
          Serial.begin(9600);
          setPowerManagementMode(PM_SNOOZE_MODE, 0, 100);
        }
         
        void loop()
        {
          int value = analogRead(A2);
          Serial.println(value);
          Serial.flush();
          delay(100);
        }