Problem with Arduino based Energy Monitor

Hi there dear friends ... I am new with Arduino
I recently started a simulation in Proteus about Arduino base Energy Monitor that display the V/I/PF/KW!
fortunately I finished the circuit diagram wiring and adjusting but I have problem with code compiling in Arduino Software, I installed Emonlib.h in Arduino Library but I can't compile with it. always errors happens.
I built my circuit and get the codes from: Help2educate.com is for sale | HugeDomains
Is anybody here that could help me on this matter?
Please send me a working .ino file of this project, all information available at the above link.
please help me :frowning: , I need the correct programming codes, or .ino format file.
best regards

Project from here

but I can't compile with it. always errors happens.

But you didn't think that showing us the code and the errors would help us to help you?

oh yeah. of course! I will send you now! :slight_smile:

the code that I enter the arduino software is:
I attached the codes that I entered and the Errors :confused:

code2.txt (10.1 KB)

You've cut and pasted the code from a web page, and it's got a load of illegal characters like this

“V=”

which should look like this "V="
Try and locate a raw version of the code.

Edit: The code is a mess, with two setups and two loops - was it originally like that when you found it? Please don't tell me it's an Instructable.

Well I know that, but I tried what you said and it happened again! :confused:
Can you analysis the code from that site and send me the correct one to use? please

You need to fix the double quotes.
All of them.

 float powe//extract Apparent Power into variable rFactor     = emon1.powerFactor; //extract Power Factor into Variable

I have no idea what that is supposed to look like. Best guess is float powerFactor    = emon1.powerFactor;

Ok :wink: , but dear friend, I would like that you enter and test them in your Arduino software and check it out for me, that's really nice of you dude! thanks for your help...
if you send me the .ino file of the project, u really give me a huge gift :-[

You've already got a .ino - all you have to do is fix it.

I would like that you enter and test them in your Arduino software and check it out for me, that's really nice of you dude! thanks for your help...

But I don't have your hardware, so that's not going to happen.

No unfortunately I don't have a working .ino file, I just copied the code from the web to my Arduino software, I need it for college project, I don't have the hardware, I wanna simulate it in Proteus, that's it! :frowning: :frowning: :confused: :confused:

I didn't say you had a working .ino file, I said you've got a .ino, and all you need to do is make it work.

I don't have Proteus (I've seen "Demon Seed"), so that's not going to happen either.

We could ping-pong like this all day, or you could post the code you've got so far (in code tags of course) and post the errors it gives you too, then you might get help. Your choice.

It's your college course, not mine.

And please, turn off the bold

oh yes you’re right! my choice is solving the problem, but my knowledge of Arduino is poor!
this is my wife’s college project! and I graduated from university years ago! I am an electrical engineer and my wife is the computer one… anyway … now the error messages are here:

Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files\Arduino\hardware" -tools "C:\Program Files\Arduino\tools-builder" -tools "C:\Program Files\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files\Arduino\libraries" -libraries "C:\Users\Novin Pendar\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -ide-version=10607 -build-path "C:\Users\NOVINP~1\AppData\Local\Temp\buildb58985ad23b5c9ec59f937e1a697e066.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Novin Pendar\Documents\Arduino\vdd\vdd.ino"
C:\Program Files\Arduino\arduino-builder -compile -logger=machine -hardware "C:\Program Files\Arduino\hardware" -tools "C:\Program Files\Arduino\tools-builder" -tools "C:\Program Files\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files\Arduino\libraries" -libraries "C:\Users\Novin Pendar\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -ide-version=10607 -build-path "C:\Users\NOVINP~1\AppData\Local\Temp\buildb58985ad23b5c9ec59f937e1a697e066.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Novin Pendar\Documents\Arduino\vdd\vdd.ino"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\NOVINP~1\AppData\Local\Temp\buildb58985ad23b5c9ec59f937e1a697e066.tmp\sketch\vdd.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "C:\Users\NOVINP~1\AppData\Local\Temp\buildb58985ad23b5c9ec59f937e1a697e066.tmp\sketch\vdd.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "C:\Program Files\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "C:\Users\NOVINP~1\AppData\Local\Temp\buildb58985ad23b5c9ec59f937e1a697e066.tmp\sketch\vdd.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "C:\Users\NOVINP~1\AppData\Local\Temp\buildb58985ad23b5c9ec59f937e1a697e066.tmp\sketch\vdd.ino.cpp" -o "C:\Users\NOVINP~1\AppData\Local\Temp\buildb58985ad23b5c9ec59f937e1a697e066.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
vdd:1: error: #include expects "FILENAME" or <FILENAME>

 #include “EmonLib.hâ€‌  // Include Emon Library

          ^

Using library LiquidCrystal at version 1.0.4 in folder: C:\Program Files\Arduino\libraries\LiquidCrystal 
exit status 1
#include expects "FILENAME" or <FILENAME>

It doesn’t really matter to me if the project is yours, your wife’s or second cousin Cletus’ - it’s not mine.
Go back to where you got the code from and look at how the #include directive is written.
Either #include “filename”, or #include

Ok dude, thanks for your guidance ... I will try my best! :slight_smile:

Dear Friends ... I correct the codes in Arduino :slight_smile: but now this error happens:
" expected initializer before float " What should I do to solve it? ThanQ :slight_smile:

What should I do to solve it?

You should fix it.

Or, if you want help, you should post the code that produces the error.

Oh yup! U're right! that code was this one:

float supplyVoltage   = emon1.Vrms; //extract Irms into Variable

Error is: Expected initializer before 'float'

regards :slight_smile:

Hi dear friends … finally I correct it and now its all working♥ and compiled on Arduino Software
but when I mounted the .hex file in Proteus Arduino, after running, nothing appear on the LCD!

Proteus Pic while running
Arduino Pic

#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 Apparent Power into variable rFactor     = 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));   
}

Dear Friend, Hopefully my project is working well, and All Errors disappeared, Hooray!
another problem is the position of the parameters on the display LCD!
Any Idea ?!

I fix it♥