How do you plan to solve it?
/*Paste your code here*/
#define ANALOG_PIN A0
void setup() {
Serial.begin(9600);
}
void loop() {
int peakValue = 0; // To store the peak value
int minValue = 1023; // Initialize with max value to find the minimum
unsigned long sampling_start_time= millis();
// take sample for 1 second
while(millis() - sampling_start_time < 1000){
int sensorValue = analogRead(ANALOG_PIN); // Read the analog value
// Track the peak value (highest value)
if (sensorValue > peakValue) {
peakValue = sensorValue;
}
// Track the minimum value (lowest point of the wave)
if (sensorValue < minValue) {
minValue = sensorValue;
}
}
double peakVoltage = (peakValue - minValue) / 2.0; // peak Value calculation
peakVoltage = (peakVoltage / 1023.0) * 5.0; // Convert to voltage
// calculate RMS volatge
double rmsVoltage = peakVoltage / sqrt(2);
// calculate average voltage
double avgVoltage = 0.637 * peakVoltage;
// Print the results on the Serial Monitor
Serial.print("Peak Voltage: ");
Serial.print(peakVoltage, 3);
Serial.print("\tRMS Voltage: ");
Serial.print(rmsVoltage, 3);
Serial.print("\tAverage Voltage: ");
Serial.println(avgVoltage, 3);
delay(100);
}
Add video of output (know more)
Add a photo of your hardware showing the output.