Hi, thanks for reading my post ![]()
I'm using a Wemos D1 Mini / ESP8266 board to perform an HTTP GET to mu local server.
My code works although I am getting a compilation warning.. I have changed the http.begin() call to include the WiFi client but then the code fails. Here is the warning message :
WiFi_test.ino:37:27: warning: 'bool HTTPClient::begin(String)' is deprecated (declared at C:\Users\user\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:174) [-Wdeprecated-declarations]
  if ( http.begin( Buffer ) )
I suspect I have the wrong combination of libraries ? - can anyone please advise of what the issue may be ? Here is the complete app.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#define BUTTON_PINÂ 0
void setup()
{
 Serial.begin( 38400 );
 pinMode( BUTTON_PIN, INPUT_PULLUP );
}
void loop()
{
 char    Buffer[64];
 WiFiClient Client;
 HTTPClient http;
 Serial.println("Starting...");
 WiFi.mode(WIFI_STA);
 WiFi.begin( "VM2293456", "******" );
 while ( WiFi.status() != WL_CONNECTED )
  delay( 50 );
 Serial.println("Ready...");
 while ( digitalRead( BUTTON_PIN ) == HIGH )
  delay( 50 );
 strcpy( Buffer, "http://192.168.0.47/writelog.php?" );
 strcat( Buffer, "Source=Arduino" );
 strcat( Buffer, "&LogType=1" );
 strcat( Buffer, "&LogText=Button%20Pressed" );
 if ( http.begin( Buffer ) )
 {
  int httpRetCode = http.GET();
  http.end();
  if ( httpRetCode == HTTP_CODE_OK )
  {
   Serial.println( "GET sent OK" );
  }
  else
  {
   Serial.print( "Bad Request. httpRetCode = " );
   Serial.println( httpRetCode );
  }
 }
 else
 {
  Serial.print( "http.begin() failed" );
 }
 delay(5000);
}
I press the button connect to the device and see that the GET works ( confirmed on server ), but I get an exception message some time later on the device.
Thanks