Arduino Giga R1 WiFi ACS712 Current Sensor
In this guide, we will learn how to use the ACS712 30A current sensor with the Arduino Giga R1 WiFi to find out how many amps a load really pulls. In detail, we will learn:
- What is inside the ACS712 module, and what each of its pins and terminals does.
- Why the sensor output must pass through a small voltage divider before it reaches a Giga analog pin.
- How to write a program for the Arduino Giga R1 WiFi that finds the zero point by itself and then prints the DC current of a 12V DC device, such as a DC motor, LED strip or lamp.
- How to change the program to read AC current as an RMS value.

Knowing the current is handy in many projects. A motor that pulls much more than normal is probably stuck. A charger that drops to almost zero amps is probably done. The Giga reads its analog pins with 12 bits, so it can follow these changes in fine steps.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of ACS712 Current Sensor
The ACS712 is a small chip from Allegro that measures current with the Hall effect. Inside the chip, the load current runs through a thick copper path. This current makes a magnetic field, and a Hall sensor right next to the path turns that field into a voltage. The copper path has only about 1.2 mΩ of resistance, so it hardly changes your circuit. And the load side is isolated from the sensor side (2.1 kV RMS), so the Giga never touches the load wires.
The chip comes in three current ranges. They look almost the same, so read the text on the chip before you start. This guide uses the 30A version.
| Version | Range | Sensitivity | Output at the highest current |
|---|---|---|---|
| ACS712ELCTR-05B | −5A to +5A | 185 mV per amp | about 3.43V |
| ACS712ELCTR-20A | −20A to +20A | 100 mV per amp | about 4.5V |
| ACS712ELCTR-30A | −30A to +30A | 66 mV per amp | about 4.48V |
Main data of the 30A module:
| Feature | ACS712 30A |
|---|---|
| Supply voltage | 5V (4.5V to 5.5V) |
| Output at 0A | about half of VCC, so about 2.5V |
| Output at +30A / −30A | about 4.48V / about 0.52V |
| Bandwidth | 80 kHz |
| Total output error | about ±1.5% at 25°C |
| Measures | DC and AC current |
How the output moves:
- With no current, OUT stays near 2.5V.
- Current that enters at IP+ and leaves at IP− pushes OUT up, by 66 mV for each amp.
- Current the other way pulls OUT down by the same 66 mV per amp.
- The output is ratiometric. It follows the real 5V supply. If USB gives only 4.9V, the zero point moves to about 2.45V. This is why the code measures the zero point at start instead of trusting 2.5V.
Be realistic about small loads. With the divider and the 12-bit ADC of the Giga, one ADC step is about 18 mA of current. But the module itself has noise, so seeing ±0.05A to ±0.1A with nothing connected is normal. This 30A version works best for loads of about 0.5A and up: motors, lamps, LED strips, heaters and chargers. For tiny currents, the 5A version is a better pick.
Pinout

Signal header (3 pins, goes to the Giga side):
- VCC pin: connect to 5V. The chip does not work well from 3.3V.
- GND pin: connect to GND (0V)
- OUT pin: analog voltage, about 2.5V at 0A. Connect it to a Giga analog pin through the voltage divider, never directly.
Screw terminal (2 terminals, goes to the load side):
- IP+ and IP−: put them in series with the load. Cut one supply wire of the load and fix the two cut ends into these terminals. On some modules these two terminals have no label.
There is also a red power LED. It lights up when VCC gets 5V.
Wiring Diagram
Every analog pin of the Arduino Giga R1 WiFi accepts 3.3V at most. The ACS712 must run from 5V, and its OUT pin can rise to about 4.5V. So we put two resistors between OUT and A0. They scale the signal down to two thirds, which turns 4.5V into a safe 3.0V.

This image is created using Fritzing. Click to enlarge image
Sensor side:
| From | To |
|---|---|
| ACS712 VCC | Arduino Giga R1 WiFi 5V |
| ACS712 GND | Arduino Giga R1 WiFi GND |
| ACS712 OUT | one end of the 10kΩ resistor |
| Other end of the 10kΩ resistor | Arduino Giga R1 WiFi A0, and one end of the 20kΩ resistor |
| Other end of the 20kΩ resistor | Arduino Giga R1 WiFi GND |
Load side:
| From | To |
|---|---|
| 12V adapter + (via DC power jack) | ACS712 IP+ |
| ACS712 IP− | DC device + |
| DC device − | 12V adapter − (via DC power jack) |
The isolation is already inside the chip, so there's no need to join the 12V ground with the Giga ground. This makes wiring or soldering easier. If you have no 20kΩ resistor, two 10kΩ resistors in series do the same job.
※ NOTE THAT:
Mains AC (110V/220V) can kill. Learn with a low-voltage DC load like the 12V DC device here first. The screw terminal and the copper side of the module carry the full load voltage, so never touch them, or any wire on them, while a mains circuit is live.
How To Program For ACS712 Current Sensor
No library is needed. The sketch uses only analogRead() and a little math.
- Set the analog pin and the numbers of your hardware:
- Switch the ADC to 12-bit mode in setup():
- Average many readings, then turn the result into the OUT voltage. Multiplying by 1.5 undoes the divider:
- Learn the zero point once at start, while no current flows:
- Turn the voltage into amps:
The formula is simple: current in amps = (Vout − Vzero) / 0.066. For example, if OUT sits at 2.556V and the zero point was 2.489V, then (2.556 − 2.489) / 0.066 ≈ 1.02A.
Avoid a global variable named error in your own sketches on this board. The Giga core is built on Mbed OS, which already has a function called error(), and the two names clash at compile time.
Arduino Giga R1 WiFi Code - ACS712 Current Sensor
What the sketch does:
- Waits one second for the sensor to settle.
- Averages 1000 readings with the load off and keeps this as the zero point.
- Every half second, averages 300 new readings and calculates the current.
- Prints the OUT voltage and the current. A minus sign means the current flows the other way.
Detailed Instructions
Follow these instructions step by step:
- New to this board? Set it up first with the Arduino Giga R1 WiFi getting started guide.
- Wire the components according to the provided diagram. Check the divider twice: A0 must sit between the 10kΩ and the 20kΩ resistor.
- Keep the 12V adapter unplugged, so the DC device is off.
- Plug the Giga R1 WiFi into your computer with the USB Type-C cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate Arduino Giga R1 WiFi board (e.g., Arduino Giga R1 WiFi) and COM port.
- Paste the code above into a new sketch.
- Press the Upload button, then open the Serial Monitor at 9600 baud.
- Wait until the zero point is printed. The load must stay off until then.
- Now plug in the 12V adapter. The DC device turns on, and the current shows up in the Serial Monitor.
The first three lines are the idle noise, a few hundredths of an amp around zero. With a 12V DC motor as the DC device, the 1.42A line is the short surge when the motor starts. After that, the motor settles near 1A. Hold the motor shaft lightly with your fingers and the current goes up, because a motor under load pulls more.
Do you see negative values while the DC device is on? Then the current enters at IP− instead of IP+. Swap the two wires on the screw terminal, or just ignore the sign.
Measuring AC Current
With AC, the current changes direction many times every second (50 or 60 times, depending on your country). So the OUT pin swings up and down around the zero point, and a simple average is close to 0A. What we need is the RMS value. This is the number that a multimeter shows for AC.
How the second sketch does it:
- For 200 ms, it reads A0 as fast as it can. 200 ms covers 10 full cycles at 50Hz and 12 at 60Hz.
- For each reading, it takes the distance from the zero point and squares it.
- At the end, it takes the square root of the average: RMS = sqrt(mean((V − Vzero)²)).
- It divides the result by 0.066 to get amps RMS.
The wiring on the Giga side does not change. The load side changes: the ACS712 sits in series with one wire of the AC device.
※ NOTE THAT:
Again: mains voltage is dangerous. Only work with mains if you have the skill to do it safely, and never touch the module's screw terminal while the circuit is plugged in.
Upload it the same way, with the AC device switched off at power-up. Then switch the device on. Here is what a small heater looked like:
With the device off, the RMS value is not exactly zero. Noise is always positive after squaring, so 0.05A to 0.1A at idle is normal. You can subtract this small value in code if it bothers you.