This is my code for it: it is not all in english but still I hope you will understand

// Merjenje AC toka z modulom ACS712

const int sensorInAC = A0;

int mVperAmpAC = 185; // use 100 for 20A Module and 66 for 30A Module

double VoltageAC = 0;

double VRMS_AC = 0;

double AmpsRMS_AC = 0;

float getVPP_AC()

{

float resultAC;

int readValueAC; //value read from the sensor

int maxValueAC = 0; // store max value here

int minValueAC = 1024; // store min value here

uint32_t start_time = millis();

while((millis()-start_time) < 100) //sample for 1 Sec

{

readValueAC = analogRead(sensorInAC);

// see if you have a new maxValue

if (readValueAC > maxValueAC)

{

/*record the maximum sensor value*/

maxValueAC = readValueAC;

}

if (readValueAC < minValueAC)

{

/*record the maximum sensor value*/

minValueAC = readValueAC;

}

}

// Subtract min from max

resultAC = ((maxValueAC - minValueAC) * 5.0)/1024.0;

return resultAC;

}

// merjenje AC napetosti z modulom

const int sensorInAC_U = A1;

double sensorValueAC=0;

double sensorValue1AC=0;

int crosscountAC=0;

int climbhillAC=0;

double VmaxD_AC=0;

double VeffD_AC;

double VeffAC;

// merjenje DC toka

const int analogInI_DC = A2;

int mVperAmpI_DC = 13.3; // See Scale Factors Below

int ACSoffsetI_DC = 2500; // See offsets below

int RawValueI_DC = 0;

double VoltageI_DC = 0;

double AmpsI_DC = 0;

// Voltmeter DC setup

int analogInputDC_U = A3;

float voutDC_U = 0.0;

float vinDC_U = 0.0;

float R1_DC_U = 100000.0; // resistance of R1 (100K) -see text!

float R2_DC_U = 10000.0; // resistance of R2 (10K) - see text!

int valueDC_U = 0;

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

}

void loop() {

// put your main code here, to run repeatedly:

merjenjeAC_I();

merjenjeAC_U();

merjenjeDC_I();

merjenjeDC_U();

Serial.print ("AC I: ");

Serial.println (AmpsRMS_AC);

// Serial.println (vinDC);

Serial.print ("AC U: ");

Serial.println (VeffAC);

Serial.print ("DC I: ");

Serial.println (AmpsI_DC);

Serial.print ("DC U: “);

Serial.println (vinDC_U);

Serial.println (” ");

delay(1500);

}

void merjenjeAC_I(){

// merjenje AC toka

VoltageAC = getVPP_AC();

VRMS_AC = (VoltageAC/2.0) *0.707;

AmpsRMS_AC = (VRMS_AC * 1000)/mVperAmpAC;

}

float merjenjeAC_U(){

// merjenje AC napetosti

sensorValue1AC=sensorValueAC;

delay(100);

sensorValueAC = analogRead(sensorInAC_U);

if (sensorValueAC>sensorValue1AC && sensorValueAC>511){

climbhillAC=1;

VmaxD_AC=sensorValueAC;

}

if (sensorValueAC<sensorValue1AC && climbhillAC==1){

climbhillAC=0;

VmaxD_AC=sensorValue1AC;

VeffD_AC=VmaxD_AC/sqrt(2);

VeffAC=(((VeffD_AC-420.76)/-90.24)*-210.2)+210.2;

// Serial.println(VeffAC);

VmaxD_AC=0;

}

}

void merjenjeDC_I(){

//merjenje DC toka

RawValueI_DC = analogRead(analogInI_DC);

VoltageI_DC = (RawValueI_DC / 1024.0) * 5000; // Gets you mV

AmpsI_DC =(0 + ((VoltageI_DC - ACSoffsetI_DC) / mVperAmpI_DC));

// AmpsI_DC = AmpsI_DC - 18.78;

//if (AmpsI_DC<0.0) {

// AmpsI_DC=0.0;

// }

}

void merjenjeDC_U(){

// Merjenje DC napetosti

valueDC_U = analogRead(analogInputDC_U);

voutDC_U = (valueDC_U * 5.0) / 1024.0; // see text

vinDC_U = (voutDC_U / (R2_DC_U/(R1_DC_U+R2_DC_U))+1);

if (vinDC_U<0.09) {

vinDC_U=0.0;//statement to quash undesired reading !

}

}