Editor Version ×
recommended

Pro Edition

free

Brand new interactions and interfaces

Smooth support for design sizes of over 3W

devices or 10W pads

More rigorous design constraints, more

standardized processes

For enterprises, more professional users

Std Edition

Easy to use and quick to get started

The process supports design scales of 300

devices or 1000 pads

Supports simple circuit simulation

For students, teachers, creators

Ongoing

STD Arduino based simple Watt-meter shield

Arduino based simple Watt-meter shield

Project tags

License

GPL 3.0

License: GPL 3.0

Mode:

Mode

Editors' pick

Editors' pick

  • 246
  • 0
  • 1
Update time: 2022-09-29 10:12:15
Creation time: 2022-09-29 10:11:56
Description

Description

Power monitoring is the basic need of any electronics or electric system nowadays, if you are a hobbies or working on any hardware related project. Now I have a portable wattmeter available which has functions to measure the DC voltage, Current and overall power.

Basically, it is a watt meter which is also comes in the lab bench power supplies. But we are just measuring not making any constant current/ voltage supply in this tutorial. That is the content to be done in another video/ article. This project is bought to you by JLCPCB- China based PCB manufacturer, has a 15 years’ experience in this industry.

 

Problem in measuring:

Arduino has two type of measuring capability voltage and time duration. Arduino can measure voltage using the 10bit ADC which can provide a great resolution up to 20volts. Somehow If the current can be converted into voltage form, it can be easily measurable. But to do this either we have to go old shunt-based voltage drop configuration or we can go with readymade hall effect current sensors. ACS712 comes with a precision current measurement of 100mv/A.

 

ACS712 and its types:

ACS712 comes in different current selection chip. It has 3 variants one for 5Amperes, second for 20Amps and next for 30Amperes. ACS712 comes with linear graph of respective voltage when there is increase in current. Here I am using 20 ampere version but 5ampere is recommended for better precision in small electronics readings. Code can be modified as per used variant.

 

Components required:

1) Arduino Nano

2) ACS712-20A

3) 4.7K and 10k resistor

4) OLED display

5) External SMPS power supply

6) Usb and connection wires

7) Custom PCB shield from JLCPCB

 

 

Circuit diagram:

Arduino ADC has a maximum range of 5volts, so if you want to measure voltage more than 5volts then a voltage divider network is required. Here I made a resistor network using 4.7k and 10k which gives the final range of 16.6volts. Just do a little bit calculations over the voltage divider network.

OLED is connected using I2C bus to the Arduino, ACS 712 also needs a constant voltage of 5volts. It is to be noted that the readings of voltage and current is based on the 5volt regulation, resistor tolerance and room temperature. The practical readings are always different from theory. When we have both current and voltage, power can be defined using the formula: voltage x current.

 

 

PCB shield:

Just plug your Arduino, OLED and ACS712 sensor. Solder some resistor and capacitors and we are ready to go with this wattmeter project. Values can be calibrated through the program. I made this shield in EasyEDA and then fabricated by JLCPCB in China’s best lab.

Or you can go with Arduino UNO based shield which provide a better interface, just plug you shield to Arduino and go for it. You can download all the required file from below.

Get your hands on the best manufacturer service form JLCPCB just in $2 for 5pcs of 2-layer boards. Sign-up now to JLCPCB and get free new user coupons of worth $54. Download the code, Gerber and schematics from here or you can also try your own design with modification by taking a reference from this.

 

 

Code:

All the basic libraries are used in this program and you can get them from manage library section under tools menu in Arduino IDE.

// Suitable with 12v battery, adaptor wattage, current and voltage monitoring.
// Resistor divider network need more upgradation if voltage is higher that 15.6
// Try 0x3D OLED address if screen did not work.
// Precision of the voltage depends on the tolerance of the resistors.

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

#define OLED_RESET -1
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Change the address to your's one
  display.clearDisplay();
}

void loop() {
  // put your main code here, to run repeatedly:
  int adc = analogRead(A0);
  int adc2 = analogRead(A1);
  float voltage = adc * 5 / 1023.0;
  float voltage2 = adc2 * 16.24/1023.0;        // resistor divider basics needed to be learn 
  float current = (voltage - 2.5) / 0.100; 

//0.100 for 20A, 0.185 for 30A, 0.66 for 5A
// follow this link:
//https://startingelectronics.org/articles/arduino/measuring-voltage-with-arduino/

  if (current < 0.16) {
    current = 0;
  }
  
   display.clearDisplay();
   display.setTextSize(1);
   display.setTextColor(WHITE);

   display.setCursor(10,10);
   display.print("Current : ");
   display.print(current);
   display.display();

   display.setCursor(10,20);
   display.print("Voltage : ");
   display.print(voltage2);
   display.display();

   display.setCursor(10,30);
   display.print("Power ");
   display.print(current*voltage);
   display.display();
   delay(1000);
}

Code explained:

First of all, we defined the basic initializing libraries, modes and reset pins of the display.

#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h>  #define OLED_RESET -1 Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

In the loop section, Arduino ADC read the voltage and current on A1 and A0 respectively.

int adc = analogRead(A0);
  int adc2 = analogRead(A1);

A voltage divider network is placed to measure the voltage and current readings are directly supplied from ACS sensor.

float voltage = adc * 5 / 1023.0;
  float voltage2 = adc2 * 16.24/1023.0; // resistor divider basics needed to be learn 
  float current = (voltage - 2.5) / 0.100; // follow this link: https://startingelectronics.org/articles/arduino/measuring-voltage-with-arduino/

  if (current < 0.16) {
    current = 0;

The readings are converted into voltages and then displayed on screen; this is the basic output code to SSD1306 type display.

display.clearDisplay();
   display.setTextSize(1);
   display.setTextColor(WHITE);

   display.setCursor(10,10);
   display.print("Current : ");
   display.print(current);
   display.display();

Working of the project:

I always recommend to use a separate power supply/ battery unit for the microcontroller circuit. This would not affect the readings anymore whatever is the input voltage. Also helps to keep the sensor calibrated.

The reads are much accurate as they are in my bench power supply unit. The code can be further modified for ACS712 which is explained in the comment lines inside it. Keep it simple using the PCB shield which also eliminates the breadboard, dry soldering and wires impedance.

Design Drawing

Design Drawing

schematic diagram
1 /
PCB
1 /
The preview image was not generated, please save it again in the editor.
Project Attachments

Project Attachments

Project Members

Project Members

Related Projects
Change a batch
Loading...

Comment

Add to album ×

Loading...

reminder ×

Do you need to add this project to the album?

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn