Professional Documents
Culture Documents
Objective:
Circuit Diagram:
Connect the resistor of a known value with Analog pin (A0) of the Arduino
Board.
Connect the Arduino board with the computer.
Write the Arduino code to read the analog input and convert it to current.
Upload the code and display values on Arduino Serial Monitor
Code:
const int analogInputPin = A0; // Analog input pin connected to the shunt resistor
const float shuntResistance = 0.1; // Shunt resistor value in ohms (adjust based on your resistor)
void setup() {
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int sensorValue = analogRead(analogInputPin); // Read analog input value
float voltage = sensorValue * (5.0 / 1023.0); // Convert analog value to voltage
float current = voltage / shuntResistance; // Use Ohm's Law to calculate current
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.print(" V, Current: ");
Serial.print(current);
Serial.println(" A");
Conclusion:
In conclusion, an Arduino-based ammeter can be effectively implemented by connecting a shunt resistor
in series with the circuit, measuring the voltage drop across the resistor using an analog input pin on the
Arduino, and utilizing Ohm's Law to calculate the current. This straightforward approach provides a
basic ammeter functionality for hobbyist projects, educational purposes, or simple applications.
However, users should be mindful of potential inaccuracies and consider calibration against a known
current source for more precise measurements. The simplicity of this Arduino-based ammeter makes it
accessible for those with basic programming skills and a clear understanding of the electrical
components involved, offering a practical solution for current measurement in various
electronic projects.