Power Management HAT
| Primary Attribute | |||||
|---|---|---|---|---|---|
| Category: Raspberry Pi | |||||
| {{{userDefinedInfo}}}: | {{{userdefinedvalue}}} | ||||
| Brand: Waveshare | |||||
| Website | |||||
|---|---|---|---|---|---|
| International: Waveshare website | |||||
| Chinese: 微雪电子 | |||||
| Onboard Interfaces | |||||
|---|---|---|---|---|---|
| Related Products | |
|---|---|
Introduction
The Power Management HAT is a smart power bank designed for Raspberry Pi. With the embedded Arduino MCU and RTC, the HAT features auto power management function which allows the Pi to work more power-efficient and safely.
Features
- Standard Raspberry Pi 40PIN GPIO extension header, supports Raspberry Pi series boards.
- Onboard ATmega328P MCU, supports Arduino programming.
- Onboard PCF8523 RTC chip, provides precise RTC information.
- Onboard CP2102 UART converter, for UART communication or ATmega328P programming.
- User-defined button, can be used for Raspberry Pi start-up, safe shutdown, or other customized functions.
- Protection circuits such as power supply anti-reverse, counter-current proof, etc. ensure stable and safe operating.
- Voltage/current monitoring circuit, monitors the Raspberry Pi operating voltage and current in real-time.
- Comes with online development resources and manuals.
Specification
- Communication interface: UART, GPIO (custom protocol)
- Controller: ATmega328P-AU
- Communication interface: UART + GPIO
- Baud rate: default 115200bps (other baud rates can be programmed)
- Power supply mode: USB interface or PH2.0 interface
- USB power input: 5V
- PH2.0 power input: DC 7~28V (regulated power supply or lithium battery)
- Built-in circuit: power supply anti-reverse connection, counter-current proof, current detection, voltage detection
- Dimensions: 56.5mm x 65mm
- Mounting hole size: 3.0mm
Working principle
The ATmega328O connect to Raspberry Pi by 2 GPIO. These pins are defined by firmware.
- Raspberry Pi side
- Power on: GPIO21 is set to High after powering on
- Power off: Keep detecting the status of GPIO20, if it is high, Raspberry Pi shutdown and set GPIO21 to Low after shutdown.
- Arduino (ATmega328P) side
- Power on: Set PC3 to Low and power on Raspberry Pi. If PD7 is detected as High, it means that Raspberry Pi boots successfully.
- Power off: Set PC3 to High, Raspberry Pi shutdown after detecting it. Keep detecting the status of PD7, if PD7 is Low, it means that Raspberry Pi has shut down and it can cut off the power of Raspberry Pi.
SAFETY CAUTIONS
- Li-ion and Li-po batteries are quite unstable. They may cause fire, personal injury, or property damage, if they're not properly recharged or used.
- Do not reversely connect the polarities when recharging or discharging the battery. Do not use inferior charger/charging panel to recharge the battery.
- Do not mix use old batteries with new ones, avoid using batteries of different brands.
- When buying Lithium battery, make sure the battery specification is compatible with the expansion board. Choose batteries from formal manufacturer, and ensure the batteries will work stably and safely by aging test.
- Lithium batteries have limited cycle life, they will also deteriorate as time goes by. Should be replaced with new ones when the batteries reaching their max cycle life, or working over two years, whichever comes first.
- Should be placed carefully and properly, keep it away from inflammables and explosives articles, away from children, avoid any safety accident caused by careless storage.
Preparation
The Software is divided into two parts. You need to first configure the Raspberry Pi. Then download the control codes (firmware) to the Power Management HAT by Arduino IDE. The different examples feature different function.
Software setup (Pi)
Shutdown Protocol Configuration
Open the terminal of Raspberry Pi and set the system-shutdown script.
- Download the shell script
wget https://files.waveshare.com/upload/4/44/Power-Management-HAT.zip unzip Power-Management-HAT.zip cd Power-Management-HAT
- Set the permission of the script.
sudo chmod a+x Power-Management-HAT-Setup.sh
Power-Management-HAT-manual-2.png
- Run the script.
sudo ./Power-Management-HAT-Setup.sh
The result is shown below, when prompted "Would you like to reboot now? y/n", enter "y" to reboot the Raspberry Pi (you must reboot the Raspberry Pi for the operation to be effective if the Raspberry Pi is not rebooted, you must manually reboot the Raspberry Pi before it takes effect).
Power-Management-HAT-manual-3.png
Note: Attention must be paid to check whether there is an error reported after the execution of the above operation, there is an error reported according to the prompts to correct before continuing.
Software setup (PC)
- Install Arduino IDE: Please install Arduino IDE to your Windows PC and remember the installation path.
- Install Power Management HAT package.
- The package can be downloaded from the Gihub download address, or you can also download it from the Waveshare website.
After downloading, copy the downloaded Power Management HAT folder (which also contains a subfolder Power Management HAT) to the hardware folder under the Arduino installation path. Copy it to the hardware folder under the Arduino installation path, as shown in the figure below, and then you can use the Arduino IDE to develop Power Management HAT.
Power-Management-HAT-manual-4.png
- Setup Arduino IDE
- Restart Arduino IDE.
- Connect the USB interface of Power Management HAT to PC.
- Select the correct port.
- Power-Management-HAT-manual-5.png
- Select Power Management HAT device.
- Power-Management-HAT-manual-6.png
- Finally, examples (firmware) can be found from File -> Examples -> PowerManagementHAT.
- Power-Management-HAT-manual-7.png
Power Supply Preparation
- Plug Power Management HAT into the Raspberry Pi pins.
- The Power Management HAT will supply power to the Raspberry Pi and the Raspberry Pi will not need to be powered again.
- The Power Management HAT is powered by one of the following methods, and if both are powered, USB power is automatically selected.
- Power Management HAT is powered by USB.
- The Power Management HAT is powered by the matching Li-ion battery pack or by an optional DC power supply (optional DC power supply voltage range is 7V-28V).
Examples
Several examples are provided, you need to download them to the Power Management HAT to feature the differnt contorl function.
ButtonBoot
- How to set up
- Connect the USB port of the PM HAT to the computer.
- Open Arduino IDE software (PM HAT environment should be configured before).
- Open the ButtonBoot demo, compile, and download it.
- Turn DEBUG switch to the other end.
- Configurable parameters are shown below:
- Firmware function
- If the Raspberry Pi is powered off:
- Press the power button and the Raspberry Pi will power on.
- If the Raspberry Pi is powered on:
- Press and hold the power button for more than 2 seconds, but for less than 8 seconds, the Raspberry Pi will be software shut down first, and the software shutdown will cut off the Raspberry Pi's power.
- Press and hold the power button for more than 8 seconds, the Raspberry Pi will be powered off directly.
MeasureCurrent
- How to set up
- Connect the USB port of the PM HAT to the computer.
- Open Arduino IDE software (PM HAT environment should be configured before).
- Open the MeasureCurrent demo, compile, and download it.
- Turn DEBUG switch to the other end.
- Configurable parameters are shown below:
- Firmware function
- If the Raspberry Pi is turned off: Press the power button and the Raspberry Pi will power on.
- If the Raspberry Pi has been powered on:
- Press and hold the power button for more than 2 seconds, but for less than 8 seconds, the Raspberry Pi will first software shutdown, software shutdown will cut off the Raspberry Pi's power.
- Press and hold the power button for more than 8 seconds, and the Raspberry Pi will directly cut off the Raspberry Pi power.
- Open the serial terminal, and you can view the Raspberry Pi power on and off state of the operating current.
- If you plug the jumper cap into A, open the serial monitor of the IDE to check the current situation.
- If you plug the jumper cap into B, use the minicom plug-in on the Raspberry Pi to check the current situation.
MeasureVoltage_ShutdownInLowVoltage
- How to set up
- Connect the USB port of the PM HAT to the computer.
- Open Arduino IDE software (PM HAT environment should be configured before).
- Open the MeasureVoltage_ShutdownInLowVoltage demo, compile, and download it.
- Turn DEBUG switch to the other end.
- Configurable parameters are shown below:
【Note】:
- When the voltage of batteries is less than the OFF_VOLTAGE, if you press the Power button in 30000ms (LOW_Voltage_TIME_IN_MS), Raspberry can keep working for 3600000ms (OVERRIDE_TIME_MS). During this time, once the voltage is less than 5.8V (FORCE_OFF_VOLTAGE_VOLT), Management HAT will cut off Raspberry Pi immediately; Once the voltage reaches On_VOLTAGE, the Raspberry Pi will be powered again.
- The voltage of a single lithium battery is around 3.0V~4.2V, the battery power can be roughly estimated by the lithium battery voltage, 4.2V lithium battery means it is full, and 3.0V lithium battery means the power is very low, the lithium battery works at 3.7V most of the time; if the voltage of a single lithium battery is lower than 3.0V, the lithium battery may be permanently destroyed. If the Power Management HAT is powered by an external lithium battery, at least two lithium batteries (packs) need to be connected in series to provide a power supply of 5V or more, at this time, please set the corresponding voltage data according to the specific number of batteries in series, which can be referred to the data provided in the table below (if the Power Management HAT is powered by a matching Li-ion battery pack is used to power the Power Management HAT, then please select the parameters of 2S):
- Firmware Function
- If the Raspberry Pi is powered off:
- Press the power button, and the Raspberry Pi will power on.
- If the Raspberry Pi has been powered on:
- Press and hold the power button for more than 2 seconds, but for less than 8 seconds, the Raspberry Pi will be software shut down first, and the Raspberry Pi will be powered off after the software shutdown.
- Press and hold the power button for more than 8 seconds, and the Raspberry Pi will be powered off directly.
- If the voltage is lower than the set threshold, it will shut down automatically.
PowerOnInAPeriodTime
- How to set up
- Connect the USB port of the PM HAT to the computer.
- Open Arduino IDE software (PM HAT environment should be configured before).
- Open the PowerOnInAPeriodTime demo, compile, and download it.
- Turn DEBUG switch to the other end.
- Configurable parameters are shown below:
PowerOnPeriodicallyOnTimer
- How to set up
- Connect the USB port of the PM HAT to the computer.
- Open Arduino IDE software (PM HAT environment should be configured before).
- Open the PowerOnPeriodicallyOnTimer demo or PowerOnPeriodicallyOnAlarm demo, compile, and download it.
- Turn DEBUG switch to the other end.
- Parameters differences and configurable parameters are shown below:
- Firmware Function
- Raspberry PI will be turned on periodically for a specified period of time.
PowerOnPeriodicallyOnTimerInAPeriodTime
- How to set up
- Connect the USB port of the PM HAT to the computer.
- Open Arduino IDE software (PM HAT environment should be configured before).
- Open the PowerOnPeriodicallyOnTimerInAPeriodTime demo, compile, and download it.
- Turn DEBUG switch to the other end.
- Configurable parameters are shown below:
- Firmware Function
- Raspberry PI will be turned on periodically for a specified period of time.
Resources
Documents
Demo codes
Software
Datasheet
FAQ
{{{5}}}
{{{5}}}
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)