Request for member print in 1 which is of non class type int

I am trying to connect my ESP8266 to internet server through Arduino Mega and it is throwing this error

code:-

boolean setup_ESP(){//returns a '1' if successful
  
  ESP8266.print("AT\r\n");// Send just 'AT' to make sure the ESP is responding
  //this read_until_... function is used to find a keyword in the ESP response - more on this later and in the function itself
  if(read_until_ESP(keyword_OK,sizeof(keyword_OK),5000,0))//go look for keyword "OK" with a 5sec timeout
    Serial.println("ESP CHECK OK");
  else
    Serial.println("ESP CHECK FAILED");
  serial_dump_ESP();//this just reads everything in the buffer and what's still coming from the ESP

   ESP8266.print("AT+RST\r\n");// Give it a reset - who knows what condition it was in, better to start fresh
  if(read_until_ESP(keyword_OK,sizeof(keyword_OK),5000,0))//go look for keyword "Ready" - takes a few seconds longer to complete
    Serial.println("ESP RESET OK");//depneding on the FW version on the ESP, sometimes the Ready is with a lowercase r - ready
  else
    Serial.println("ESP RESET FAILED"); 
  serial_dump_ESP();

  
   ESP8266.print("AT+CWMODE=");// set the CWMODE
   ESP8266.print(CWMODE);//just send what is set in the constant
   ESP8266.print("\r\n");
  if(read_until_ESP(keyword_OK,sizeof(keyword_OK),5000,0))//go look for keyword "OK"
    Serial.println("ESP CWMODE SET");
  else
    Serial.println("ESP CWMODE SET FAILED"); //probably going to fail, since a 'no change' is returned if already set - would be nice to check for two words
  serial_dump_ESP();  
   
   //Here's where the SSID and PW are set
   ESP8266.print("AT+CWJAP=\"");// set the SSID AT+CWJAP="SSID","PW"
   ESP8266.print(SSID_ESP);//from constant 
   ESP8266.print("\",\"");
   ESP8266.print(SSID_KEY);//form constant
   ESP8266.print("\"\r\n");
  if(read_until_ESP(keyword_OK,sizeof(keyword_OK),10000,0))//go look for keyword "OK"
    Serial.println("ESP SSID SET OK");
  else
    Serial.println("ESP SSID SET FAILED");   
  serial_dump_ESP();
  
  //This checks for and stores the IP address
  Serial.println("CHECKING FOR AN IP ADDRESS");
  ESP8266.print("AT+CIFSR\r\n");//command to retrieve IP address from ESP
  if(read_until_ESP(keyword_rn,sizeof(keyword_rn),10000,0)){//look for first \r\n after AT+CIFSR echo - note mode is '0', the ip address is right after this
  if(read_until_ESP(keyword_rn,sizeof(keyword_rn),1000,1)){//look for second \r\n, and store everything it receives, mode='1'
    //store the ip adress in its variable, ip_address[]
    for(int i=1; i<=(scratch_data_from_ESP[0]-sizeof(keyword_rn)+1); i++)//that i<=... is going to take some explaining, see next lines
       ip_address[i] = scratch_data_from_ESP[i];//fill up ip_address with the scratch data received
//i=1 because i=0 is the length of the data found between the two keywords, BUT this includes the length of the second keyword, so i<= to the length minus
//size of teh keyword, but remember, sizeof() will return one extra, which is going to be subtracted, so I just added it back in +1
    ip_address[0] = (scratch_data_from_ESP[0]-sizeof(keyword_rn)+1);//store the length of ip_address in [0], same thing as before
    Serial.print("IP ADDRESS = ");//print it off to verify
    for(int i=1; i<=ip_address[0]; i++)//send out the ip address
    Serial.print(ip_address[i]);
    Serial.println("");
  }}//if first \r\n
  else
  Serial.print("IP ADDRESS FAIL");
  serial_dump_ESP();

 
   ESP8266.print("AT+CIPMUX=");// set the CIPMUX
   ESP8266.print(CIPMUX);//from constant
  if(read_until_ESP(keyword_OK,sizeof(keyword_OK),5000,0))//go look for keyword "OK" or "no change
    Serial.println("ESP CIPMUX SET");
  else
    Serial.println("ESP CIPMUX SET FAILED"); 
  serial_dump_ESP();


 

 //that's it!  Could be done by nesting everything together, so if one thing fails, it returns '0', and if it gets all the way through it returns '1'...oh well
  
  
}//setup ESP

This is the compiler's error:

Error:-
Arduino: 1.8.14 Hourly Build 2021/04/08 03:25 (Linux), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"









WARNING: library LiquidCrystal_I2C claims to run on avr architecture(s) and may be incompatible with your current board which runs on esp8266 architecture(s).
<command-line>: error: expected unqualified-id before numeric constant
/home/udit/Desktop/HomeAutomationSystem/ESP_tutorial/MAIN_ESP8266/MAIN_ESP8266.ino:148:16: note: in expansion of macro 'ESP8266'
  148 | SoftwareSerial ESP8266(ESP8266_RX, ESP8266_TX);// rx tx
      |                ^~~~~~~
/home/udit/Desktop/HomeAutomationSystem/ESP_tutorial/MAIN_ESP8266/connect_ESP.ino: In function 'boolean connect_ESP()':
connect_ESP:7:11: error: request for member 'print' in '1', which is of non-class type 'int'
    7 |   ESP8266.print("AT+CIPSTART=0,\"TCP\",\"www.homiecube.000webhostapp.com\",80\r\n");//connect to your web server
      |           ^~~~~
connect_ESP:14:11: error: request for member 'print' in '1', which is of non-class type 'int'
   14 |   ESP8266.print("AT+CIPSEND=0,");//send AT+CIPSEND=0, size of payload
      |           ^~~~~
connect_ESP:15:11: error: request for member 'print' in '1', which is of non-class type 'int'
   15 |   ESP8266.print(payload_size);//the payload size
      |           ^~~~~
connect_ESP:17:11: error: request for member 'print' in '1', which is of non-class type 'int'
   17 |   ESP8266.print("\r\n\r\n");//cap off that command with a carriage return and new line feed
      |           ^~~~~
connect_ESP:26:13: error: request for member 'print' in '1', which is of non-class type 'int'
   26 |     ESP8266.print(payload[i]);
      |             ^~~~~
/home/udit/Desktop/HomeAutomationSystem/ESP_tutorial/MAIN_ESP8266/read_until_ESP.ino: In function 'boolean read_until_ESP(const char*, int, int, byte)':
read_until_ESP:18:28: error: request for member 'available' in '1', which is of non-class type 'int'
   18 |             while(!ESP8266.available()){//wait until a new byte is sent down from the ESP - good way to keep in lock-step with the serial port
      |                            ^~~~~~~~~
read_until_ESP:25:24: error: request for member 'read' in '1', which is of non-class type 'int'
   25 |     data_in[i]=ESP8266.read();// save the byte to the buffer 'data_in[]
      |                        ^~~~
read_until_ESP:56:28: error: request for member 'available' in '1', which is of non-class type 'int'
   56 |             while(!ESP8266.available()){// same thing as done in the buffer
      |                            ^~~~~~~~~
read_until_ESP:65:33: error: request for member 'read' in '1', which is of non-class type 'int'
   65 |     data_in[key_size-1]=ESP8266.read();//save the new data in the last position in the buffer
      |                                 ^~~~
/home/udit/Desktop/HomeAutomationSystem/ESP_tutorial/MAIN_ESP8266/serial_dump_ESP.ino: In function 'void serial_dump_ESP()':
serial_dump_ESP:5:17: error: request for member 'available' in '1', which is of non-class type 'int'
    5 |   while(ESP8266.available()){
      |                 ^~~~~~~~~
serial_dump_ESP:6:19: error: request for member 'read' in '1', which is of non-class type 'int'
    6 |     temp =ESP8266.read();
      |                   ^~~~
/home/udit/Desktop/HomeAutomationSystem/ESP_tutorial/MAIN_ESP8266/setup_ESP.ino: In function 'boolean setup_ESP()':
setup_ESP:3:11: error: request for member 'print' in '1', which is of non-class type 'int'
    3 |   ESP8266.print("AT\r\n");// Send just 'AT' to make sure the ESP is responding
      |           ^~~~~
setup_ESP:11:12: error: request for member 'print' in '1', which is of non-class type 'int'
   11 |    ESP8266.print("AT+RST\r\n");// Give it a reset - who knows what condition it was in, better to start fresh
      |            ^~~~~
setup_ESP:19:12: error: request for member 'print' in '1', which is of non-class type 'int'
   19 |    ESP8266.print("AT+CWMODE=");// set the CWMODE
      |            ^~~~~
setup_ESP:20:12: error: request for member 'print' in '1', which is of non-class type 'int'
   20 |    ESP8266.print(CWMODE);//just send what is set in the constant
      |            ^~~~~
setup_ESP:21:12: error: request for member 'print' in '1', which is of non-class type 'int'
   21 |    ESP8266.print("\r\n");
      |            ^~~~~
setup_ESP:29:12: error: request for member 'print' in '1', which is of non-class type 'int'
   29 |    ESP8266.print("AT+CWJAP=\"");// set the SSID AT+CWJAP="SSID","PW"
      |            ^~~~~
setup_ESP:30:12: error: request for member 'print' in '1', which is of non-class type 'int'
   30 |    ESP8266.print(SSID_ESP);//from constant
      |            ^~~~~
setup_ESP:31:12: error: request for member 'print' in '1', which is of non-class type 'int'
   31 |    ESP8266.print("\",\"");
      |            ^~~~~
setup_ESP:32:12: error: request for member 'print' in '1', which is of non-class type 'int'
   32 |    ESP8266.print(SSID_KEY);//form constant
      |            ^~~~~
setup_ESP:33:12: error: request for member 'print' in '1', which is of non-class type 'int'
   33 |    ESP8266.print("\"\r\n");
      |            ^~~~~
setup_ESP:42:11: error: request for member 'print' in '1', which is of non-class type 'int'
   42 |   ESP8266.print("AT+CIFSR\r\n");//command to retrieve IP address from ESP
      |           ^~~~~
setup_ESP:61:12: error: request for member 'print' in '1', which is of non-class type 'int'
   61 |    ESP8266.print("AT+CIPMUX=");// set the CIPMUX
      |            ^~~~~
setup_ESP:62:12: error: request for member 'print' in '1', which is of non-class type 'int'
   62 |    ESP8266.print(CIPMUX);//from constant
      |            ^~~~~
exit status 1
request for member 'print' in '1', which is of non-class type 'int'


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

Hello,

do you have a question?

do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including necessary documentation for your ask + formatting the post correctly).

You are compiling the sketch for an ESP8266, do not use ESP8266 as the name of the SoftwareSerial object because the board files for the ESP8266 have a conflicting use of that name.

Presumably the sketch is NOT intended to run on the ESP8266, but on another board that communicates with the ESP8266 over serial.

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Sure i will do it

The code is written for ESP8266

what can be the solution?

Are you sure about that? It is really odd to be sending AT commands to an ESP8266 from a 2nd ESP8266. Where did you get the code, can you post a link?

Please fix post 1... separate code from compiler error (using code tags), provide an introduction to your problem (what you use etc)

then we can discuss.

I did it

so #3 is the answer to the question you did not ask