Introduction: ATtinyPowerMeter

Picture of ATtinyPowerMeter

This instructables show how to make a simple power meter using 3 components: ATtiny85, INA219 and OLED module.

It can continuous measure the voltage(V), current(mA) and accumulated power usage(mWh). And also plot a simple graph to visualise the figures.

Step 1: Why?

Picture of Why?

While developing IoT device, power consumption does matter, especially if it cannot wired. A simple multi-meter is not enough for continuous monitoring the voltage and current at the same time. And also the accumulated power consumption (mWh) is very important for deciding how big a battery required in the IoT project.

So I use the components in hand to create this ATtinyPowerMeter.

Step 2: Preparation

Picture of Preparation

The power meter should not drain too much power itself, it is the major criteria to choose the components:

MCU

ATtiny85 only draw less than 1 mA while running at 1 MHz and 8 KB program flash can well fit a power meter program.

Power Monitor Module

INA219 module is the only module I can found that can monitor voltage and current at the same time (leave comment to me if you known other modules). It draws around 1 mA power.

Display Module

SSD1306 OLED display module drain few mA for display, it is the major power consumption. It should be better if using mono LCD display, but I only have this I2C display module in hand, so I will use it this time.

Battery

According to the data sheet, the above 3 components can operate at 3 V to 5.5 V, 2 rechargeable AAA battery is not enough, 3 AAA battery is better, 1 Lipo battery also ok. But in this project I am testing a new type battery, Lithium iron phosphate (LiFePO4 or LFP) battery. It is the same as AAA battery in size, but can provide 3.2 V 600 mAh. It should be good enough for most electronic project but I am still testing it.

Others

A 380 hole breadboard, some breadboard wire, a breadboard friendly battery holder, a 3 pins screw terminal block and a switch. And also a ISP for programming the ATtiny85.

Step 3: Download Source Code

Download source from GitHub:

https://github.com/moononournation/ATtinyPowerMete...

If you are not familiar GitHub, simple press "Clone or download" button and then "Download ZIP".

Step 4: Program ATtiny85

Step 5: Circuit Design

Picture of Circuit Design

Here is the connection summary:

Battery +ve -> switch -> ATtiny85 pin 8, INA219 module Vcc, OLED module Vcc
Battery -ve -> ATtiny85 pin 4, INA219 module GND, OLED module GND, screw terminal block middle pin
ATtiny85 pin 5 -> INA219 module SDA, OLED module SDA
ATtiny85 pin 7 -> INA219 module SCL, OLED module SCL
INA219 module Vin- -> screw terminal block left pin
INA219 module Vin+ -> screw terminal block right pin

Step 6: Testing

Picture of Testing
  1. Turn on the switch, you should see V and mA figure is 0.
  2. Connect testing power source +ve and -ve to screw terminal right pin and middle pin respectively, you should see V figure become the power source Voltage value and mA still 0
  3. Connect testing loading device +ve and -ve to screw terminal left pin and middle pin respectively, you should see mA figure become the loading device drawing current value

Step 7: Self Test

Picture of Self Test

You want to know how much power draining this power meter itself? In my measurement it draws around 3 - 6 mA, just for your reference.

Step 8: Happing Measuring!

Picture of Happing Measuring!

It is the time to design and testing your device power consumption now!

P.S. My source code configured measure maximum 16V and 800 mA, you may change the configuration at "INA219.h".

Comments

WannaDuino (author)2017-10-01

can i use the attiny 45??

陳亮 (author)WannaDuino2017-10-07

The program size is over 6 KB and cannot fit to Attiny45 4 KB flash size.

WannaDuino (author)陳亮2017-10-10

YOU ARE THE MAN. thanx dude..I will order a few.


www.wannaduino.com

WannaDuino (author)2017-10-01

what are the differenses about those 2 the at45 and the 85?

陳亮 (author)WannaDuino2017-10-07

the only different for ATtiny45 and ATtiny85 should be the size of flash, RAM and EEPROM

WannaDuino (author)陳亮2017-10-10

thank you so much, i learned again... something new today from you.

YOU ARE THE MAN. thanx dude..

www.wannaduino.com

TheThinker (author)2017-06-24

Also I want to point out that your attention to detail is excellent and results in a very clean design which makes your Instructable much more useable!

TheThinker (author)2017-06-24

This is great! Well done and thanks for sharing! I will use this to test my designs... probably with the addition of a V and A vs time data logger.

About This Instructable

4,426views

114favorites

License:

Bio: Do it yourself if you cannot buy one!
More by 陳亮:Circuit VisualizationNanoblock McDonald's FriesFlapping Paper Plane (Print Version)
Add instructable to: