Web client with arduino uno+esp8266

Hi,
I found a code for a web client and when I load this program to my arduino and esp8266 don’t get a reply from the website from my get request.
This is my 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 8/9 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(8, 9); // RX, TX
#endif

char ssid[] = "waterfill";            // your network SSID (name)
char pass[] = "waterfill08";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "api.pushingbox.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.connect(server, 80)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("GET /pushingbox?devid=v0DC35307E3AE991");
    client.print("&a=");
    client.print(String(20));
    client.print("&b=");
    client.print(String(10));
    client.println(" HTTP/1.1");
    client.println("Host: api.pushingbox.com");
    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");
}

I use that code then cannot send my data to pushingbox
in serial monitor show up like this


[WiFiEsp] Initializing ESP module
[WiFiEsp] Initilization successful - 1.5.4
Attempting to connect to WPA SSID: waterfill
[WiFiEsp] Connected to waterfill
You're connected to the network
SSID: waterfill
IP Address: 192.168.8.103
Signal strength (RSSI):-422 dBm

Starting connection to server...
[WiFiEsp] Connecting to api.pushingbox.com
Connected to server
[WiFiEsp] Data packet send error (2)
[WiFiEsp] Failed to write to socket 3
[WiFiEsp] Disconnecting  3

Disconnecting from server...

Do you see anything at all in the serial monitor (at 115200 bauds)?

in serial monitor like this

[WiFiEsp] Initializing ESP module
[WiFiEsp] Initilization successful - 1.5.4
Attempting to connect to WPA SSID: waterfill
[WiFiEsp] Connected to waterfill
You're connected to the network
SSID: waterfill
IP Address: 192.168.8.103
Signal strength (RSSI):-482 dBm

Starting connection to server...
[WiFiEsp] Connecting to api.pushingbox.com
Connected to server
[WiFiEsp] Data packet send error (2)
[WiFiEsp] Failed to write to socket 3
[WiFiEsp] Disconnecting 3

Disconnecting from server...

so that is the WiFiEsp library. always having problems with timing.
if you update the AT firmware, you could use my WiFiEspAT library, which is much better.
and instead of the official AT firmware you can use ESP_ATMod sketch in the esp8266 if you don't need UDP.

That’s what you need to investigate

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.