exit status 1 'A0' was not declared in this scope

can some please help me

Samadi:
can some please help me

I loaned my crystal ball to a friend for Halloween so can't yet view your code. I will have a look at your code later today when I get the crystal ball back.

A0 not AO ?

From @Samadi’s thread jacking reply:

#include <EmonLib.h>  // Include Emon Library
EnergyMonitor emon1;  // Create an instance

// include the Library code:
#include <LiquidCrystal.h>    // initialize the Library with the numbers of the interface pins
LiquidCrystal lcd (12, 11, 5, 4, 3, 2);
const int sensorIn = A0;
int mVperAmp = 66;  // use 100 for 20A Module and 66 for 30A Module

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
double current = 0;
double IRMS = 0;
float powerFactor = 0;
int i;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2); // set up the LCD's number of colunms and rows.
  emon1.voltage(2, 234.26, 1.7);  // Voltage: input pin, calibration, phase_ shift
  emon1.current(1, 111.1);        // current: input pin, calibration.
}


void loop()
{
  analogRead(A0, INPUT);
  Voltage = getvoltage();
  VRMS = (Voltage) * 0.707 * 11 * 12;
  current = getcurrent();
  IRMS = (current / 2.0) * 0.707;
  AmpsRMS = (IRMS * 1000) / mVperAmp;
  emon1.calcVI(20, 2000);   // Calculatte all. No. of half wavelengthe (crossings), time-cut.
  //VRMS  =emon1.Vrms;    // extract Irms into Variable
  // AmpsRMS          = emon1.Irms;
  for ( i = 0; i < 100; i++)
  {
    powerFactor   = powerFactor + emon1.powerFactor;  //extract Power Facto into Variable
  }
  powerFactor = powerFactor / 100;
  lcd.setCursor(0, 0);
  lcd.print("PF=");
  lcd.setCursor(3, 0);
  lcd.print(powerFactor * 100);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print("I=");
  lcd.setCursor(3, 1);
  lcd.print(AmpsRMS);
  lcd.print("A=");
  lcd.print(" ");
  lcd.print("V=");
  lcd.print(VRMS);
  lcd.print("V=");
}


float getcurrent()
{
  float result;

  int readValue;        // value read from the sensor
  int maxValue = 0;     // store max value here
  int minValue = 1024;  // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) // sample for 1 Sec
  {
    readValue = analogRead(A0);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /* record the maximum sensor Value*/
      minValue = readValue;
    }
    if (readValue < minValue)
    {
      /* record the minimum sensor Value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}


float getvoltage()
{
  float result;

  int readValue;        // value read from sensor
  int maxValue = 0;     // store max value here
  int minValue = 1024;  // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) // sample for 1 Sec
  {
    readValue = analogRead(A0);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /* record the maximum sensor Value*/
      minValue = readValue;
    }
    if (readValue < minValue)
    {
      /* record the minimum sensor Value*/
      minValue = readValue;
    }
  }
}
Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\GHAFOO~1.SAM\AppData\Local\Temp\arduino_modified_sketch_313829\sketch_nov01a.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\EmonLib/EmonLib.h:95:5: error: 'boolean' does not name a type

     boolean lastVCross, checkVCross;                  //Used to measure number of times threshold is crossed.

     ^

In file included from C:\Users\GHAFOO~1.SAM\AppData\Local\Temp\arduino_modified_sketch_313829\sketch_nov01a.ino:5:0:

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal/LiquidCrystal.h:86:16: error: conflicting return type specified for 'virtual void LiquidCrystal::write(uint8_t)'

   virtual void write(uint8_t);

                ^

In file included from C:\Program Files (x86)\Arduino\libraries\LiquidCrystal/LiquidCrystal.h:5:0,

                 from C:\Users\GHAFOO~1.SAM\AppData\Local\Temp\arduino_modified_sketch_313829\sketch_nov01a.ino:5:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:51:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

     virtual size_t write(uint8_t) = 0;

                    ^

sketch_nov01a:7: error: 'A0' was not declared in this scope

 const int sensorIn = A0;

                      ^

C:\Users\GHAFOO~1.SAM\AppData\Local\Temp\arduino_modified_sketch_313829\sketch_nov01a.ino: In function 'void setup()':

sketch_nov01a:22: error: 'Serial' was not declared in this scope

   Serial.begin(9600);

   ^

C:\Users\GHAFOO~1.SAM\AppData\Local\Temp\arduino_modified_sketch_313829\sketch_nov01a.ino: In function 'void loop()':

sketch_nov01a:31: error: 'A0' was not declared in this scope

     analogRead(A0, INPUT);

                ^

sketch_nov01a:31: error: 'INPUT' was not declared in this scope

     analogRead(A0, INPUT);

                    ^

sketch_nov01a:31: error: 'analogRead' was not declared in this scope

     analogRead(A0, INPUT);

                         ^

C:\Users\GHAFOO~1.SAM\AppData\Local\Temp\arduino_modified_sketch_313829\sketch_nov01a.ino: In function 'float getcurrent()':

sketch_nov01a:69: error: 'millis' was not declared in this scope

      uint32_t start_time = millis();

                                   ^

sketch_nov01a:72: error: 'A0' was not declared in this scope

           readValue = analogRead(A0);

                                  ^

sketch_nov01a:72: error: 'analogRead' was not declared in this scope

           readValue = analogRead(A0);

                                    ^

C:\Users\GHAFOO~1.SAM\AppData\Local\Temp\arduino_modified_sketch_313829\sketch_nov01a.ino: In function 'float getvoltage()':

sketch_nov01a:99: error: 'millis' was not declared in this scope

         uint32_t start_time = millis();

                                      ^

sketch_nov01a:102: error: 'A0' was not declared in this scope

           readValue = analogRead(A0)

                                  ^

sketch_nov01a:102: error: 'analogRead' was not declared in this scope

           readValue = analogRead(A0)

                                    ^

exit status 1
'A0' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Don’t you think it would have been useful to post the code and the error message, as you did in your reply to the other thread?

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you’re using the Arduino Web Editor you will not have access to this useful tool but it’s still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we’re trying to read your code.

When your code requires a library that’s not included with the Arduino IDE please always post a link (using the chain link icon on the toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.

6v6gt:
A0 not AO ?

No, that’s not it.

Another possibility is code in a .cpp file that isn't including Arduino.h

Another possibility is code in a .cpp file that isn't including Arduino.h

Yeah, I suspect that from this:

C:\Program Files (x86)\Arduino\libraries\EmonLib/EmonLib.h:95:5: error: 'boolean' does not name a type

Because boolean is a typedef from the Arduino core. Which is why it's important to include links to the library dependencies. I shouldn't have to go hunt around for this EmonLib and hope I find the same version that Samadi happens to be using.

No response from OP?

I think that they didn’t have the correct board selected under the tools tab.

I get the same issue when I try to upload to an Uno instead of a Mega :wink: