problem with measuring Ac current with ACS712 5A Module interfaced with arduino

Hello every one , I have a project that is about designing a smart house to monitor and control the power consumption of the house , part of the project is about measuring the ac current that flows in each appliance and that for power monitoring purposes

I used a ACS712 5A module to measure the currents between 0.5amp-3amp , sometimes I get a good reading other times I got a wild fluctuations like for example the current flowing must be 3amp I got on the serial port reading about 4.5amp .

the loads I’m measuring are heaters,lights bulbs , power resistors and motors that are working on 220v (ac)

I don’t know if that is a problem with ACS712 5A Module should I isolate in some form as it does not capture any fluxs , or is the problem about the loads I’m dealing with , or it is a problem in my code as I’m not taking enough samples …

please help me …
yours answers is highly appreciated
here is the code that I’m using

float current=0;
const int currentPin = A0;
const unsigned long sampleTime = 100000UL;                           // sample over 100ms, it is an exact number of cycles for both 50Hz and 60Hz mains
const unsigned long numSamples = 250UL;                               // choose the number of samples to divide sampleTime exactly, but low enough for the ADC to keep up
const unsigned long sampleInterval = sampleTime/numSamples;  // the sampling interval, must be longer than then ADC conversion time
const int adc_zero = 510;                                                     // relative digital zero of the arudino input from ACS712 (could make this a variable and auto-adjust it)

void setup()
{
 Serial.begin(9600);
}

void loop()
{

CurrentSense();

delay(1000);

}

void CurrentSense()
{
 unsigned long currentAcc = 0;
 unsigned int count = 0;
 unsigned long prevMicros = micros() - sampleInterval ;
 while (count < numSamples)
 {
   if (micros() - prevMicros >= sampleInterval)
   {
     int adc_raw = analogRead(currentPin) - adc_zero;
     currentAcc += (unsigned long)(adc_raw * adc_raw);
     ++count;
     prevMicros += sampleInterval;
   }
 }
 
float rms = sqrt((float)currentAcc/(float)numSamples) * (50/ 1024.0);

rms= rms-0.101;

Serial.println(rms,6);
}