Hello everyone,
I have a circuit that consist of Arduino Uno, 2x ACS712 current sensor modules, ADS1115 ADC module and two loads. Each load is connected to one of the current sensors and each current sensor is connected to the ADC1115 ADC then to Arduino. Code is working and both channels read approx 2.5v which indicates zero current. below are simple schematic and arduino code( Adafruit lib.). I have two issues:
1-whenever I switch on one load, both current sensor will change the output voltage. So zero current sensor will also change value and follow the other sensor with the load. this is the main prob.
2- volt reading will always indicate -ve current doesn't matter if i reverse wire on the sensor connectors.
Note that I completely removed the ADS1115 and checked output voltage of the two sensors manually with multimeter and still getting the same.
Thanks alot for your help.
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
//Adafruit_ADS1015 ads; /* Use thi for the 12-bit version */
void setup(void)
{
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
// ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
ads.begin();
delay(500);
}
void loop(void)
{
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
Serial.print("AIN0: "); Serial.println(adc0);
// Serial.print("AIN1: "); Serial.println(adc1);
// Serial.print("AIN2: "); Serial.println(adc2);
Serial.print("AIN3: "); Serial.println(adc3);
Serial.println(" ");
delay(1000);
}
Both ACS are connected to 5v and ground from arduino (shown on the left unit only to simplify).
load is an LED and a relay in parrael and are drwaing 160 mA. the second ACS is one LED but it is not connected so should be zero current.
The ACS712 can be for 5A, 20A or 30A.
Would something change to your project if the ACS712 was 20% inaccurate ?
When very carefully connecting the wires to the ACS712 module and keeping wires away from the module as much as possible with nothing electric or magnetic nearby, then the accuracy is not as bad as 20%.
The inaccuracy according to the datasheet is 1.5%. Perhaps that can be achieved in a laboratory.
The ACS712 does not output a voltage. It outputs something that is relative to its VCC. If you connect its VCC to the Arduino 5V pin and connect the output to the analog inputs of the Arduino, then you might be able to tell the difference between 1A and 2A.
Below is complete schematic. Note that I have repaced LED and relay with 2 LEDs to avoid destroying the Arduino As mentioned by jremington.
(current drawn is 40 mA. I'still get the same result . once i switch on LEDs on left side , both ACS giving same valus, follwing are the raw values Im getting from ADS1115
before switch on :
AIN0: 13710
AIN3: 13779
After switch on:
AIN0: 13558
AIN3: 13573
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
//Adafruit_ADS1015 ads; /* Use thi for the 12-bit version */
void setup(void)
{
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
//ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mVB
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
ads.begin();
delay(500);
}
void loop(void)
{
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
Serial.print("AIN0: "); Serial.println(adc0);
// Serial.print("AIN1: "); Serial.println(adc1);
//Serial.print("AIN2: "); Serial.println(adc2);
Serial.print("AIN3: "); Serial.println(adc3);
Serial.println(" ");
delay(1000);
}
5V regulator should be fine for 200-300mA, as long as the barrel jack voltage is not to high, like 7.5V or 9V. 12V, yeah, the regulator will probably overheat and turn itself off.
50mA? From what manufacturer? The only 50mA I can think of is the 50mA of 3.3V current when it comes from an FT232.
This type of Hall effect current sensor is very noisy, the only selling point is galvanic isolation. And
since they rely on the magnetic field from a wire, you'll pick up lots of interference too if you
try to measure small currents - think amps to hundreds of amps as the useful range of use
for ACSxxx devices.
There are more expensive Hall-effect sensors using a transformer which are available with better
performance, and for low voltage use without isolation a simple current shunt sensor is way more
performant.
The routing of the ground and Vcc wires to the sensors is crucial to avoid a ground-loop or
supply loop - if the current being measured flows in the same wires you'll generate IR voltages
in the wiring.
Run separate wires for the ACSxxx supply/ground from any other circuit. This gives the greatest
chance of decent ratiometric performance from them.
Each device will have a slightly different zero-point, which you have to calibrate out for best
performance - any magnets in the vicinity, or motors/transformers/relays, will directly influence
the outputs so you have to be careful about siting the sensors.
And you'll have to low-pass filter the outputs to reduce noise to get more accuracy (at the
expense of bandwidth).
Typical uses for these chips are current-feedback in a motor drive circuit where accuracy is
relatively unimportant but high bandwidth and isolation is vital - so out of the box they are
maximum bandwidth (and thus noise, as noise depends on bandwidth).
The output of the ratiometric ACS712 not only depends on current, but also on it's supply voltage.
That makes an ADS1115 with absolute A/D a poor match for that sensor.
You will be rewarded with instability.
The default ratiometric A/D of the Arduino is much better suited for this task,
and it's 10-bit A/D has a good enough resolution for that sensor.
Leo..
Thanks alot everyone for your responses.
jremington ,
Actually this what I'm hoping for. Typically current to be measured in the project is in range of 0.5 Amp but it can be as low as 50 mA with some LED lights.
MarkT
,
I did as suggested, powering up the sensor from another circuit and it seems working fine now. each sensor is giving its value and is not affected by the other. However I still need to look for another option for resolution.
Wawa,
I'm using the ADS1115 because my plan is to monitor 12 channels so I thought about ADS1115.
Anyway, I have two question I'd appreciate if you can help with it.
1- If I sacrifice the requirement to measure current value, Is there is anyway to utilize the ACS as accurate current detector only so I can detect is current is flowing ( lamp is on) or current is not flowing (lamp is off) without measuring current value.
2- When current flowing is 110 AC, would it be more difficult to get accurate value or could it be easier . What other option for in-line current detector apart from current transformer
ACS boards are more suited for high current measurements.
Note that the boards they are mounted on are not rated for mains power,
and the ACS712 range is not rated for 240volt mains.
A shunt-based INAxxxx breakout board would be better for low current/voltage.
The INA3221 can do three channels.
For mains, I would use (clip-on) current transformers.
Leo..