GithubHelp home page GithubHelp logo

developersdevxnow / zmpt101b-arduino Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abdurraziq/zmpt101b-arduino

0.0 0.0 0.0 358 KB

Arduino library for ZMPT101B voltage sensor.

License: MIT License

C++ 100.00%

zmpt101b-arduino's Introduction

ZMPT101B

An Arduino library to interact with the ZMPT101B, an active single phase AC voltage sensor module.

This library is based on Ruslan Koptev ACS712 current sensors library for Arduino https://github.com/rkoptev/ACS712-arduino. This library is modified so that it can be used with ZMPT101B voltage sensor with the same code principle.

Methods

Constructor

ZMPT101B(uint8_t pin, uint16_t frequency = DEFAULT_FREQUENCY);

Constructor has a parameters pin for analog input to tell where is connected and the frequency value of the AC voltage that the sensor will measure (by default 50.0Hz).

Reading RMS Voltage Value

float getRmsVoltage(uint8_t loopCount = 1)

This method allows us to obtain the root mean square (RMS) value of the voltage. By default this method will only calculate the RMS value of one period wave. If you want the calculation to be done over several periods you can specify how many iterations you want. Reading more than once will usually return a more precise value however, sometimes it will take longer.

Set Sensitivity

void setSensitivity(float value)

This method sets the sensitivity value of the sensor. The Sensitivity is the ratio of the output voltage sensor (that read by the ADC) to the input voltage sensor. The default value of sensitivity is 500.0.

Example

Circuit

circuit

โš ๏ธ If you are using a board with a 3.3 Volt system you should connect VCC to 3.3 Volt (eg ESP board family).

Steep

0. Make sure the output voltage from the sensor is not clipped and distorted

Connect the sensor to the voltage source you are going to measure.

Use the following code to observe the waveform from the ZMPT1b sensor output.

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(analogRead(A0));
  delayMicroseconds(1000);
}

Upload code and open serial plotter.

Rotate the trimpot on the sensor until the output is not clipped, distorted and safe enough.

Wave

1. Determine the appropriate sensitivity value

Open the calibrate.ino example and change the ACTUAL_VOLTAGE value according to the actual AC voltage value (eg based on a measurement with a voltmeter or something else). Upload the code then open serial monitor. Wait until the sensitivity value is displayed and then copy it.

2. Start measurement

Open the simple_usage.ino example then change the SENSITIVITY value (seventh line) based on the value you got in the previous process. Upload the code then open the serial monitor to observe the displayed voltage value.

zmpt101b-arduino's People

Contributors

abdurraziq avatar per1234 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.