Hello everyone, first time in the forum.
I created a custom PCB with the ACS37800 IC to measure current consumption and voltage level on a 220VAC line. Using ESP32 as the main microcontroller of the board.
I managed to work out SPI communication using SparkFun Library as base, simply changing from i2c to spi. Thank you very much for that btw!
The IC circuit is as the example in the datasheet, with L line isolated via 2 x 1MOhm resistors, N line connected directly to GND in the IC, and the RSENSE with a value of 2.2KOhm. The device is powered via a Switching Mode Power Supply, which is why the N can’t be isolated from GND.
The IC is 3.3VDC powered, as is the ESP32.
Here is the schematic of the ACS37800 in my custom board, please note that R8 and R9 are actually shorted with 0Ohm resistors:
And here is the PCB layout of the board:
My problem is that the values read are not exactly correct. For example, it measures 194 VAC RMS, but the real value is 224VAC RMS; in current is similar, without load the value read is 0.088A and with a load of approximately 120W , the measured value is 0.680 A (it should be around 0.110A).
Here is an extract from the ESP32 log:
Voltage: 0.01, Current: 0.088, Active: 0.00, Img: 0.00, Apparent: 0.00
Voltage: 191.90, Current: 0.680, Active: 129.41, Img: 14.46, Apparent: 130.56
Voltage: 191.82, Current: 0.679, Active: 129.14, Img: 14.33, Apparent: 130.29
Note here the Apparent Power is very close to the real value but the Voltage and Current are weird.
In the library I see a lot of magic numbers that I can’t work out where they come from, even thought they say what they are. For example, here I don’t understant where the 55000 value comes from:
volts /= 55000.0; //Convert from codes to the fraction of ADC Full Scale (16-bit)
volts *= 250; //Convert to mV (Differential Input Range is +/- 250mV)
volts /= 1000; //Convert to Volts
//Correct for the voltage divider: (RISO1 + RISO2 + RSENSE) / RSENSE
//Or: (RISO1 + RISO2 + RISO3 + RISO4 + RSENSE) / RSENSE
float resistorMultiplier = (_dividerResistance + _senseResistance) / _senseResistance;
volts *= resistorMultiplier;
Also, the datasheet is very confusing in this matter as the calculation for the real value is very different and I can’t make heads or tails of this explanation:
I tried changing averaging samples, offsets, gains, and others but the values just went crazier than before.
I hope someone can help me understand what I’m doing wrong.