The majority of my electronic projects are connected on an external power source but, I intend to make some of them work on battery or solar panel.
To achieve that goal, I need to estimate the power consumption, in mAh, over a certain period of time.
Let's take some exemples:
- Let's say that my circuit consume 50mA for 1 hour, then I can say that a 50mAh battery will support the circuit for 1 hour.
- Now, let's presume that my circuit triggers certain external devices and that the current consumption varies over time. For example: In the first half of the hour, my device consumes 50mA but for the second half, it consumes 100mA, then, after one hour, I could calculate that the circuit will need a 75mAh battery to support the load for one hour.
- But what if my circuit consumes 50mA for 15 minutes then 55mA for 6 minutes then 150 for 12 minutes and so on... the only way to correctly estimate the mAh needed for a 1 hour period is by capturing the power consumption every second or more precisely, many times per second!
This is exactly the goal of that project: Continuously estimating the current consumption, overtime, and store all the data on an micro SD card so I can loadthe data into Excel and, not only will I be able to see the final power consumption but also a graph showing the variation of the power over the hole period of time.
Video explanationI posted a video on YouTube so if you want to see the complete build, please visit the video.
Technical detailsMy version of a data logger based on the one made by "GreatScott"; This guy is hot and the video explanations that he makes are very detailed so, I decided to let you visit his video for the technical part and for the base code and use my video for the build and the modification that I made on the base code.
At the heart of this project resides the INA219
It is a I2C breakout board that is really easy to use but it has a small problem: the current returned, when there are no load, is in the negative range. So to hide this problem, I decided to add a condition to return 0 when this condition occurs
power_mw = (loadvoltage * current_mA);
if (power_mw < 0)
{
current_mA = 0;
loadvoltage = 0;
power_mw = 0;
}
I also added a push button to start & stop the recording so I control what to monitor. For that purpose, I added a function tu Debounce the pushbutton
I tried to make an "Easy to use" module and to make it more friendly so I prepared 2 ways to "Input the voltage".
One of the method is via a DC Power Supply Jack Socket Female Connector
The other method is via a Stereo Speaker Plate Terminal Strip Push Connector Block
Here are some 3D Rendered images of the inside
As shown in the next image, I split the front section in 2 sections: the left side are the inputs and the right side are the outputs section with the ground clip.
Once the data are imported into Excel, a deeper analysis can be made as you can see in the next image
My goal is reached now: I can monitor any electronic project and analyze the captured data to better understand the current consumption overtime and, using this data, I can start thinking about creating outdoors IoT devices powered by solar panels like this IoT Weather Station that I made: I will certainly revisit this project to estimate the current and, eventually, convert it to use solar panels.
Thanks
Comments