1

Hello I am trying to make a request using WiFiEsp library but even the examples not working, I have searched a lot but never solved it. most of the solutions are outdated and do not solve anything, I am using Arduino Mega 2560 and ESP8266 the problem as shown in the log is that it's not connected to google.com and I have tried my APIs and I got the same response.

code:

/*
 WiFiEsp example: WebClient

 This sketch connects to google website using an ESP8266 module to
 perform a simple web search.

 For more details see: http://yaab-arduino.blogspot.com/p/wifiesp-example-client.html
*/

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7);  // RX, TX
#endif
char ssid[] = "IOT";          // name
char pass[] = "60606060";     // password
int status = WL_IDLE_STATUS;  // the Wifi radio's status

char server[] = "www.google.com";

// Initialize the Ethernet client object
WiFiEspClient client;

void setup() {
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true)
      ;
  }

  // attempt to connect to WiFi network
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");

  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  // if you get a connection, report back via serial
  if (client.connectSSL(server, 443)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("GET / HTTP/1.1");
    delay(100);
    client.println("Host: www.google.com");
    delay(100);

    client.println("Connection: close");
    delay(100);

    client.println();
  }
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true)
      ;
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

and this is the log

23:21:51.468 -> ----------------------------------------------
23:21:51.468 -> >> AT+CIFSR
23:21:51.533 -> +CIFSR:STAIP,"192.168.1.4"
23:21:51.533 -> +CIFSR:STAMAC,"e8:db:84:df:8b:46"
23:21:51.575 -> 
23:21:51.575 -> OK
23:21:51.575 -> ---------------------------------------------- > 192.168.1.4!h=
23:21:51.575 -> 
23:21:51.575 -> IP Address: 192.168.1.4
23:21:51.575 -> > getCurrentRSSI
23:21:51.575 -> ----------------------------------------------
23:21:51.575 -> >> AT+CWJAP?
23:21:51.607 -> +CWJAP:"IOT","b4:f5:8e:b5:2f:d9",1,-51
23:21:51.653 -> 
23:21:51.653 -> OK
23:21:51.653 -> ---------------------------------------------- > 512
23:21:51.653 -> 
23:21:51.653 -> Signal strength (RSSI):-512 dBm
23:21:51.653 -> 
23:21:51.653 -> Starting connection to server...
23:21:51.653 -> [WiFiEsp] Connecting to www.google.com
23:21:51.653 -> > startClient www.google.com 443
23:21:51.653 -> ----------------------------------------------
23:21:51.653 -> >> AT+CIPSSLSIZE=4096
23:21:51.700 -> 
23:21:51.700 -> OK
23:21:51.700 -> ---------------------------------------------- > 0
23:21:51.700 -> 
23:21:51.700 -> ----------------------------------------------
23:21:51.700 -> >> AT+CIPSTART=3,"SSL","www.google.com",443
23:21:52.018 -> 
23:21:52.018 -> ERROR
23:21:52.018 -> ---------------------------------------------- > 1
23:21:52.018 -> 
23:21:52.018 -> > getClientState 3
23:21:52.018 -> ----------------------------------------------
23:21:52.050 -> >> AT+CIPSTATUS
23:21:52.050 -> 3,CLOSED
23:21:52.050 -> STATUS:4
23:21:52.050 -> 
23:21:52.050 -> OK
23:21:52.050 -> No start tag found: 0
23:21:52.050 -> ---------------------------------------------- > 
23:21:52.092 -> 
23:21:52.092 -> Not connected
23:21:52.092 -> 
23:21:52.092 -> Disconnecting from server...
1
  • AT firmware doesn't support TLS 1.3 encryption used by most sites now.. try Jiri Bilek's 'fake' AT firmware github.com/JiriBilek/ESP_ATMod Best with my WiFiEspAT library
    – Juraj
    Commented Dec 30, 2023 at 6:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.