ConnectionDiagramwithLiquidCrystal
The probe of the AC transformer can only clamp one AC wire at a time. It cannot be clamped
two at the same time!
SampleCodewithLiquidCrystal
/***************************************************
This example reads Analog AC Current Sensor.
Created 2016-3-10
By berinie Chen <bernie.chen@dfrobot.com>
GNU Lesser General Public License.
See <http://www.gnu.org/licenses/> for details.
All above must be included in any redistribution
****************************************************/
/***********Notice and Troubleshooting***************
1.Connection and Diagram can be found here http://www.dfrobot.com/wiki/inde
x.php?title=Gravity:Analog_AC_Current_Sensor_(SKU:SEN0211)#Sample_Code
2.This code is tested on Arduino Uno.
****************************************************/
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // select the pins used on the LC
D panel
float Vref = 0;
const int ACPin = A2; //set arduino signal read pin
#define ACTectionRange 20; //set Non-invasive AC Current Sensor tection range
(20A,30A,50A,100A)
void setup()
{
Serial.begin(115200);
lcd.begin(16, 2); // start the library
pinMode(13, OUTPUT);
Vref = readVref(); //Read reference voltage
}
void loop()
{
lcd.setCursor(3, 0);
float ACCurrentValue = readACCurrentValue(); //read AC Current Value
// Serial.println(ACCurrentValue);
lcd.print("AC CURRENT");
lcd.setCursor(5, 1);
lcd.print(ACCurrentValue);
lcd.print(" A");
digitalWrite(13, HIGH);
delay(50);
digitalWrite(13, LOW);
delay(50);
}
float readACCurrentValue()
{
float ACCurrtntValue = 0;
unsigned int peakVoltage = 0;
unsigned int voltageVirtualValue = 0; //Vrms
for (int i = 0; i < 5; i++)
{
peakVoltage += analogRead(ACPin); //read peak voltage
delay(1);
}
peakVoltage = peakVoltage / 5;
voltageVirtualValue = peakVoltage * 0.707; //change the peak voltag
e to the Virtual Value of voltage
/*The circuit is amplified by 2 times, so it is divided by 2.*/
voltageVirtualValue = (voltageVirtualValue * Vref / 1024) / 2;
ACCurrtntValue = voltageVirtualValue * ACTectionRange;
return ACCurrtntValue/1000;
}
/*Read reference voltage*/
long readVref()
{
long result;
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined (__AV
R_ATmega328P__)
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);

SEN0211

Mfr. #:
Manufacturer:
DFRobot
Description:
Current Sensor Development Tools Gravity Analog AC Current Sensor
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet