Project tutorial

Make a power meter for 5v circuits using material from the Arduino Starter Kit

• 1,793 views
• 6 respects

## Components and supplies

 Arduino UNO & Genuino UNO
×1
 Jumper wires (generic)
×18
 Resistor 221 ohm
×1
 Adafruit Standard LCD - 16x2 White on Blue
×1
 Rotary potentiometer (generic)
×1

## Apps and online services

 Arduino IDE

### Overview

Have you ever needed a power meter for your Arduino or your Raspberry Pi? Here is a tutorial on making a multi function power meter for 5v circuits--using material found in the Arduino Starter Kit!

### Making the Power Meter

Gather the materials listed in the Components and Supplies section and assemble them together as shown in the "Main Project" picture in the Schematics section. If the "Main Project" picture is not clear in showing how to connect a LCD, use the LCD Setup picture to help.

### What the Setup is Supposed To Do

The LCD is used to project the calculated data.  The potentiometer is used as a knob to change between the five modes: Off, 5v Volt Meter, Analog Read/Write values,  Resistor calculator, and Conductivity. The three wires at the bottom are used as input, output, and GND wires.

### The Code Explained

Mode two is a 5v Volt Meter; using analog input you can calculate the voltage of the input.

``````float vv = analogRead(in) * (5.0 / 1023.0);
``````

Mode three is the Analog Read/Write values; by read the analog pin, you can calculate the power output in analog(Read) value (0-1023) or analogWrite value (0-255).

``````int aR = analogRead(in);// 0-1023
int aW = map(aR, 0, 1023, 0, 255);// 0-255
``````

Mode four is a resistor calculator that outputs in ohms; you can calculate the resistor using Ohms Law, Resistor = Volts / Current: Volts is the inputted voltage, and current is 20mA (because the Arduino's output current is about 20mA).

``````float vv = analogRead(in) * (5.0 / 1023.0);
float rr = vv / 20.0; // volt / current = resistor
``````

Mode five is a simple conductivity checker; anything bellow 5v would be counted as disconnect.

``````if(digitalRead(in) == HIGH)
lcd.print("Connect");
else
lcd.print("Disconnect");
``````

### Last Notes

This project can only be used on equipment that handles 5v. If not, the equipment could be burned and may not be usable after.

If the input/output wires aren't connected to anything, the wires would be calculating whatever is in the air so don't be surprised if random numbers are flashing on the LCD when the wires are not connected to anything.

Thank you!!

## Code

##### PowerMeterArduino
Main code
```#include <LiquidCrystal.h>

//Include^
//Init
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//Global Var
int pot = 0;
int index = 0;

const int out = A1;
const int in = A2;
const int mm = A0;
const int li = 6;
void setup() {//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lcd.begin(16, 2);
// put your setup code here, to run once:
pinMode(li, OUTPUT);
pinMode(out, OUTPUT);
pinMode(in, INPUT);
pinMode(mm, INPUT);
pinMode(8, OUTPUT);
off(8);
on(li);
lcd.print("   PowerMeter");
delay(1000);
lcd.clear();

}//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void loop() {//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// put your main code here, to run repeatedly:
index = map(pot, 0, 1023, 1, 5);

if (index == 1) {
off(li);
on(8);
}
if (index == 2) {
lcd.clear();
on(li);
off(8);
lcd.print(" DC Volt Meter");
while (true) {
float vv = analogRead(in) * (5.0 / 1023.0);
lcd.setCursor(0, 1);
lcd.print(vv);

index = map(pot, 0, 1023, 1, 5);
if (index != 2)
break;
}
}
if (index == 3) {
lcd.clear();
on(li);
off(8);
lcd.print(" Analog R/W Val");
while (true) {
int aW = map(aR, 0, 1023, 0, 255);
lcd.setCursor(0, 1);
lcd.print("R:" + String(aR) + "     W:" + String(aW)+"    ");

index = map(pot, 0, 1023, 1, 5);
if (index != 3)
break;
}
}
if (index == 4) {
lcd.clear();
on(li);
off(8);
lcd.print("      Ohms");
while (true) {
float vv = analogRead(in) * (5.0 / 1023.0);
float rr = vv / 20.0;
lcd.setCursor(0, 1);
lcd.print(rr);

index = map(pot, 0, 1023, 1, 5);
if (index != 4)
break;
}
}
if (index == 5) {
lcd.clear();
on(li);
off(8);
lcd.print("  Conductivity");
while (true) {
on(out);
lcd.setCursor(0, 1);
lcd.print("Connect         ");
else
lcd.print("Disconnect      ");

index = map(pot, 0, 1023, 1, 5);
if (index != 5)
break;
}
}
}//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//Functions
//New~~~~~~~~~~~~~~~~

//Back~~~~~~~~~~~~~~~~~~
void on(int pin) {
digitalWrite(pin, HIGH);
}
void off(int pin) {
digitalWrite(pin, LOW);
}
```

## Schematics

How to setup a 16x2 LCD

• 7 projects
• 60 followers

January 10, 2016

#### Members who respect this project

and 2 others

See similar projects
you might like

#### The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

• 3,530 views
• 14 respects

by MicroBob

• 30,818 views
• 101 respects

#### GPS Datalogger, Spatial Analysis, and Azure IoT Hub.

Project tutorial by Shawn Cruise

• 16,947 views
• 61 respects

#### Temperature sensor

Project tutorial by Grant

• 12,305 views
• 30 respects

#### Display Current Weather with Arduino and Python!

Project tutorial by Arduino “having11” Guy

• 6,710 views