GET Request Mega/ESP8266-12F Issue

So the issue is that while it does connect, sends the request it only gets a partial response and then times out. Not quite sure why this is.

#include <WiFiEsp.h>



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

WiFiEspClient client;

char server[] = "*******";

void setup() {


Serial.begin(115200);                                     // initialize serial 0 for debugging
Serial1.begin(115200);                                    // initialize serial 1 for ESP module
WiFi.init(&Serial1);                                      // initialize ESP module
if (WiFi.status() == WL_NO_SHIELD) {                      // check for the presence of the shield
Serial.println("WiFi shield not present");              // If shield not present, don't continue
while (true);
}
while ( status != WL_CONNECTED) {                         // attempt to connect to WiFi network
Serial.print("Attempting to connect to WPA SSID: ");    // Print message to serial monitor
Serial.println(ssid);                                   // Print SSID to serial monitor
status = WiFi.begin(ssid, pass);                        // Connect to WPA/WPA2 network
}
Serial.println("You're connected to the network");
Serial.println();

Serial.println("Starting connection to server...");

if (client.connect(server, 80)) {
Serial.println("Connected to server");
// Make a HTTP request
client.println("GET /KB_Pool_Pump/getCurrentStatus.php HTTP/1.1");
client.println("Host: www.radproducts.me");
client.println("Accept: */*");
char c = client.read();
Serial.write(c);
client.println("Connection: close");
client.println();
}

}

void loop() {

while (client.available()) {
Serial.println("Begin printing data...");
char c = client.read();
Serial.println(c);
}

Serial.println("Finished Reading Data...");


delay(120000);
}


void printWifiStatus()
{

Serial.print("SSID: ");
Serial.println(WiFi.SSID());


IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);


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

This is the output

HTTP/1.1 200 OK Date: Tue, 12 Ju[WiFiEsp] TIMEOUT: 204

I've seen some things about people saying they needed to change the BAUD rate but I'm not sure how to do that without buying additional parts (which I don't want to do if I can avoid it) so if that is the case that I need to change it to 9600 instead of the 115200 then if someone could point me in the right direction as to how to change the BAUD rate with AT commands straight from the board that would be awesome.

my WiFiEspAT library is better, because it uses features of newer AT firmware versions.
so if you can update to AT 2.7.5 (SDK 3.0.5), use WiFiEspAT library

https://github.com/JAndrassy/WiFiEspAT#Why-a-new-wifiesp-library

I can't seem to run these on a Mega. Is this what you mean by update to AT 2.7.5? Can you elaborate further on that?

When I attempt to use either the Tools or a basic sketch I get these errors.

C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp: In member function 'IPAddress WiFiClient::remoteIP()':
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp:168:68: error: no matching function for call to 'EspAtDrvClass::remoteParamsQuery(uint8_t, IPAddress&, uint16_t&, uint16_t&)'
     EspAtDrv.remoteParamsQuery(stream->getLinkId(), ip, port, lport);
                                                                    ^
In file included from C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp:20:0:
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\utility/EspAtDrv.h:98:8: note: candidate: bool EspAtDrvClass::remoteParamsQuery(uint8_t, IPAddress&, uint16_t&)
   bool remoteParamsQuery(uint8_t linkId, IPAddress& remoteIP, uint16_t& remoteParamsQuery);
        ^~~~~~~~~~~~~~~~~
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\utility/EspAtDrv.h:98:8: note:   candidate expects 3 arguments, 4 provided
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp: In member function 'uint16_t WiFiClient::remotePort()':
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp:178:68: error: no matching function for call to 'EspAtDrvClass::remoteParamsQuery(uint8_t, IPAddress&, uint16_t&, uint16_t&)'
     EspAtDrv.remoteParamsQuery(stream->getLinkId(), ip, port, lport);
                                                                    ^
In file included from C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp:20:0:
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\utility/EspAtDrv.h:98:8: note: candidate: bool EspAtDrvClass::remoteParamsQuery(uint8_t, IPAddress&, uint16_t&)
   bool remoteParamsQuery(uint8_t linkId, IPAddress& remoteIP, uint16_t& remoteParamsQuery);
        ^~~~~~~~~~~~~~~~~
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\utility/EspAtDrv.h:98:8: note:   candidate expects 3 arguments, 4 provided
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp: At global scope:
C:\Users\Owner\Documents\Arduino\libraries\WiFiEspAT\src\WiFiClient (2).cpp:183:32: error: no 'uint16_t WiFiClient::localPort()' member function declared in class 'WiFiClient'
 uint16_t WiFiClient::localPort() {
                                ^
exit status 1
Error compiling for board Arduino Mega or Mega 2560.

did you install it from Library Manager?

it looks like ho have library's source files from different versions of the library

Ah, I did not! I thought I could just grab the Git and move it into libraries and roll, guess it also installs some dependencies when doing it through the Manager?

Well I was able to upload ect. now but I am getting the "Communication with WiFi module failed" message.

Since my current hook up works with the other library, presumably I have it wired correctly, yes?

I have it on a Mega in the 18/19 ports so I removed the If/Else statement to select a BAUD rate and just left this

#define AT_BAUD_RATE 115200

But no go with that. Any thoughts?

did you try the CheckFirmware sketch?

for Serial3?

I tried this one and it just tells me the communication fails.

/*
  This sketch checks the version of the AT firmware in attached esp8266.

  created in Jul 2019 for WiFiEspAT library
  by Juraj Andrassy https://github.com/jandrassy

*/

#include <WiFiEspAT.h>

#define AT_BAUD_RATE 115200

void setup() {

  Serial.begin(115200);
  while (!Serial);

  Serial1.begin(AT_BAUD_RATE);
  WiFi.init(Serial1);

  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  char ver[10];
  int major = 0;
  int minor = 0;
  if (WiFi.firmwareVersion(ver)) {
    Serial.print("AT firmware version ");
    Serial.println(ver);
    char* tok = strtok(ver, ".");
    major = atoi(tok);
    tok = strtok(NULL, ".");
    minor = atoi(tok);
    if (major == 2 && minor == 0) {
      Serial.println("AT firmware version 2.0 doesn't support passive receive mode and can't be used with the WiFiEspAt library");
    } else if (major < 1 || (major == 1 && minor < 7)) {
      Serial.println("WiWiEspAT library requires at least version 1.7.0 of AT firmware (but not 2.0)");
    } else {
      Serial.println("AT firmware is OK for the WiFiEspAT library.");
#ifdef WIFIESPAT1
      if (major > 1) {
        Serial.println("For AT firmware version 2 comment out #define WIFIESPAT1 in EspAtDrvTypes.h");
      }
#else
      if (major == 1) {
        Serial.println("For AT firmware version 1 add #define WIFIESPAT1 in EspAtDrvTypes.h");
      }
#endif
    }
  } else {
    Serial.println("Error getting AT firmware version");
  }


}

void loop() {
}

Not sure what you mean by Serial3 :smiley:

sorry, pins 18 amd 19 are Serial1

you could try to turn on logging to see the communication with the AT firmware.
https://github.com/JAndrassy/WiFiEspAT#logging

Words, lots of words haha.

esp INFO: soft reset
esp> AT+RST ...sent
esp>p>   SPI Fl32Mbit(51p to run user1 @ 1000 ...ignored
esp INFO: soft reset
esp> AT+RST ...sent
esp> AT+RST ...ignored
esp> OK ...ignored
esp>  ets Jan  8 2013,rst cause:2, boot mode:(3,7) ...ignored
esp> load 0x40100000, len 2408, room 16  ...ignored
esp> tail 8 ...ignored
esp> chksum 0xe5 ...ignored
esp> load 0x3ffe8000, len 776, room 0  ...ignored
esp> tail 8 ...ignored
esp> chksum 0x84 ...ignored
esp> load 0x3ffe8310, len 632, room 0  ...ignored
esp> tail 8 ...ignored
esp> chksum 0xd8 ...ignored
esp> csum 0x ...ignored
esp> 2nd boot version : 1.6 ...ignored
esp>   SPI SHz ...ignored
esp>   SPQIO ...ignored
esp>   SPI Fl32Mbit(51p to run user1 @ 1000 ...ignored
esp> ⸮⸮⸮⸮n⸮r⸮⸮n|⸮ll⸮l⸮⸮s⸮l⸮l⸮l`⸮⸮s⸮l⸮l⸮l`⸮⸮r⸮l⸮⸮ ...ignored
esp> ll`sl⸮⸮rl⸮⸮⸮b⸮⸮b⸮bcs⸮sb⸮⸮n⸮on⸮l⸮⸮l⸮l⸮⸮ll⸮ ...ignored
esp> ⸮⸮⸮⸮⸮l⸮n⸮ ...ignored
esp> ready ...matched
esp> ATE0 ...sent
esp> ATE0 ...ignored
esp> OK ...matched
esp> AT+CIPMUX=1 ...sent
esp> OK ...matched
esp> AT+CIPRECVMODE=1 ...sent
esp> ERROR ...error
esp ERROR: expected OK got ERROR
WiFi shield not present

old AT firmware. it doesn't have the new command AT+CIPRECVMODE

Is there anyway I can update it through an Arduino without buying some kind of boot loader or something?

if you upload the SerialPassthrough example (wit baud rate changed to 115200), it will bridge the esp to computer.
for the esp to go into flashing mode io 0 of the eesp8266 must be LOW at reset or power-up.

you can download the SDK with the AT firmware here https://github.com/espressif/ESP8266_NONOS_SDK/releases

the upload command is

esptool.py write_flash --flash_size 2MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin

you may have to install esptool.py https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html

Well, hopefully I don't blow anything up! I'll give it a shot haha. Never flashed anything before but we'll see.

Thanks for all the help thus far!

Can you break down this a bit for me by chance?

Not sure what I need here.

// Emulate Serial1 on pins 6/7 if not present
#if defined(ARDUINO_ARCH_AVR) && !defined(HAVE_HWSERIAL1)
#include "SoftwareSerial.h"
SoftwareSerial SerialAT(6, 7); // RX, TX
#define AT_BAUD_RATE 9600
#elif defined(ARDUINO_ARCH_SAMD) && defined(SAMD_FLOW_CONTROL)
#include "wiring_private.h"
Uart SerialAT(&sercom3, 0, 1, SERCOM_RX_PAD_1, UART_TX_PAD_0, 2, 255);
#define AT_BAUD_RATE 115200
#else
#define SerialAT Serial1
#define AT_BAUD_RATE 115200
#endif

Here is a very rough demonstration of my wiring. Are you saying I need to remove the Enable pin while flashing?

So I removed the D0 and uploaded the sketch and then after powering up I pressed the RESET button the ESP and on the serial monitor I got a LONG string following by a "ready" but then typing AT for a test it errors out. Image of output shown below, the long string of illegal characters is about 3-5x as long as shown below.

sorry, I meant the SerialPassthrough basic example from IDE Examples menu. but this one will work too.

the unreadable part is the boot log at a different baud rate. it is not important.

when io 0 is wired to ground, AT firmware shouldn't start.

IO 0 (I assume you mean the ENABLE one from my example schematic) is generally wired to +3.3V

I removed it for now, but I get that "ERROR" when I type AT. Is that normal?

So this is my current wiring, when I get the ERROR message

io 0 is labeled GPIO 0

Okay, I got you now.

So this will be my wiring now. I'll get Python installed and flash it tomorrow and we'll see how it goes!