Skip to content

Easy measure of AC Voltage using Arduino and ZMPT101B



        Hello guys, and welcome, before we start anything, I want to warn you about messing with domestic voltage, power line, wall power…. pay attention and be very careful it’s dangerous.

Watch the tutorial for further explanations.

             So the project today is how to measure AC voltage up to 250V, in both 50Hz and 60Hz, using the ZMPT101B, that’s the name of the transformer only, but you’ll find it around with this name or “AC voltage sensor”.


          This module used with the right code, is far better for measures, than the other methodes that uses transformer + rectifier + voltage divider…., these kind of things can be dangerous if not done right, and also don’t give the right values all the time because it doesn’t make any difference if the signal si square or triangular, even though it does affect seriously the RMS, and the RMS is what we want to measure, and for this we should keep the same shape of the signal when adapting it for the Arduino, and here is when the module is handy.



The module takes the signal we want to measure, here a 220V domestic power, it has around 311V as its peak.


The module transformer brings it back to 2.5V peak.



Then it adds a 2.5V offset to adapt it to the Arduino.


          And here pay attention, some codes around are used with this module, they only do a sampling of the signal and measure the peaks then a little multiplication,and it can show you the “RMS” of this signal, but those codes work only for perfect sinewave signal, if you’re measuring another shape of the signal it would be false.

Light dimmer.jpg

And for example here I used a light dimmer, which is based on a Triac and you know the “weird” shape of the signal that a Triac makes.


Here you can see, to measure the RMS you shouldn’t only measure the peaks and do the same calculations for the Sinewave signal.

But you should do it the right way and it’s very difficult to code, that’s why I found a simple library as always to do the work for us 😀

But you should know how it’s done and it’s easy to find around.


For the measures I’m using an OLED display, you can check My previous tutorial, on how to use it with different examples.





This is the whole wiring, and as mentionned I’m using an 128×32 OLED screen you can use it or no, the module is powred by 5v and delivers an analog signal.



The first thing you need to do, is calibrating the module by its potentiometer, you wire the module, plug the Arduino and upload this simple code, and don’t forget to place you measuring probes to the power socket (BE CAREFUL !!!) and you already know the voltage over.

void setup() {

void loop() 

Open the serial plotter of the Arduino IDE:


You’ll see something like this in your serial plotter, it means you don’t acquire the whole signal, adjust the potentiometer until you have something that looks like a sinewavish thing. I know that’s not the AC sinewave signal.



When you have something like this you can add a delay to see a nice sinewave, here it’s because I’m measuring right after my light dimmer you’ll see a little peak before the signal peak if you measure the socket directly you won’t have this.

void setup() {

void loop() 


Now your module is calibrated, the code calibrations will be based on it so try to not change it.


The library I’m using is Filters.h, it reduces the amount of work for you, Download here, or from Github. I don’t know if they are the same because I had it for 2 years.

Adafruit OLED display libraries


Here’s the code I’ve used: Download here



The values are sure not perfect and 100% Accurate but as you see you need very precise calibrations to make it perfect, and don’t forget you’re using a 10$ or less module, and there it’s compared to a multimeter that uses TRMS, True RMS.



     A non TRMS Multimeter will give you a false reading for a non Sinewave signal too, as you can see the cheap one (blue) compared to our project, it’s 40V difference which is not good. (NB: the other multimeter is not measuring at that moment, check the video for more).

That’s all folks, I hope you like it, be careful and if you have any probel feel free to contact me, don’t forget to support the channel by a subscribe.


Yassine View All

Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.

4 thoughts on “Easy measure of AC Voltage using Arduino and ZMPT101B Leave a comment

  1. Hi Sir
    How are you
    Sir i also want to run other perimeters what can i do
    When i was trying to remove while it says error while reading
    PLease help in it


  2. Hi,

    I really like this project

    Can you tell me, from your code , where you got the values below ?
    float intercept = -0.04; // to be adjusted based on calibration testing
    float slope = 0.0405; // to be adjusted based on calibration testing
    current_Volts= current_Volts*(40.3231); //Further calibrations for the amplitude

    I have adjusted the Trim Pot as you suggested ..and the readings look good – . what is my next step to calibrating ?
    How do I get the the readings translated to the correct voltage.
    NOTE: My AC voltage is 240 Volts so I assume the values you have above are not correct for me ?
    How do I get the values I need ?



    • Hi, did you ask me on hackster? because I had the same question toda, and I responded there.
      I’ll just copy it here:
      “Hi, to understand better you can check the “RunningStatistics.cpp” file from the library, you’ll find the mathematical functions, it takes the input which is an analog one, do some sampling then calculate the average square value and after the standard deviation…
      For the intercept and slope you can make the input as 0 and you should have 0 then take a known value and calibrate the slope
      For the “current_Volts= current_Volts*(40.3231)” actually I had this lying around for 2 years and first it was mean’t to measure “Current” so multiplied by (40.3231).
      About the multimeter, cheap multimeters measure all AC signals as sinewaves, if you want to use it to calibrate, measure AC sinewave signal from a socket or after a transformer, but since I used a Triac based light dimmer I had to use a TRMS multimeter to get the right value.”

      You can start by the values given above, as I said they are very sensitive, or you can put the Analog input to 0 and make slop=0 then adjust the intercept to get 0 as the result, then put the voltage to a known value, and the intercept to its new value and adjust the slope.
      For the last line to calibrate you can remove it, if you do this. Mein was based on an code I made before to measure current… so I had to readjust


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: