Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Giovanni Carrera
Published © GPL3+

ArduAmmeter

A simple circuit for measuring electrical current with Arduino.

IntermediateFull instructions provided5 hours5,677
ArduAmmeter

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

Figure 1 - Arduino Ammeter schematic.

Code

ArduAmmeter.ino

Arduino
The example program is very simple, the values used are relative to my system. To calibrate the Rp1 trimmer, just run the program and turn the trimmer to read zero on the serial monitor with zero input current. If it is not possible to zero the trimmer, it is necessary to slightly modify the Nsh constant to be subtracted from the measurement.
The constant mVtomA is derived from experimental measurements using a good precision ammeter, a power supply and some resistive loads such as car bulbs or wire resistors of adequate power.
/* program ArduAmmeter.ino Arduino current meter
 Giovanni Carrera, rev. 11/07/2019 */

float NtomV;
const float VREF = 1095;// in mV, this value can be read on VREF pin 
const int Nsh = 98;// shift value corresponding to about 100 mV

void setup() {
  Serial.begin(9600);
  analogReference(INTERNAL); // internal ADC reference input = 1100 mV
  NtomV = VREF/1023;// constant of conversion into millivolts
}

void loop() {
  int val = analogRead(A0)-Nsh;// read the current sensor and remove the shift
  float mvolt = NtomV*val;// convert to millivolt
  float mamp = mvolt/2.17;// convert to milliampere
  Serial.print("Vo = ");
  Serial.print(mvolt,1);
  Serial.print(" mV - Current = ");
  Serial.print(mamp,0);
  Serial.println(" mA");
  delay(1000);
}

Credits

Giovanni Carrera
14 projects • 50 followers
Electronic Engineer

Comments