Regards,
I'm trying to use a voltage sensor ZMPT101B (with an arduino uno) to obtain the voltage values of the network (220 VRMS), but i don't need the RMS values, i need peak to peak values, ergo -311 V to 311 V (the values between that range).
The sensor is the shown in the following image:
But, the problem is that the values given in the monitor serie of my arduino are very variable and because of that i can't make a formula to translate the values of sensor to voltage values.
the code that i'm using is the following:
int rele = 3; //relé conectao al pin digital 3
int sensorvalue = 0; // variable to store the value read
int sensmax = 0;
int sensmin = 0;
int Rmsmax = 0;
int Rmsmin = 0;
void setup()
{
pinMode(rele, OUTPUT); // inicializar entrada digital 3 como una salida (OUTPUT)
Serial.begin(9600); // initialize serial communication at 9600 bits per second
}
// the loop function runs over and over again forever
void loop()
{
int sensorvalue = analogRead(A0); // read the input on analog pin 0
//Serial.println(sensorvalue); // print out the value you read
digitalWrite(rele, HIGH);
//int cont = 0; //Inicializa la varieble de contar en cero
//Serial.println (cont);
sensmax = max(sensorvalue,600) ;
sensmin = max(sensorvalue,50);
Rmsmax= sensmax*1.4142;
Rmsmin= sensmin*1.4142;
Serial.print(sensmax);
Serial.print("");
Serial.print(" SensorMax");
Serial.print("\t");
Serial.print(Rmsmax);
Serial.print("");
Serial.print(" SensorRMSmax");
Serial.println("");
Serial.print(sensmin);
Serial.print("");
Serial.print(" SensorMin");
Serial.print("\t");
Serial.print(Rmsmin);
Serial.print("");
Serial.print(" SensorRMSmin");
Serial.println("");
Serial.println("");
delay (0.000001);
}
An this are the values that monitori serie shown:
I hope ypu can help me with this problem.
Thanks.