Smart Amperage Meter With an Arduino and Java GUI

Smart Amp Meter With a Java GUI

Quick Overview:

I required the ability to monitor some amperage readings that not only exceeded my hand held mulit-meter but I also wanted an automated email alert.  In the following blog post I document how to accomplish this quickly, easily, and for less money than a new multi-meter.  Follow the below blog post to create an Arduino amp meter with a Java GUI.

Main GUI for Arduino Amp Meter in Java
Smart Meter GUI

What You Will Need:

All you really need are the following 3 things:

Arduino Code:

The Arduino code is fairly straightforward and there is lots of documentation regarding it in many forums.  I used other examples I was able to find and tweaked them to work for my application.  The largest change that I made was outputting to serial where I have a starting character and an ending character sent with the amperage data.  This allows me to see if I’m getting partial data sent from the Arduino and to discard it if necessary.  My use of this meter didn’t require any smoothing of the data so I didn’t alter anything in regards to that.

Start and finish characters to validate data from the Arduino.
Quick Data Validation

Visit GitHub to download the Arduino sketch.

Java Code Installation:

The Java code was a little bit more complicated as I used a few libraries to get the Arduino and the GUI talking and also some libraries for the automated emails.  The three main libraries that are required are the following:

You will need an IDE to modify the Java code in the Email.java class to update the email address and password you will want to utilize for the automated emails.  I used a Gmail account as there were more instructions but others can be used with further modifications.  Initially you will need to update lines 30, 173, and 190 for full email functionality.  You may also need to change settings in your Gmail account so that it will allow automatic emails.  There are lots of tutorials for this as well.

Update lines for email functionality.

Visit GitHub to download the 3 Java class files.

Program Walk-Through:

Here I will run through the basics of the software and what changes you can make along with basic operations.  Some of the more basic features of the GUI I will not go through as they are self-explanatory.  If you have questions though, leave me a message or an email and I will see what I can do to help.  I have also blanked out the email address I was using to test with.

Settings -> Email Settings

Updating email settings.Entering a new email

 

 

 

 

The “Email Settings” selection allows the user to change the recipient of the automated email alert.  If the email is not updated, the previous settings are held.

Settings -> Amp Settings

Changing amp settingsChanging upper amp limit

 

 

 

 

You can change the upper limit on the amperage that triggers the email alert by changing the “Amp Settings”.  The default is 5.0 amps and the bounds are between 0 and 20 due to the current sensor I was using.  If you are using a smaller or larger sensor you can change line 256 in “Meter.java” to account for this.

Settings -> Test Email

Sending a test emailSending a test email

 

 

You can choose to send a test email to make sure that your email account is setup correctly to handle the automated emails.  Choose the “Test Email” and enter the email address you would like to send a test email to and click “OK”.  The email should show up shortly after, usually within 30 seconds.  I used a Gmail account and had to tweak it to allow automated emails but there is lots of info on this with a quick search.

Test email example

Electrical Setup

The electrical setup for this system is pretty straight forward.  I wrote the Arduino side of the software to read in voltage from the current sensor into the A0 input.  If you choose to use a different analog input, you will need to update the Arduino sketch.

Amp meter wiring diagram

  • Arduino 5V to VCC on the SMAKN ACS712 sensor.  (red wire)
  • Arduino ground to GND on the SMAKN ACS712.  (green wire)
  • Arduino A0 to OUT on the SMAKN ACS712.  (black wire)

You now need to setup the device that will be generating a load.  You need to tap into one of the lines and splice it into the current sensor.  In the above diagram, I have the green load wire from the motor into the SMAKN sensor and then tied it back into the power supply.

Computer Fan Example:

I quickly wired up a computer fan that should pull about 0.25 amps to demonstrate the GUI.  Smoothing the signal input would help with resolution but if you’re going to measure amps this low you will want to select a current sensor with a smaller range.

Measuring fan amperage

GUI of fan amps

 

Good luck and be safe when dealing with electricity!  Let me know if you run into any problems or need help with anything.

Leave a Reply

Your email address will not be published. Required fields are marked *