All Projects → Abdurraziq → ZMPT101B-arduino

Abdurraziq / ZMPT101B-arduino

Licence: MIT license
Arduino library for ZMPT101B voltage sensor.

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to ZMPT101B-arduino

MCP CAN lib
MCP_CAN Library
Stars: ✭ 567 (+1567.65%)
Mutual labels:  arduino-library
Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
Stars: ✭ 43 (+26.47%)
Mutual labels:  arduino-library
sbus
Arduino and CMake library for communicating with SBUS receivers and servos.
Stars: ✭ 277 (+714.71%)
Mutual labels:  arduino-library
Arduino
🚀 Proyectos de todo tipo para arduino utilizando sus sensores y actuadores. 🤖
Stars: ✭ 27 (-20.59%)
Mutual labels:  arduino-library
Adafruit CAP1188 Library
Arduino library for the Adafruit CAP1188 8-Channel Capacitive Touch Sensor Breakout
Stars: ✭ 16 (-52.94%)
Mutual labels:  arduino-library
SparkFun AutoDriver Arduino Library
Arduino library support for the SparkFun AutoDriver board based on the ST Micro L6470 stepper driver.
Stars: ✭ 14 (-58.82%)
Mutual labels:  arduino-library
ArduZ80
The first Z80 emulation library for Arduino
Stars: ✭ 44 (+29.41%)
Mutual labels:  arduino-library
Adafruit AMG88xx
AMG88xx Grid-EYE
Stars: ✭ 85 (+150%)
Mutual labels:  arduino-library
TimerInterrupt
This library enables you to use Interrupt from Hardware Timers on an Arduino, such as Nano, UNO, Mega, etc. It now supports 16 ISR-based timers, while consuming only 1 hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behavin…
Stars: ✭ 76 (+123.53%)
Mutual labels:  arduino-library
ArduBadge
ArduBadge gives you GitHub Badges for you Arduino Libraries. The badge shows the latest version available and custom installation instructions.
Stars: ✭ 24 (-29.41%)
Mutual labels:  arduino-library
Commander
Arduino Command Line Utility
Stars: ✭ 20 (-41.18%)
Mutual labels:  arduino-library
scd30
arduino esp8266 ESP8266 SCD30 SCD-30 ESP32
Stars: ✭ 38 (+11.76%)
Mutual labels:  arduino-library
Seeed Arduino Sketchbook
This library provides many Wio terminal demos and some other demo for seeed's product.
Stars: ✭ 64 (+88.24%)
Mutual labels:  arduino-library
miniboot
🏗️ An I2C bootloader for Arduino.
Stars: ✭ 62 (+82.35%)
Mutual labels:  arduino-library
Adafruit MPL3115A2 Library
Arduino library for the MPL3115A2 sensors in the Adafruit shop
Stars: ✭ 41 (+20.59%)
Mutual labels:  arduino-library
Arduino-USBMIDI
Allows a microcontroller, with native USB capabilities, to appear as a MIDI device over USB to a connected computer
Stars: ✭ 98 (+188.24%)
Mutual labels:  arduino-library
asysbus
Arduino System Bus
Stars: ✭ 23 (-32.35%)
Mutual labels:  arduino-library
AD9850SPI
AD9850 SPI library for arduino
Stars: ✭ 20 (-41.18%)
Mutual labels:  arduino-library
Adafruit-MLX90614-Library
Arduino library for the MLX90614 sensors in the Adafruit shop
Stars: ✭ 113 (+232.35%)
Mutual labels:  arduino-library
WiFiEspAT
Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.
Stars: ✭ 178 (+423.53%)
Mutual labels:  arduino-library

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)

Constructor has a parameters for analog input to which it is connected.

getVoltagetAC()

float getVoltageAC(uint16_t frequency )

This method allows you to measure AC voltage. Frequency is measured in Hz. By default frequency is set to 50 Hz. Method use the Root Mean Square technique for the measurement. The measurement itself takes time of one full period (1second / frequency). RMS method allow us to measure complex signals different from the perfect sine wave.

calibrate()

int calibrate()

This method reads the current value of the sensor and sets it as a reference point of measurement, and then returns this value. By default, this parameter is equal to half of the maximum value on analog input - 512; however, sometimes this value may vary. It depends on the individual sensor, power issues etc… It is better to execute this method at the beginning of each program. Note that when performing this method, no current must flow through the sensor, and since this is not always possible - there is the following method:

setZeroPoint()

void setZeroPoint( int _zero )

This method sets the obtained value as a zero point for measurements. You can use the previous method once, in order to find out zero point of your sensor and then use this method in your code to set starting point without reading sensor.

setSensitivity()

void setSensitivity( float sens )

This method sets the sensitivity value of the sensor. This sensitivity value indicates how much the output voltage value read by the ADC is compared to the value of the measured voltage source. The default value is 0.001.

Example

This is an example of measuring electrical power using the zmpt101b sensor for voltage measurement and acs712 sensor for current measurements.

Circuit

circuit

Code

This example code use this ACS712 library for arduino.

#include "ZMPT101B.h"
#include "ACS712.h"

// ZMPT101B sensor connected to A0 pin of arduino
ZMPT101B voltageSensor(A0);

// 5 amps version sensor (ACS712_05B) connected to A1 pin of arduino
ACS712 currentSensor(ACS712_05B, A1);

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

  // calibrate() method calibrates zero point of sensor,
  // It is not necessary, but may positively affect the accuracy
  // Ensure that no current flows through the sensor at this moment
  Serial.println("Calibrating... Ensure that no current flows through the sensor at this moment");
  delay(100);
  voltageSensor.calibrate();
  currentSensor.calibrate();
  Serial.println("Done!");
}

void loop()
{
  // To measure voltage/current we need to know the frequency of voltage/current
  // By default 50Hz is used, but you can specify desired frequency
  // as first argument to getVoltageAC and getCurrentAC() method, if necessary

  float U = voltageSensor.getVoltageAC();
  float I = currentSensor.getCurrentAC();

  // To calculate the power we need voltage multiplied by current
  float P = U * I;

  Serial.println(String("U = ") + U + " V");
  Serial.println(String("I = ") + I + " A");
  Serial.println(String("P = ") + P + " Watts");

  delay(1000);
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].