How to read voltage from ZMPT101B sensor through ADS1115?

Hello,

I have a problem regarding the measurement of the 220VAC with ZMPT101B sensor from China, which has an operating level of 5V or more. I connected an external power supply of 12V to power this sensor.

The power supply has L, N, GND, -V, +V. I connected the L, N, GND to 220VAC.

-V of power supply -> GND of ZMPT101B
+V of power supply -> VCC of ZMPT101B

Between these 2 points I have 12V.

Now the ZMPT101B has 2 more pins: OUT and 1 more GND.

The OUT pin connects to A2 of ADS1115.

However, I am not sure whether the GND of the ZMPT101B should be connected to A3 of ADS1115 in order to measure in differential mode ads.readADC_Differential_2_3() for accurate measurement of the 220V or if it should be connected to common GND of ADS1115 and Arduino's (Arduino MKR) and do a single ended point measurement relative to the GND of the ADS1115 as in ads.readADC_SingleEnded(2).

Should I measure and calculate and do the things in the same manner for Voltage as I do for Current or not? Given the fact that the Voltage should output (graphically) a sinusoidal function, should I use some Min and Max values for Voltage and calculate the RMS from there on?

My code is the following:

#include <Wire.h>
#include <Adafruit_ADS1X15.h>

Adafruit_ADS1115 ads;

const float FACTOR = 30; //30A/1V from teh CT

const float multiplier = 0.00003125;

void setup() {
  Serial.begin(9600);

  ads.setGain(GAIN_FOUR);      // +/- 1.024V 1bit = 0.5mV
  ads.begin();

}

void printMeasure(String prefix, float value, String postfix)
{
  Serial.print(prefix);
  Serial.print(value, 3);
  Serial.println(postfix);
}

void loop() {
  float currentRMS = getcurrent();
  float voltageRMS = getvoltage();
  printMeasure("Irms: ", currentRMS, "A");
  printMeasure("Vrms: ", voltageRMS, "V");
  delay(1000);

}

float getcurrent()
{
  float voltage;
  float current;
  float sum = 0;
  long time_check = millis();
  int counter = 0;

  while (millis() - time_check < 1000)
  {
    voltage = ads.readADC_Differential_0_1() * multiplier;
    current = voltage * FACTOR;

    sum += sq(current);
    counter = counter + 1;
  }

  current = sqrt(sum / counter);
  return (current);
}

float getvoltage() // question-related function
{
  float voltage;
  float sum = 0;
  long time_check = millis();
  int counter = 0;

  while (millis() - time_check < 1000) {
    voltage = ads.readADC_Differential_2_3() * multiplier; // question-related line of code
    
    sum += sq(voltage);
    counter++;
  }

  voltage = sqrt(sum / counter);
  return voltage;
}

Thank you for your time!

Hi,
Have you Googled;

ZMPT101B ADS1115 arduino

Tom... :grinning: :+1: :coffee: :australia:

Hi, yes.

I haven't found something conclusive for what I'm asking exactly. Maybe I don't understand your question. Could you provide a specific link so I can look it up?

Thank you!

The voltage on the ADS1115 inputs must be between the ADS1115 GND and Vcc at all times, or it will be instantly destroyed. Use the same 5V (positive voltage only) power supply for both the ZMPT101B sensor and the ADS1115 and you should be fine.

You need only one single-ended input on the ADS1115 to monitor the sensor output voltage, and will have to subtract the midpoint value (0 VAC input) from the ADS result.

1 Like

Hi,
Why do you want to use a ADS1115?

The MKR has, 8, 10, 12 bit ADC's I believe.

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

1 Like

You should describe the final purpose of your project.
There is a chance that a different solution than using the ZMPT101B and an ADS1115 is better suited,
or
a modification how to use the ZMPT101B and the ADS1115

best regards Stefan

1 Like

Hello, Stefan. Thanks for your comment.

The purpose of this project is to measure energy consumption in a household, for a final year project (IoT) which implies having a graph over time of the power, current consumption and the simple measurement of the 220VAC from the power outlet. Currently I am able to measure the current of a few loads (e.g. electric heater, lights as in simple bulbs for the moment etc.) with values close to the ones measured with a professional clamp meter. For smaller values, it's accuracy it's good, for greater ones (>3.9A), there's a smaller accuracy.

Hello, Tom.

I would like to use ADC1115 for a more accurate depiction of values.

That would mean having a Single-ended point measurement of A2 for example, relative to the ADS1115's GND?

OK so this offers multiple approaches:

depending on the kind of energy-meter used
if it looks more like this one

which has a blinking LED one blink for every 0.000625 kWh
or as the type-plate says 1600 blinks per kWh
pretty easy to detect the blinks with a photo-transistor

or if it looks more like this


you could use optical detection of the red area on the disk
giving information about a certain amout of energy used per rotation
And this would give you the summary of energy-consumption of the complete house

1 Like

Any ADS1115 input can be used.

GND and 5V must be shared between the ADS1115 and the ZMPT101B.

1 Like

I'm using a similar approach using same ADC. I too was using the default sample per second rate of 128. What occurred to me is that with 128 SPS, you're only getting roughly 2 samples per AC cycle, sampling 60/50 cycles per second. Since you can't predict where in the cycle you start, you 're likely to read rather low compared to actual RMS. In my case my results were 30% low.

What I am doing is reading a current sense coil built into an APC PDU. The sensor produces 0.0165V RMS per amp which I determined by using a DMV to measure the AC output against fixed loads. I later found references that confirmed my values.
3.5A yielded 0.058v AC on my DVM
13.5A yielded 0.225v AC on my DMV
Using the same conversion factor of 16.5mV/A, I was getting 2.4A for 3.5A load, 9.2A for 13.5A load. Load is a hairdrier, used an amp/watt meter to measure its current load. Since a hairdrier is mostly resistive, not much of an issue of a power factor issue.

I'm taking a differential reading between A0 and A3, with A3 also sent a DC offset of a 10K ohm voltage divider across the 3.3v VCC supply. Since the 3.3V isn't precise, I can't use that as an offset to use with a single end reading.
It was just today I realized I probably was reading low not because of the basic algorithm, but probably because of the sample rate being too close to the sensor frequency, that I'm probably tending to hit close to the middle of the wave, thus 'averaging' low.

I was hoping to find someone who was successful in getting accurate small signal RMS readings from a mains current sensor.
I only want to display to 1 decimal place with max current 30A.

If you connected 12V to the Vcc pin, you probably killed the ZMPT101B. Have a look here:
ZMPT101B application

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