Easy measure of any AC voltage with Arduino and ZMPT101B (up to 250V)

Поделиться
HTML-код
  • Опубликовано: 20 янв 2019
  • This is the easy and the precise way to measure AC voltage of any shape, not like the other one that rectifies the signal or use a peak to peak measure to calculate the RMS, here we're using a simple library and a simple module to calculate the True RMS of any voltage, sine, triangular and square ...
    No sketchy wiring no false code, be careful don't mess with the powerline.
    Please consider a Like and Subscribe
    Wiring and codes:
    surtrtech.com/2019/01/21/easy-...
    Arduino Modules playlist:
    bit.ly/2Dh4pJC
    Arduino Projects playlist:
    bit.ly/2Fxm2Y7
    Arduino Shields playlist:
    bit.ly/2APsndI
    Siemens TIA Portal playlist:
    bit.ly/2MhtSFT
    Facebook: / surtrtech
    Twitter: / surtrtech
  • НаукаНаука

Комментарии • 112

  • @SurtrTech
    @SurtrTech  4 года назад +1

    People who have trouble with Slope/Intercept values, Sorry my bad I tought it was clear, you can check my tutorial about AC current measuring using the same method: ruclips.net/video/GcSFvG1DFB0/видео.html at 18:00.
    It may look a bit different because it relies on the module potentiometer setting first, then on the testing conditions.
    Mine required a "further calibration" part, because I used it first in other things and didn't want to lose those values, you can skip that and set only the correct slope and intercept.

  • @nitinkumar29
    @nitinkumar29 3 года назад

    Best way to calibrate it to use the relay between this module and connection to power socket. Open the relay, then take lots of sample and average the values to get zero value or mid value where zero crossing will happen. Then close the relay, so now you will have live voltage to the module. This calibration can be implemented as a function, called in the setup function and later using command for runtime calibration. Of course, you have to find the slope using the voltage values and sensor adc measurement, say 0v will be near 512 and 230V may be near 740 depending on the trim position, consider the sensor as linear and save as a global variable and use this slope for further calculations. Also, you have to set the pot so the waveform is not clipped in the voltage range you want to measure, this has to be done in the beginning, if you have oscilloscope the better else this video describe it beautifully. By doing above mentioned step, you won't need any filtering library or complicated passive calibration calculation routine. For sine wave, you don't need to take sample and sum and take mean of it to be squared off later, wiki says if signal is sine wave, you can divide by square root of 2, just run a loop of say 100 or 1000 samples and find peak value, convert to rms value and then using slope and new reading, find out new rms voltage. That's it.

  • @rubijantojunipribadi9485
    @rubijantojunipribadi9485 5 лет назад +1

    this helps my project, thanx u v much

  • @aliens1192
    @aliens1192 3 года назад +1

    Thanks for the video, buddy! :D

  • @50Hz
    @50Hz 5 лет назад +1

    Pretty cool, I used a Energy Metering IC to measure AC

  • @MrZomhad
    @MrZomhad 5 лет назад +2

    Thanks a lot! Cheers

  • @mohamedsuhailirfankhazi6628
    @mohamedsuhailirfankhazi6628 5 лет назад +2

    Hello my friend. Thank you for this awesome tutorial. I would like to ask if you can please elaborate a little bit more on how you went about finding the slope and intercept values. It would be helpful.

    • @SurtrTech
      @SurtrTech  5 лет назад +1

      The hard work of RMS calculation is done by the Filters library and its functions...
      If you don't add the (intercept / slope) calculations, you'll read false RMS values, and they need a little calibration further, it's like that all the RMS values are making a line of sultions, this line should be adjusted so we make:
      "y=mx+b" where "y" are the new correct solutions, "x" are old solutions (They are still RMS values), "m" is the slope and "b" is the intercept.
      You can find your own slope and intercept by just measuring two or more known values with a multimeter then compare these values with ones measured with Arduino without the (slope/intercept).

  • @gulshan0799
    @gulshan0799 3 года назад +2

    does it has any protection if exposed to 260 - 270 volt Ac ?

  • @karthick4683
    @karthick4683 4 года назад

    Is that Current limiting resistor and sampling resistor has to be connected mandatorily?

  • @algunvatansever8283
    @algunvatansever8283 2 года назад +1

    Is there a module that performs exactly the same function as this module?

  • @alepassos3022
    @alepassos3022 2 года назад

    Hello, do you know some DC module to measure upper 30V? I just found one to measure from 0-25V.

  • @smoothengineering42
    @smoothengineering42 2 года назад

    hello friend, I am facing some problem while using the sensor, the calibrations is not working. with lower voltages less than 30V i get a clean sine wave but the wave forms gets distorted if the voltage is 220V. I tried increasing the VCC input voltage still wave form is looking very bad, for my work i need to capture the waveforms and use it in some other works. what can i do to make the waveform looks better?

  • @taro9751
    @taro9751 3 года назад

    Thanks a lot

  • @AlexAlexOmsk
    @AlexAlexOmsk 2 года назад

    работает! спасибо!

  • @FeyzSHB
    @FeyzSHB 4 года назад +1

    Is there a module to measure up to 50v dc?

  • @shehriyarbinak3776
    @shehriyarbinak3776 4 года назад

    why you have multiply 40.3231 with current_volts?

  • @alzaroughalzarough6153
    @alzaroughalzarough6153 Год назад

    can I use this. sensor with Arduino Due board, if so how to achieve that??

  • @johnarvinlising6834
    @johnarvinlising6834 4 года назад +1

    Hi! How do you set your assumptions/calculations for the values in the code? the 40.3231 one and the -0.04?? is there formulas i can use to obtain them? or is there any graph i should use/see?

    • @SurtrTech
      @SurtrTech  4 года назад +1

      The RMS values measured can be offset sometimes for example a real 0VAC it will give you another value so you should set the "intercept" to calibrate it, then same thing for a real 100VAC it will show another value so you set the "slope", it's like a line of solutions that you need to calibrate.

    • @nitinkumar29
      @nitinkumar29 3 года назад

      @@SurtrTech I used a relay instead of intercept, I cut the connection using relay, takes around 100 values and average them to determine zero value, then turn turn the connection on.. my offset is 0.708 (using 0V, 220V and 0V and 253V) after adjusting trim pot which I calibrated using an oscilloscope. I tested between 230V and 253V, because that's two voltage i have because of 3 phase residential connection(one regulated to 230V, other unregulated) . My measurement comes under +-2 Volts. It doesn't exactly goes to 0V though, but doesn't matter anyway.

  • @perceptrongaming4290
    @perceptrongaming4290 4 года назад

    great job!, but i think think the best way to find rms of any periodic wave would be through basic stuff...like ...taking square of n samples,divide by n and taking the square root of the the result .

    • @nitinkumar29
      @nitinkumar29 3 года назад +1

      If you know that your signal is sinusoidal then you don't need to do that, just take samples and get maximum value or peak value and then divide it by square root of 2. For square wave, rms value is peak value and for trapezoidal wave, it is square root of 3 instead of 2 for division. No need to make it more complicated, because it is not easy to sample and calculate rms values with arduino, you have to consider the timing and zero offset for zero crossing for wave.

  • @hacker6695
    @hacker6695 Год назад

    can we increase the range of measurement upto 300V ?

  • @ahmadfaqih5968
    @ahmadfaqih5968 5 лет назад

    I want to ask, do we need to add an llibrary to the Arduino IDE application?

    • @SurtrTech
      @SurtrTech  5 лет назад

      Once you install the IDE it comes with few libraries, if you need others you can download and install them...

  • @alzaroughalzarough6153
    @alzaroughalzarough6153 Год назад

    hello there,
    can I use this code with arduino due board??

  • @BG-dk2lp
    @BG-dk2lp 5 лет назад

    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 ?
    thanks

    • @SurtrTech
      @SurtrTech  5 лет назад

      Hello, it's the 3rd time you ask the same question I responded you on Hackster and my website I hope you read them.

  • @mufidzzukhruf3497
    @mufidzzukhruf3497 5 лет назад

    Hello, I using the ZMPT101B on my research, if I want to use this method, where I can find the paper referencing that formula(s)? Thanks a lot my friend

    • @SurtrTech
      @SurtrTech  5 лет назад

      First you need to know how to calculate the RMS of any signal, there are some good subjects about this on the internet, but since those calculations cannot be done by a computer in the same exact way, if you want to know how its done here, check the "RunningStatistics.h" file in the "Filters" library, and you'll find how it's done using the Sigma, Variance, Average...

  • @abdulraheemm5797
    @abdulraheemm5797 3 года назад

    Sir i m facing a problem with filters.h library

  • @zest167
    @zest167 5 лет назад +1

    Hi, I'm a last year student using this module. Could you explain how the module add voltage offset to rectified the low AC voltage?

    • @SurtrTech
      @SurtrTech  5 лет назад +2

      There's a transformer that lowers the AC voltage, there are two OpAmps, one sets the amplitude of the signal you can set with a potentiometer, the other one adds a 2.5VDC to make the offset at 2.5V instead of 0V because you can't put negative signal to the Arduino.
      I have a PDF document about the module but it's in Thai (I don't speak it), if you can't too you can translate it or just read the schematic, send me a message on Facebook page.

    • @zest167
      @zest167 5 лет назад +1

      @@SurtrTech Thank you for replying. This is really the answer I was looking for, I was wondering why there are 2 op amp in the module. It meant a lot for me(and my thesis), thank you so much.

    • @SurtrTech
      @SurtrTech  5 лет назад +1

      @@zest167 You're welcome.

  • @DissyWorld
    @DissyWorld Год назад

    My voltage sensor shows noise in output but current sensor dose'nt show any noise to direct supply. Is my voltage sensor faulty??

  • @ML-sr2ep
    @ML-sr2ep 4 года назад

    The output of this transformer is 5V max, 0V min, with 2.5V at the "zero" crossing? What is the deal with the 2 mA rated output? Is that just the max current output? We are still programming the arduino to scale the 5Vpp back up to 120V/220V?

    • @SurtrTech
      @SurtrTech  4 года назад

      I don't know if you're talking about the transformer part only or the whole module, that 2mA output is because there's a sampling resistor and this type of transformers is made for measurements only, the output voltage of the transformer is 0 - 5 VAC but the output of the module has a 2.5 V offset and it varies between 0V and 5V.
      The Arduino has to deal with a voltage that varies 0 - 5V but in the screen we should display the real value at the transformer input.

  • @tlogic23
    @tlogic23 4 года назад

    Can I use ZMPT107B instead.. I am planning to implement the module in a PCB.. Please advice

    • @SurtrTech
      @SurtrTech  4 года назад

      Hello, if the 107 has the same specifications as the 101 you can use it, same output and current..., the differences in some errors marges is not a problem, and if you can contact me on Facebook: facebook.com/SurtrTech/
      Or Twitter: twitter.com/SurtrTech, I'll send you a document that I found about the module, in Thai (I don't know that neither) but contains the schematic.

  • @LifeGeneralist
    @LifeGeneralist 3 года назад +1

    On you cheap multimeter, check if the battery is new and has proper voltage. Most multimeters show inaccurate readings due to that battery

    • @SurtrTech
      @SurtrTech  3 года назад +1

      No, it's not... you can check in the video, on sinewave it works fine but on unsual shapes it start measuring wrong.
      Check for difference between TRMS and RMS multimeters.

  • @Remontnik_
    @Remontnik_ 4 года назад

    like/ Но почему всего лишь до 250 вольт? Разве до импульсных 280 вольт нельзя скейч написать?

  • @rrestapani
    @rrestapani 4 года назад

    Hello there could this module to withstand 115VAC 400Hz? And also do you have advise what kind of current module and frequency module should I use for interfacing with arduino?
    Thanks in advance.

    • @SurtrTech
      @SurtrTech  4 года назад

      For the frequency, I don't really have concrete idea, the recommended one is 50Hz-60Hz but for 400Hz I don't know, for the current you can ACS712 or GY712, or a split core one like SCT013
      And you can use the same algorithm to measure its RMS too.
      To measure the frequency you can measure the duration between each peaks or between every 2 zeros and do the math...

    • @rrestapani
      @rrestapani 4 года назад

      @@SurtrTech SurtrTech thank you for fast respond, you've explained very clear.
      I'm preparing for my final year project and it's related to generator produces 115VAC 400Hz as mentioned above.
      Please don't be bothered if I ask you again one day 😃

    • @SurtrTech
      @SurtrTech  4 года назад

      @@rrestapani No problem, I hope I helped.

  • @mastiff1995
    @mastiff1995 5 лет назад

    Having a hard time calibrating this, Using the initial basic code. I doing this at 120vac and 60hz, would the code be different?

    • @SurtrTech
      @SurtrTech  5 лет назад

      You'll have to modify the frequency in the top, it's 50 make it 60, for the calibration the slope and intercept are very difficult to calibrate, so the easy way is to calibrate the part where you find //Further calibration
      But if you give enough time to calibrate slope and intercept you'll have better results

    • @mastiff1995
      @mastiff1995 5 лет назад

      So start the calibration with
      float testFrequency = 60; // test signal frequency (Hz)
      void setup() {
      Serial.begin(9600);
      }
      void loop()
      {
      Serial.println(analogRead(A0));
      }
      like this?

    • @SurtrTech
      @SurtrTech  5 лет назад

      Did you ask about the first code where there's only "analogRead"? No there you don't have that testFrequency variable

  • @syafiqsallehudin2650
    @syafiqsallehudin2650 3 года назад

    what is the max current input that the sensor can withstand? 2mA as per stated?

    • @SurtrTech
      @SurtrTech  3 года назад +1

      A perfect voltmeter should have 0A (open circuit), the 2mA is just the maximum parasitic draws, ideally shouldn't be there.

    • @syafiqsallehudin2650
      @syafiqsallehudin2650 3 года назад

      @@SurtrTech oic, thanks!

  • @TheDarkforce95
    @TheDarkforce95 5 лет назад

    can i get the zmpt101b fritzing part ?

    • @SurtrTech
      @SurtrTech  5 лет назад

      Hi I just have a PNG image that I inserted there.
      Here's its link if you want it: drive.google.com/file/d/15Qx__7YBNRmUHkQpN9UurQ5EwEHYljJc/view?usp=sharing

  • @nitinkumar29
    @nitinkumar29 3 года назад

    How did you get 311V value?...by multiplying 220V to square root of 2?

    • @nitinkumar29
      @nitinkumar29 3 года назад

      Got it, yes the wiki says so, it should be that...Vpeak = Vrms x sqrt(2).

  • @omaral-gallab7735
    @omaral-gallab7735 Год назад

    Can you shearing your cood

  • @hkmun8779
    @hkmun8779 5 лет назад +1

    You have done a great project. I had tried this too. I had tried connecting the ZMPT101B voltage sensor to the Arduino UNO. The ACC pin, OUT pin and Ground Pin of the ZMPT101B are connected to the 5 V pin, A0 pin and Ground Pin of the Arduino UNO respectively. The ADC output should be around 512 at 0 V input voltage. However, I can't get this value, the ADC output of my Arduino Uno is only 35. This project is really important to me. Could you advise me on that matter?

    • @SurtrTech
      @SurtrTech  5 лет назад +1

      This is strange, Try to use a potentiometer only with one analog input and check if the values goes from 0 to 1023, if okay it means the ADC is good then try to power your module and check if it has correct power (5v) and check its output with a multimeter

    • @hkmun8779
      @hkmun8779 5 лет назад

      Thanks. I had checked the ADC (A0) is working well. You said that check if it has correct power (5V). Which pin of ZMPT101B voltage sensor that I should check?

    • @SurtrTech
      @SurtrTech  5 лет назад

      @@hkmun8779 Just the Vcc and GND pin should be 5v there, I think there's a light in the module that shows that it's powered

    • @hkmun8779
      @hkmun8779 5 лет назад

      @@SurtrTech Yes, it is power and the internal LED is light up

    • @SurtrTech
      @SurtrTech  5 лет назад

      Well try to measure with a multimeter between the Output pin and the GND pin or Vcc pin and GND pin while the module is powered by 5v and don't use the terminal for the AC input so it should be a 0, and on your multimeter you should read around "2.5V" which is "512", if you don't have this value I'm afraid that something is wrong with the module.

  • @aurdinoexplorer6353
    @aurdinoexplorer6353 5 лет назад

    can the module withstand 80 amp ?

    • @SurtrTech
      @SurtrTech  5 лет назад

      This is a voltage sensor, it's wired parallel to the load, it doesn't consider the load amps, you just have to consider the voltage 0-250VAC.

  • @karthick4683
    @karthick4683 4 года назад

    Is this sensor measures 250V peak (or) the 250V rms ?

    • @SurtrTech
      @SurtrTech  4 года назад

      RMS

    • @karthick4683
      @karthick4683 4 года назад

      @@SurtrTech Can the sensor sustain the 353.5 V peak value?

  • @mutiulmuhaimin9156
    @mutiulmuhaimin9156 3 года назад

    Does 512 always read 2.5V? And this is the RMS, right?

    • @SurtrTech
      @SurtrTech  3 года назад +1

      Arduino's analog input goes from 0-5V and the analog digital conversion goes from 0-1023... Yes 512 corresponds to 2.5V.... that's not the AC voltage RMS, that's the module output when you have 0VAC at the input.

  • @zivkloda882
    @zivkloda882 4 года назад

    hi, can i measure the AC frequency with this sensor?

    • @SurtrTech
      @SurtrTech  4 года назад

      Probably, but I've never did it, you may wire the module take a value to measure with and calculate durations... should give you the frequency.

    • @zivkloda882
      @zivkloda882 4 года назад

      @@SurtrTech Okay, what is the value I take for the purpose of doing this calculation? Because there is no such thing in the sketch

    • @SurtrTech
      @SurtrTech  4 года назад

      @@zivkloda882 Well, this sketch is not meant to do that, you asked if "it's possible with this sensor?"
      The sketch should be changed completely, take any raw value as long as it's not the peak of the sinewave and everytime the signal passes through that value trigger a duration counter and stop it on the signal period, few math and you got the frequency.
      example take value 600, when it reaches trigger the duration counter and when the value reches 600 again don't stop it, but stop it when it reaches 600 the third time.
      1/duration=frequency.
      Looks interesting may do it some day.

    • @nitinkumar29
      @nitinkumar29 3 года назад

      You can certainly do that, you have to sample and find the count of maximum values in a second, you can use timer. Other way to do the same is comparator to process the signal to square wave pulse and then use arduino to detect its frequency.

  • @DEEPAKSV99
    @DEEPAKSV99 3 года назад

    At what frequency is the Triac operating in this video?

    • @SurtrTech
      @SurtrTech  3 года назад +1

      Twice the main frequency, main is 50Hz.

    • @DEEPAKSV99
      @DEEPAKSV99 3 года назад

      @@SurtrTech Thanks for the quick reply. Also at 8:08 the time period of the waveform seemed to be around 7 seconds (while plotting at a rate of 10Hz). Could you tell me how did you generate that waveform?

    • @SurtrTech
      @SurtrTech  3 года назад +1

      @@DEEPAKSV99 Just change the delay until you get the waveform you want, of course that's not real time (you won't be able to see anything), so you keep playing until you get a more/less synchronized waveform with a lower frequency.

    • @DEEPAKSV99
      @DEEPAKSV99 3 года назад

      @@SurtrTech Wow. That seems to be such an intelligent method to view the Waveform at a slower speed. Haven't thought of this before. Thanks for the idea. . .

  • @ShopperPlug
    @ShopperPlug 3 года назад

    You can't fiddle around using code based on arduino IDE, it has too much overhead and will give nothing but problems. You need to write in pure c code and also use interrupts without all the arduino IDE overhead.

  • @ArvindRao33455
    @ArvindRao33455 4 года назад

    Is it 240 volt rms or 240 volt peak?

  • @androidsha4995
    @androidsha4995 3 года назад

    I am Try ur method it working well but if i use any "delayMicroseconds() or use TM1637 Library" it value is not stable ,now this condisition what can i do ,please help.
    Library of TM1637:github.com/avishorp/TM1637

  • @electricalengineeringsures7965
    @electricalengineeringsures7965 3 года назад

    Voice is very low