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
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.
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
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() {
}
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.
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.