I've got two 5-amp ACS712 sensors mounted in my project box. I have an 8-channel relay. One is measuring 120V current going through four of the channels, and the other is measuring 12V DC current going through the remaining four channels.
Apparently hall effect sensors can be kind of finicky, and I've got some hardware and software questions:
-
The two sensors are inside the project box with many other wires in proximity. Would this cause a huge amount of interference? The readings are consistent and they don't fluctuate much at all.
-
The two sensors are mounted side by side, with one taking 120V AC and the other 12V DC. Would this cause interference as well?
-
The measurement should be done on the positive (red) wire, right?
The DC and AC currents should have different code since AC is a sine wave while DC is not... right?
Here's my code (this is being done on a Node.JS server, so the code is in JavaScript). The code is based on the one here:
let calculateACCurrent = function(sensorReading){
// these constants are for the 5A ACS712
const mVperAmp = 185;
const ACSOffset = 2500; // in mV, half of 5.0V
let voltage = (sensorReading / 1024) * 5000;
let amps = ((voltage - ACSOffset) / mVperAmp);
return amps;
}
let calculateDCCurrent = function(sensorReading){
// these constants are for the 5A ACS712
const mVperAmp = 185; // this is probably wrong for DC?
let voltage = (sensorReading / 1024) * 5000;
let amps = voltage / mVperAmp;
return amps;
}
I'm not sure if these are right. The code also differs tremendously from the one here:
https://www.elecrow.com/wiki/index.php?title=ACS712_Current_Sensor-_5A
(.0264 * analogRead(A0) -13.51); //for the 5A mode,
I'm not sure what the proper code is supposed to be for this.