element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
DIY Test Instrumentation
  • Challenges & Projects
  • Project14
  • DIY Test Instrumentation
  • More
  • Cancel
DIY Test Instrumentation
Blog A gadget for power monitoring of SBCs and MCU boards
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join DIY Test Instrumentation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: embeddedguy
  • Date Created: 4 Jul 2021 11:14 AM Date Created
  • Views 1007 views
  • Likes 11 likes
  • Comments 1 comment
  • diytestinstrumentationch
Related
Recommended

A gadget for power monitoring of SBCs and MCU boards

embeddedguy
embeddedguy
4 Jul 2021
image

DIY Test Instrumentation        Submit an EntrySubmit an Entry

 

Monthly Themes   | Monthly Poll   |  Back to homepage image

 

Give Us Your Ideas on DIY Test Instrumentation Projects in the Comments Below!

 

This is my first blog for the DIY test and instrumentation challenges. I am going to build a tiny meter for measuring DC current, Voltage, Power, etc in the range used by small devices.

The measurement of current is always a bit challenging, as we have to measure them in a series circuit. The measurement is not possible usually without breaking a circuit, inserting some

wires for the measurement.

 

There are some direct methods used with creating a common ground between measured device and measuring device with the help of a register between them. Bur such meathods are

never so much reliable due to the use of common ground, which might make systems unstable.

 

The sensors could help to solve this challange. Sensors such as INA219 from Texas Instruments operate on an I2C bus configuration which makes it possible to measure live current.

 

In this project, the first part was to interface this sensor with MCU. I am using ESP32 as of now with Arduino IDE due to their ease of use and capability for remote monitoring over the

internet.

imageimage

 

The challenge I faced here was to power up the raspberry pi via GPIO using a USB to TTL converter. The RaspberryPi is not starting and also the measurements are not showing up. I will find a solution as I go.

image

Now, I have got the solution to power up the RaspberryPi via GPIO. The thing is that it is required to use both GPIO 2 & 4 to supply 5V power & GPIO 6 to supply ground.

 

image

The following image shows the Pi running sshed via Putty and updates, the graph is the plot of current cunsuption in mAmps by Pi, It reaches at max. around 900 mAmps only sometimes.

It remains around 500mAmps normally.

image

 

When the RaspberryPi is powered of with

sudo shutdown or poweroff

commands still there is some power required by the status LED and other internal functions. If we unplug the cable then the power comsumption will be near to zero, as from the following screenshoots.

 

image

image

 

There is still some time before this contest closes. I would love to add a small display that could show live the data for power monitoring. For now, I only have an SSD1306 LCD display to make it work.

One more idea is that the power monitoring data can be sent to the loud such as AWS IoT where data is manipulated effectively but that is too much for such a small device. Also, it does not fit the project

theme well.

One more interesting thing is that a PoE HaT for RaspberryPi(any board basically) might have current monitoring capability with LCD. It would be interesting to know which part of software/hardware is consuming more power.

 

image

 

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <Adafruit_INA219.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels


#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


Adafruit_INA219 ina219;


void setup(void) 
{
  Serial.begin(115200);
  while (!Serial) {
      // will pause Zero, Leonardo, etc until serial console opens
      delay(1);
  }
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.display();
  delay(2000); // Pause for 2 seconds
  display.clearDisplay();
  
  uint32_t currentFrequency;
    
  Serial.println("Hello!");
  
  // Initialize the INA219.
  // By default the initialization will use the largest range (32V, 2A).  However
  // you can call a setCalibration function to change this range (see comments).
  if (! ina219.begin()) {
    Serial.println("Failed to find INA219 chip");
    while (1) { delay(10); }
  }
  // To use a slightly lower 32V, 1A range (higher precision on amps):
  //ina219.setCalibration_32V_1A();
  // Or to use a lower 16V, 400mA range (higher precision on volts and amps):
  //ina219.setCalibration_16V_400mA();


  Serial.println("Measuring voltage and current with INA219 ...");
}


void loop(void) 
{
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;
  float power_mW = 0;


  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  power_mW = ina219.getPower_mW();
  loadvoltage = busvoltage + (shuntvoltage / 1000);
  
  //Serial.print("Bus Voltage:   "); Serial.print(busvoltage); Serial.println(" V");
  //Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
  //Serial.print("Load Voltage:  "); Serial.print(loadvoltage); Serial.println(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
  //Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  Serial.println("");


  delay(10);
  
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(5,5);
  display.print(current_mA);
  display.print(" mA");


  
//  display.setCursor(0,0);
//  display.print(power_mW);
//  display.print(" mWatt");
  
  display.display();
  delay(100);
  display.clearDisplay();
      
}

image

  • Sign in to reply

Top Comments

  • DAB
    DAB over 4 years ago +2
    Nice post. DAB
  • DAB
    DAB over 4 years ago

    Nice post.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube