****************************************************/
/***********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);