ACS712 [![Build Status](https://travis-ci.org/rkoptev/ACS712-arduino.svg?branch=master)](https://travis-ci.org/rkoptev/ACS712-arduino)
======
An Arduino library to interact with the ACS712 Hall effect-based linear analog current sensor. Includes DC and RMS AC current measuring. Supports ACS712-05B, ACS712-20A, ACS712-30A sensors. Typical applications include motor control, load detection and management, switch mode power supplies, and overcurrent fault protection.
For more information see the datasheet: http://www.allegromicro.com/~/media/files/datasheets/acs712-datasheet.ashx
The accuracy of the analog sensors in conjunction with the low resolution of built-in Arduino ADC hardly allows you to accurately measure the current. So, this sensor is not suitable for precise measurements, but it will be useful in cases where you need to detect the presence of current and approximately estimate its amount. For more accurate measurements, I recommend using digital sensors such as Adafruit INA219.
Wiring
======
### Arduino
![alt arduino](https://raw.githubusercontent.com/rkoptev/ACS712-arduino/master/img/ACS712_arduino_wiring.jpg)
### ESP8266
In order to use the sensor with the ESP8266, you definitely need to take care of two things:
1. You need a 5V power for the sensor (the ESP works on 3.3V), or you can use Vin pin if you powering board with USB.
2. ESP8266's ADC input works in range 0-1 Volts, it means you need to use voltage divider to convert 0-5V range from sensor to 0-1V (Note that NodeMCU already has built-in voltage divider for 3.3V input, you need to take care about that and add additional resistors or solder wire directly to ESP analog input pin).
![alt esp8266](https://raw.githubusercontent.com/rkoptev/ACS712-arduino/master/img/ACS712_esp8266_wiring.jpg)
Methods
=======
### Constructor:
### **ACS712(** *ACS712_type* type, *uint8_t* _pin **)**
Constructor has two parameters: sensor model and analog input to which it is connected. Supported models: **ACS712_05B**, **ACS712_20A**, **ACS712_30A**
### *float* **getCurrentDC()**
This method reads the value from the current sensor and returns it.
### *float* **getCurrentAC(** *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.
### *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:
### *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.
快撑死的鱼
- 粉丝: 2w+
- 资源: 9156
最新资源
- 带补偿和电力市场上升问题的二元平衡问题的精确求解方法 二元策略中的纳什均衡 GAMS源代码,代码按照高水平文章复现,保证正确 纳什均衡在游戏中与二元决策变量包括薪酬支付和激励相容约束的非合作博弈理论直
- 利用群稀疏性进行风险约束的微电网重构 matlab源代码,代码按照高水平文章复现,保证正确 针对现有的配电系统和微电网,在存在可再生发电和负载森林化错误的情况下,考虑系统重构任务 通过求解一个机会约
- this is a very very file
- (1)微电网能源管理系统基于粒子群优化算法的风力光伏储能风光储系统的实时能量管理 如图123 matlab源代码,代码按照高水平文章复现,保证正确 粒子群优化算法(PSO),并将其应用于独立风力微型发
- python 操作涉及删除链表的第一个节点
- 西南科技大学数据挖掘实验1.zip
- 配电网潮流解的存在性与线性逼近 MATLAB源代码,代码按照高水平文章复现,保证正确 讨论了描述平衡配电网的非线性功率方程的显式近似解的推导问题 给出了潮流方程实际解存在的充分条件,并给出了PQ母线
- 西南科技大学数据挖掘实验2.zip
- 西门子PLC smart200伺服液压PID昆仑通态人机界面 包括整套SMART200 PLC程序,昆仑通态MCGS程序,东元伺服,外挂编码器高速输入,PLC用户库,液压PID控制,温度采集、压力采
- 西南科技大学数据挖掘实验3.zip
- 西南科技大学数据挖掘实验4.zip
- 台达触摸屏上位机 C#监控触摸屏软元件数据,MODBUS TCP协议 1,例子简单易懂,自己写的程序,程序有注解
- Halcon联合C#最新版本视觉开发框架,源码,采用仿visionpro拖拉流程形式,非常适合学习使用,摸索完成后可修改参考用于项目使用 我用的halcon版本为17 ,其它版本需要自行重新引用dl
- this is is is vey very file
- 信捷XDPLC系列5轴 6轴脉冲步进工程带屏 数据配方 运行信息实时监控 学习教程调试OK版
- 微网电压调节控制源代码,保证正确 通过控制分布式微网发电无功注入来调节配电网电压分布的问题 首先介绍了一类非常普遍的纯局部控制策略,并通过一个反例演示了这类策略中的所有策略都无法将电网驱动到可行电压
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页