Using ACS723 with Arduino Giga

Hey, I am trying to use a SparkFun Current Sensor Breakout - ACS723 with an Arduino Giga. Because the Giga uses 3.3V logic, I am also using the SparkFun Logic Level Converter - Bi-Directional to convert the 5V signal from the current sensor to 3.3V for the Giga. I am using channel one on the converter connected to an annalog pin. The HV is connected to 5V pin, LV is connected to 3.3V pin, and GND is connected to ground.

Here is my code:

const int sensorPin = A0;
const float referenceVoltage = 3.3;
const int adcResolution = 4095;

// For ACS723 5A version
const float sensitivity = 0.4; // V/A

// Adjusted center voltage due to voltage divider (2.5V * 3.3/5 = 1.65V)
const float sensorZero = 1.65;

void setup() {
Serial.begin(115200);
analogReadResolution(12);
}

void loop() {
int raw = analogRead(sensorPin);
float voltage = (raw / (float)adcResolution) * referenceVoltage;
float current = (voltage - sensorZero) / sensitivity;

Serial.print(“Raw ADC: “); Serial.print(raw);
Serial.print(” | Voltage: “); Serial.print(voltage, 3); Serial.print(” V”);
Serial.print(" | Current: “); Serial.print(current, 3); Serial.println(” A");

delay(500);
}

With a correspontding serial output: Raw ADC: 3232 | Voltage: 2.605 V | Current: 2.386 A
When the there should be zero current.

Do you see any potential issues with this setup, and why I wouldn’t be getting zero amps when the current sesor has no load on it?

If you must scale the 0–5V output of the sensor down to 0–3.3V (safe for the Giga ADC), use a resistor voltage divider, not a digital level shifter.

Can you share a photo of the setup’s wiring?

As suggested above, you need a voltage divider. To convert from 5V to 3.3V, you can simply use 2 10k resistors. This will convert the 0-5V sensor output to 0-2.5V to the Arduino input. If you want, you can go a bit higher, but is generally recommended to not go full range, in order to protect the ADC from any over-voltage.
So, if you do not need to squeeze even the last drop of precision from your system, dividing by 2 the voltage is the simple and extra-safe path.

Arduino Giga uses STM32h747 MCU. I am not sure what resolution is used on Arduino, but the MCU is capable of 16bit resolution, giving you a theoretical 100uV/LSB(does not take into account errors). Below is a schematic of how you should implement this(excuse the crudity of it, did not have time to paint it):

Let me know if you need more details or have any other questions.

1 Like