
نوشته اصلی توسط
paddesky
سلام به دوستان
من از سایت زیر، پروژه ای را در پروتئوس شبیه سازی کردم، اما هنگام استفاده از کتابخانه در آردینو و کومپایل کد دچار ارور و مشکل می شوم.
امکان دارد یکی از دوستان به سایت مراجعه کنید و با نصب کتابخانه Emonlib.h در نرم افزار آردینو، کدها را به برنامه دهد و فایل .ino را برای من ارسال نمایید
واقعا لطف بزرگی می کنید، من تازه کار هستم لطفا کمک ام کنید
Arduino based energy monitor with Emonlib library |
آدرس سایت

من موندم کسی که این کد رو اینجوری تو سایت نوشته چند چنده با خودش :
کتابخونه که همونه هیچی
کد رو برات ادیت کردم :
کد:
#include <EmonLib.h> // Include Emon Library
EnergyMonitor emon1; // Create an instance
// include LCD the library:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600); // set up the LCD’s number of columns and rows:
lcd.begin(20, 4);
emon1.voltage(2, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(1, 111.1); // Current: input pin, calibration.
}
void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
unsigned int long timemillis=millis(); //keeping the track of the time since the device is switched ON
unsigned int long time=timemillis/1000;
float realPower = emon1.realPower; //extract Real Power into variable
float apparentPower = emon1.apparentPower; //extract Apparent Power into variable
float powerFactor = emon1.powerFactor; //extract Power Factor into Variable
float supplyVoltage = emon1.Vrms; //extract Irms into Variable
float Irms = emon1.Irms;
//displaying the values
lcd.setCursor(4,0);
lcd.print("Energy Monitor");
lcd.setCursor(0,1);
lcd.print("V=");
lcd.print(supplyVoltage);
lcd.setCursor(9,1);
lcd.print("I=");
lcd.print(Irms);
lcd.setCursor(0,2);
lcd.print("Power factor=");
lcd.print(powerFactor);
lcd.setCursor(0,3);
lcd.print("Units(kWh)=");
lcd.print(abs(realPower*time)/abs(1000*3600));
}