Interfacing ZMPT101B Voltage Sensor with Arduino

Table of Contents

What is ZMPT101B Voltage Sensor?

The ZMPT101B is a voltage transformer used to measure AC voltage. You can measure AC voltages up to 250 volts by using this module. The output of this sensor is analog. if you change input voltage, the output voltage will change as well.
When there is no load on output (nothing is connected to infput), the sensor has an initial voltage (Offset) of VCC/2. That is, if nothing is connected to the input and the supply voltage of the module is 5 volts, the output of the module will be 2.5 volts.
ZMPT101B voltage sensor module

You can download the ZMPT101B voltage sensor datasheet here.

ZMPT101B Voltage Module Pinout

ZMPT101B module has 4 pins:

  • VCC: Module power supply: 5 V
  • GND: Ground
  • OUT: Module output which is analog.

You can see Pinout of this module in the following image.

Required Materials

Hardware Components

Arduino UNO R3 × 1
ZMPT101B AC Voltage Sensor Module × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing ZMPT101B Voltage Sensor with Arduino

Step 1: Circuit

Connect the module to the Arduino according to the following image.

Be aware of safety tips when you connect the input voltage (e.g. 220 volts).

Step 2: Code 1

Upload the following code to your Arduino and then open the Serial plotter window from the Tools menu. If nothing is connected to the module inputs (module input is 0 volts), your diagram will show a number around 512 (i.e. 2.5 volts).

If you apply 220V AC to the input, you will see a voltage sinusoidal diagram on the Serial plotter.

  ZMPT101B - AC Voltage sensor
  Show AC wava in serial plotter

  modified on 7 Sep 2020
  by Mohammad Reza Akbari @ Electropeak
*/ void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { Serial.println(analogRead(A0)); delay(100);

Make sure the sine wave is complete in the serial plotter, specifically the minimum and maximum parts of the chart. If your voltage pattern is not complete, you have to turn the potentiometer on the module to display the full waveform.
If the waveform is cut from the top or bottom, you will see an error in your measurement in the next step.

Step 3: Code 2

This module measures the peak-to-peak voltage. In this code, first it finds the maximum measured value (peak voltage) and then converts it to RMS value. You can see the result in the Serial Monitor.

  ZMPT101B - AC Voltage sensor
  Calculate Voltage

  modified on 7 Sep 2020
  by Mohammad Reza Akbari @ Electropeak
*/ double sensorValue1 = 0; double sensorValue2 = 0; int crosscount = 0; int climb_flag = 0; int val[100]; int max_v = 0; double VmaxD = 0; double VeffD = 0; double Veff = 0; void setup() { Serial.begin(9600); } void loop() { for ( int i = 0; i < 100; i++ ) { sensorValue1 = analogRead(A0); if (analogRead(A0) > 511) { val[i] = sensorValue1; } else { val[i] = 0; } delay(1); } max_v = 0; for ( int i = 0; i < 100; i++ ) { if ( val[i] > max_v ) { max_v = val[i]; } val[i] = 0; } if (max_v != 0) { VmaxD = max_v; VeffD = VmaxD / sqrt(2); Veff = (((VeffD - 420.76) / -90.24) * -210.2) + 210.2; } else { Veff = 0; } Serial.print("Voltage: "); Serial.println(Veff); VmaxD = 0; delay(100); }

You can see the results for measuring city electricity voltage in the figure below.

Liked What you see?

Get updates and learn from the best

More To Explore

Comments (6)

  • Abhishek Reply

    how the following formula is derived>?can you please explain?

    Veff = (((VeffD – 420.76) / -90.24) * -210.2) + 210.2;

    March 19, 2021 at 6:17 am
    • Mehran Maleki Reply

      It’s actually a formula to calculate the input voltage RMS by using the maximum value of the sensor output voltage. And here’s how it’s derived: The graph of the sensor output voltage when it has the city electricity as its input is given as the rezult of the first code. You can see that the maximum voltage is somewhere around 600. And we already know that the input voltage RMS is 220V. First the peak value of the sensor output voltage is devided by sqrt(2). -Since it is needed for calculating the RMS- Then the rest is just a linear transformation to get an output around 220 from the sensor output voltage.

      March 22, 2021 at 4:44 pm
  • Fayyaz Reply

    As salam alaikm dear
    Fayyaz Hussain Here
    I want to ask that what is the output of Module in form of DC voltages or AC if any one then what is the Mini and Max value of the Module for Arduino to formulate and display On LCD
    220 AC voltage vs Module output voltage


    May 19, 2021 at 3:18 pm
    • Mehran Maleki Reply

      Hi. As you can see in the article, the image of the output of this module is provided -right above the “step 3” section-. And you can see that the output is actually an AC voltage. In order to calculate the input AC Voltage, you need to find the maximum of the output -Vmax_v- and use the formula given in the second code -“step 3” section-.

      May 22, 2021 at 8:43 am
  • Nasri Reply

    I wont to ask you for using zmpt101b for mesuring up to 400v

    August 16, 2021 at 5:36 pm
    • Mehran Maleki Reply

      As you can see in the first section of the tutorial, the ZMP101b module can only measure AC voltages up to 250 volts. So, I’m afraid it’s not suitable for your application.

      August 17, 2021 at 9:00 am

Leave a Reply

Your email address will not be published. Required fields are marked *