Digispark Power Monitor

by 陳亮 in Circuits > Arduino

4535 Views, 32 Favorites, 0 Comments

Digispark Power Monitor

Digispark INA219 SSD1306 Power Monitor
vlcsnap-2025-12-02-22h33m29s210.png

This instructables show how to build a power monitor with only 3 components: Digispark dev board, INA219 current sensor and SSD1306 OLED breakout board.

Supplies

  1. Digispark Dev board
  2. INA219 Current Sensor Breakout board
  3. SSD1306 128x64 OLED breakout board
  4. Breadboard and some breadboard wires

What Is Power Monitor?

Power Monitor is useful to visualize the power usage of your circuit. Especially the portable gadgets powered by a battery, the power usage determine the battery life. A power monitor can help you locate the power usage of your circuit or program and then help you decide the battery capacity is required in your project.

Even minor modifications can significantly impact power consumption. For example, as shown in the cover video, adding a resistor can drastically reduce the power consumption of an LED. Without this intermediate resistor, a color-changing LED could consume over 100mA.

You may also want to measure power usage if:

  1. the dev board enter deep sleep
  2. the dev board connected to WiFi
  3. lower the clock speed from 240 MHz to 160 MHz
  4. use PWM control screen backlight
  5. power off the screen
  6. light sleep 5 seconds after every run routine in 0.2 seconds
  7. removed the on board LED
  8. replace with a more efficient low-dropout linear regulator
  9. replace a dev board without serial chip
  10. and anything you want to try...

A power monitor can help you check all of the above.

Software Preparation

Arduino IDE

Download and install Arduino IDE latest version if not yet:

https://www.arduino.cc/en/software

ATTinyCore

Follow installation step to add ATTinyCore support if not yet:

https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/Installation.md

Wire Connection

IMG_7136.jpg

Please follow the cover video to connect the wires. And please note the OLED breakout boards have different pin arrangement version. You should double check the VCC/VDD and GND pins connect correctly before turn on the power.

Here are the summary of breadboard connection:

Digispark INA219 SSD1306
========= ========= =======
5V -> Vcc, Vin+ -> VCC/VDD
GND -> Gnd -> GND
P0 -> Sda -> SDA
P2 -> Scl -> SCK/SCL

Compile & Upload

螢幕截圖 2025-12-03 下午8.33.29.png
螢幕截圖 2025-12-03 下午10.34.51.png

Please download the source code at GitHub:

https://github.com/moononournation/ATtinyPowerMeter.git

In Arduino IDE:

  1. Open ATtinyPowerMeter.ino
  2. Select Tools menu -> Board -> ATTinyCore -> ATtiny85 (Micronucleus / DigiSpark)
  3. Press Upload button for compile and upload
  4. Wait compile finish and show the "Please plug in the device" message
  5. Plug in the Digispark dev board to upload the program

How to Measure

vlcsnap-2025-12-03-22h43m21s067.png

If you followed the above wire connection, the monitoring power source is come from Digispark 5V (USB). You may replace Vin+ connection by other power source you want to measure but remember also connect the power source GND to this circuit GND. Then connect the load you want to measure to Vin- and GND.

You can see 4 metrics, 2 line charts and 1 area chart on the OLED display. The first line chart represent the voltage, the second line chart represent the current in mA and the area chart represent the power usage in mW. And also the mWh and time metrics help to count the accumulated power usage.

The program read values from the sensor continuously, so you can monitor the live power usage.

Time for Making!

Now you have this "power" tools, you can make your own power efficient portable gadgets now!

Optional: Micronucleus Firmware Fine Tune

You may notice that after turn on the power, it needs wait for few seconds before OLED start to display. It is because micronucleus designed the boot loader check and wait the USB communication for uploading new program a few seconds before running the program. The waiting time can be fine tuned in micronucleus bootloaderconfig.h:

#define FAST_EXIT_NO_USB_MS 120 // Values below 120 are ignored. Effective timeout is 300 + FAST_EXIT_NO_USB_MS.
#define AUTO_EXIT_MS 1000

But it requires recompile the firmware and apply to the dev board.

You can find more details for recompile at the GitHub source:

https://github.com/micronucleus/micronucleus

Attached my compiled hex file, you can apply it to your dev board by:

micronucleus /run upgrade.hex

Downloads