Can i use #include "ZMPT101B.h" in ads1115?

can i use #include "ZMPT101B.h" in ads1115?
or do i need to manual change the library and change the analogread to ads analog?

Hi @jamjrrr. Please provide more information about this library.

Since there are many thousands of Arduino libraries, and more created every day, you shouldn't assume that the forum members are familiar with all of them. Even if we are familiar with a library matching the general description, that doesn't guarantee it is the same library you are using, since there are often multiple variants of libraries for common parts or tasks.

Even if not familiar with a particular library, the helpers here have the general knowledge that allows them to still answer your questions. But they can only do that after taking a look at the library.

So if you installed it via the Arduino Library Manager, then please tell us the exact name of the library as shown in Library Manager. If you downloaded the library from somewhere on the Internet, then post a link to it.

#include "ZMPT101B.h"

ZMPT101B::ZMPT101B(uint8_t _pin) {
	pin = _pin;
	sensitivity = 0.019;

int ZMPT101B::calibrate() {
	uint16_t acc = 0;
	for (int i = 0; i < 10; i++) {
		acc += analogRead(pin);
	zero = acc / 10;
	return zero;

void ZMPT101B::setZeroPoint(int _zero) {
	zero = _zero;

void ZMPT101B::setSensitivity(float sens) {
	sensitivity = sens;

float ZMPT101B::getVoltageDC() {
	int16_t acc = 0;
	for (int i = 0; i < 10; i++) {
		acc += analogRead(pin) - zero;
	float V = (float)acc / 10.0 / ADC_SCALE * VREF / sensitivity;
	return V;

float ZMPT101B::getVoltageAC(uint16_t frequency) {
	uint32_t period = 1000000 / frequency;
	uint32_t t_start = micros();

	uint32_t Vsum = 0, measurements_count = 0;
	int32_t Vnow;

	while (micros() - t_start < period) {
		Vnow = analogRead(pin) - zero;
		Vsum += Vnow*Vnow;

	float Vrms = sqrt(Vsum / measurements_count) / ADC_SCALE * VREF / sensitivity;
	return Vrms;

this the library @in0 thank you for your response can i change the analog to ads.analogsingleread(0) so that the ads can read it ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.