07-18-2023, 01:39 PM
Code:
/**
* This program shows you how to use the basics of this library.
*/
#include <ZMPT101B.h>
//#define SENSITIVITY 500.0f
#define SENSITIVITY 507.25f
// ZMPT101B sensor output connected to analog pin A0
// and the voltage source frequency is 50 Hz.
ZMPT101B voltageSensor(34, 50.0);
void setup() {
Serial.begin(115200);
// Change the sensitivity value based on value you got from the calibrate
// example.
voltageSensor.setSensitivity(SENSITIVITY);
}
void loop() {
// read the voltage and then print via Serial.
float voltage = voltageSensor.getRmsVoltage();
Serial.println(voltage);
delay(1000);
}