Declaration of function cannot work in different board

I have problem where the MQCalibration is not working in the board of NodeMCU ESP8266 , while the coding works in the Arduino uno board(WIthout the IoT Blynk app part)
I intended to do this project where if gas leaked, it will notify the user through the Blynk app phone
Where the error state as below
C:\Users\User\Documents\Arduino\Gas_sensor_reeedit\Gas_sensor_reeedit.ino: In function 'void setup()':

Gas_sensor_reeedit:70: error: 'MQCalibration' was not declared in this scope

Ro = MQCalibration(MQ_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air

^

C:\Users\User\Documents\Arduino\Gas_sensor_reeedit\Gas_sensor_reeedit.ino: In function 'void loop()':

Gas_sensor_reeedit:87: error: 'MQRead' was not declared in this scope

iPPM_LPG = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG);

^

Gas_sensor_reeedit:87: error: 'MQGetGasPercentage' was not declared in this scope

iPPM_LPG = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG);

^

C:\Users\User\Documents\Arduino\Gas_sensor_reeedit\Gas_sensor_reeedit.ino: In function 'long int MQGetGasPercentage(float, int)':

Gas_sensor_reeedit:190: error: 'MQGetPercentage' was not declared in this scope

return MQGetPercentage(rs_ro_ratio,LPGCurve);

^

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

and this is my Coding

/**************************************************************************** 
  Author : Andy @ MYBOTIC www.mybotic.com.my
  Date:5/7/2016 
  Project: How to detect the concentration of gas by using MQ2 sensor
****************************************************************************/


/************************Hardware Related Macros************************************/
#include <LiquidCrystal.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxxxxxxxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxx";
char pass[] = "xxxxxxxx";
const int calibrationLed = 13;                      //when the calibration start , LED pin 13 will light up , off when finish calibrating
const int MQ_PIN=A0;                                //define which analog input channel you are going to use
int RL_VALUE=5;                                     //define the load resistance on the board, in kilo ohms
float RO_CLEAN_AIR_FACTOR=9.83;  

//RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO,
                                                    //which is derived from the chart in datasheet
 
/***********************Software Related Macros************************************/
int CALIBARAION_SAMPLE_TIMES=50;                    //define how many samples you are going to take in the calibration phase
int CALIBRATION_SAMPLE_INTERVAL=500;                //define the time interal(in milisecond) between each samples in the
                                                    //cablibration phase
int READ_SAMPLE_INTERVAL=50;                        //define how many samples you are going to take in normal operation
int READ_SAMPLE_TIMES=5;                            //define the time interal(in milisecond) between each samples in 
                                                    //normal operation
 
/**********************Application Related Macros**********************************/
#define         GAS_LPG             0   
//#define         GAS_CO              1   
//#define         GAS_SMOKE           2    
 
/*****************************Globals***********************************************/
float           LPGCurve[3]  =  {2.3,0.21,-0.47};   //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve. 
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) 
//float           COCurve[3]  =  {2.3,0.72,-0.34};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000,  0.15) 
//float           SmokeCurve[3] ={2.3,0.53,-0.44};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.53), point2: (lg10000,  -0.22)                                                     
float           Ro           =  10;                 //Ro is initialized to 10 kilo ohms

const int rs = 11, en = 12, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);         //LCD pins

void setup()
{ 
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  lcd.begin(16,2);
  pinMode(10, OUTPUT);
  pinMode(calibrationLed,OUTPUT);
  digitalWrite(calibrationLed,HIGH);
  lcd.print("Calibrating...");                        //LCD display
  

  
  Ro = MQCalibration(MQ_PIN);                         //Calibrating the sensor. Please make sure the sensor is in clean air         
  digitalWrite(calibrationLed,LOW);              
  
  lcd.print("done!");                                 //LCD display
  lcd.setCursor(0,1);
  lcd.print("Ro= ");
  lcd.print(Ro);
  lcd.print("kohm");
  delay(3000);
}
 
void loop()
{  
  long iPPM_LPG = 0;
  //long iPPM_CO = 0;
  //long iPPM_Smoke = 0;

  iPPM_LPG = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG);
  //iPPM_CO = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_CO);
  //iPPM_Smoke = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_SMOKE);
  Blynk.run();
  if(iPPM_LPG > 50 )
  {  digitalWrite(10,HIGH); 
     Blynk.notify("It is Over Flow!");
     }
  else 
  {digitalWrite(10,LOW);
     Blynk.notify("It is Normal!");}
  
   lcd.clear();   
   lcd.setCursor( 0 , 0 );
   lcd.print("Concentration of gas ");
   
   lcd.setCursor( 0 , 1 );
   lcd.print("LPG: ");
   lcd.print(iPPM_LPG);
   lcd.print(" ppm");   
   
   /*lcd.setCursor( 0, 2 );
   lcd.print("CO: ");
   lcd.print(iPPM_CO);
   lcd.print(" ppm");    

   lcd.setCursor( 0,3 );
   lcd.print("Smoke: ");
   lcd.print(iPPM_Smoke);
   lcd.print(" ppm"); */  

   delay(200);
  
}
 

float MQResistanceCalculation(int raw_adc)
{
  return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc));
}
 

float MQCalibration(int mq_pin)
{
  int i;
  float val=0;

  for (i=0;i<CALIBARAION_SAMPLE_TIMES;i++) {            //take multiple samples
    val += MQResistanceCalculation(analogRead(mq_pin));
    delay(CALIBRATION_SAMPLE_INTERVAL);
  }
  val = val/CALIBARAION_SAMPLE_TIMES;                   //calculate the average value
  val = val/RO_CLEAN_AIR_FACTOR;                        //divided by RO_CLEAN_AIR_FACTOR yields the Ro                                        
  return val;                                                      //according to the chart in the datasheet 

}
 
*/ 
float MQRead(int mq_pin)
{
  int i;
  float rs=0;
 
  for (i=0;i<READ_SAMPLE_TIMES;i++) {
    rs += MQResistanceCalculation(analogRead(mq_pin));
    delay(READ_SAMPLE_INTERVAL);
  }
 
  rs = rs/READ_SAMPLE_TIMES;
 
  return rs;  
}
 
*/ 
long MQGetGasPercentage(float rs_ro_ratio, int gas_id)
{
  if ( gas_id == GAS_LPG ) {
     return MQGetPercentage(rs_ro_ratio,LPGCurve);
  }/* else if ( gas_id == GAS_CO ) {
     return MQGetPercentage(rs_ro_ratio,COCurve);
  } else if ( gas_id == GAS_SMOKE ) {
     return MQGetPercentage(rs_ro_ratio,SmokeCurve);
  }  */  
 
  return 0;
}
 
*/ 
long  MQGetPercentage(float rs_ro_ratio, float *pcurve)
{
  return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0])));
}

You mean the function that's commented-out?

ermm, no , i mean the MQCalibration is not stated in this scope error when compiling

float MQCalibration(int mq_pin)
{
int i;
float val=0;

for (i=0;i<CALIBARAION_SAMPLE_TIMES;i++) { //take multiple samples
val += MQResistanceCalculation(analogRead(mq_pin));
delay(CALIBRATION_SAMPLE_INTERVAL);
}
val = val/CALIBARAION_SAMPLE_TIMES; //calculate the average value
val = val/RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro
return val; //according to the chart in the datasheet

}

*/ <-------------

Please ignored the comment sign ,sorry for the misunderstood, i just edited it without comment because the post would not let me exceed 9000 words
basically when arduino uno board is used, it has no problem,
but when NodeMCU ESP8266 , the MGRead, MGCalibration all have error in it

Here i attached a more clear view of the coding without the comment or any codes that does not affect anything

/************************Hardware Related Macros************************************/
#include <LiquidCrystal.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxxxxxxxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxx";
char pass[] = "xxxxxxxx";
const int calibrationLed = 13;                      //when the calibration start , LED pin 13 will light up , off when finish calibrating
const int MQ_PIN=A0;                                //define which analog input channel you are going to use
int RL_VALUE=5;                                     //define the load resistance on the board, in kilo ohms
float RO_CLEAN_AIR_FACTOR=9.83;  

//RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO,
                                                    //which is derived from the chart in datasheet
 
/***********************Software Related Macros************************************/
int CALIBARAION_SAMPLE_TIMES=50;                    //define how many samples you are going to take in the calibration phase
int CALIBRATION_SAMPLE_INTERVAL=500;                //define the time interal(in milisecond) between each samples in the
                                                    //cablibration phase
int READ_SAMPLE_INTERVAL=50;                        //define how many samples you are going to take in normal operation
int READ_SAMPLE_TIMES=5;                            //define the time interal(in milisecond) between each samples in 
                                                    //normal operation
 
/**********************Application Related Macros**********************************/
#define         GAS_LPG             0   

/*****************************Globals***********************************************/
float           LPGCurve[3]  =  {2.3,0.21,-0.47};   //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve. 
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) 
                                                    
float           Ro           =  10;                 //Ro is initialized to 10 kilo ohms

const int rs = 11, en = 12, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);         //LCD pins

void setup()
{ 
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  lcd.begin(16,2);
  pinMode(10, OUTPUT);
  pinMode(calibrationLed,OUTPUT);
  digitalWrite(calibrationLed,HIGH);
  lcd.print("Calibrating...");                        //LCD display
  

  
  Ro = MQCalibration(MQ_PIN);                         //Calibrating the sensor. Please make sure the sensor is in clean air         
  digitalWrite(calibrationLed,LOW);              
  
  lcd.print("done!");                                 //LCD display
  lcd.setCursor(0,1);
  lcd.print("Ro= ");
  lcd.print(Ro);
  lcd.print("kohm");
  delay(3000);
}
 
void loop()
{  
  long iPPM_LPG = 0;


  iPPM_LPG = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG);

  Blynk.run();
  if(iPPM_LPG > 50 )
  {  digitalWrite(10,HIGH); 
     Blynk.notify("It is Over Flow!");
     }
  else 
  {digitalWrite(10,LOW);
     Blynk.notify("It is Normal!");}
  
   lcd.clear();   
   lcd.setCursor( 0 , 0 );
   lcd.print("Concentration of gas ");
   
   lcd.setCursor( 0 , 1 );
   lcd.print("LPG: ");
   lcd.print(iPPM_LPG);
   lcd.print(" ppm");   
   

   delay(200);
  
}
 

float MQResistanceCalculation(int raw_adc)
{
  return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc));
}
 

float MQCalibration(int mq_pin)
{
  int i;
  float val=0;

  for (i=0;i<CALIBARAION_SAMPLE_TIMES;i++) {            //take multiple samples
    val += MQResistanceCalculation(analogRead(mq_pin));
    delay(CALIBRATION_SAMPLE_INTERVAL);
  }
  val = val/CALIBARAION_SAMPLE_TIMES;                   //calculate the average value
  val = val/RO_CLEAN_AIR_FACTOR;                        //divided by RO_CLEAN_AIR_FACTOR yields the Ro                                        
  return val;                                                      //according to the chart in the datasheet 

}
 

float MQRead(int mq_pin)
{
  int i;
  float rs=0;
 
  for (i=0;i<READ_SAMPLE_TIMES;i++) {
    rs += MQResistanceCalculation(analogRead(mq_pin));
    delay(READ_SAMPLE_INTERVAL);
  }
 
  rs = rs/READ_SAMPLE_TIMES;
 
  return rs;  
}
 

long MQGetGasPercentage(float rs_ro_ratio, int gas_id)
{
  if ( gas_id == GAS_LPG ) {
     return MQGetPercentage(rs_ro_ratio,LPGCurve);
  }
 
  return 0;
}
 

long  MQGetPercentage(float rs_ro_ratio, float *pcurve)
{
  return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0])));
}

So, what error messages do you get with that code?

Gas_sensor_reeedit:70: error: 'MQCalibration' was not declared in this scope

Ro = MQCalibration(MQ_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air

^

C:\Users\User\Documents\Arduino\Gas_sensor_reeedit\Gas_sensor_reeedit.ino: In function 'void loop()':

Gas_sensor_reeedit:87: error: 'MQRead' was not declared in this scope

iPPM_LPG = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG);

^

Gas_sensor_reeedit:87: error: 'MQGetGasPercentage' was not declared in this scope

iPPM_LPG = MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG);

^

C:\Users\User\Documents\Arduino\Gas_sensor_reeedit\Gas_sensor_reeedit.ino: In function 'long int MQGetGasPercentage(float, int)':

Gas_sensor_reeedit:190: error: 'MQGetPercentage' was not declared in this scope

return MQGetPercentage(rs_ro_ratio,LPGCurve);

^

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

These is the error code

I don't have the LiquidCrystal.h library. So, I deleted everything lcd-related and it compiled fine for me.
Board: NodeMCU 0.9 and NodeMCU 1.0
Arduino IDE: 1.8.5

But I would like to have LCD and IoT both in my project, how? :frowning:

Mr. gfvalvo, i tried deleted everything lcd-related , but the MQCalibration still is the problem,
May I know the coding compiled fine for u ?

VincentNg3120:
But I would like to have LCD and IoT both in my project, how? :frowning:

The LCD library is completely irrelevant. I just don’t have it installed. So, I removed it from the code to prevent errors.

You may have a non-printing garbage character in your code that the forum software filtered out for me. Try this:

  • In the Arduino IDE, select File --> New

  • In the new window that opens, select ALL the text and delete it. You should now have a completely blank sketch window.

  • Go to the code scroll box in your Reply #5 and click [Select] at the top.

  • Copy / Paste the code into your blank IDE window.

  • Save / Verify