HttpClient
HttpClient copied to clipboard
http post request using node mcu
pls anyone help me out to resolve this error i tried to upload the following code
#include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266HTTPClient.h> const char* ssid = "vathsal"; const char* password = "1234567890";
void setup() { // put your setup code here, to run once: Serial.begin(9600); WiFi.begin(ssid,password); }
void loop() { // put your main code here, to run repeatedly:
if((WiFi.status() == WL_CONNECTED))
{
HTTPClient http;
http.begin("http://wwwkprstaffcom.000webhostapp.com/index.php/iot projecthtml.php");
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
int httpcode = http.POST("$_var=helloooo");
http.addHeader("Content-Type", "text/plain"); //Specify content-type header
String payload = http.getString();
Serial.println(httpcode);
Serial.println(payload);
http.end();
}
else{
Serial.println("error in wifi connection");
}
}
AND THEN I FOUND THE FOLLOWING ERRORS
Arduino: 1.8.6 Hourly Build 2018/01/03 03:33 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 9600"
Archiving built core (caching) in: C:\Users\Laptop\AppData\Local\Temp\arduino_cache_262920\core\core_esp8266_esp8266_nodemcuv2_CpuFrequency_80,FlashSize_4M1M,LwIPVariant_v2mss536,Debug_Disabled,DebugLevel_None____,UploadSpeed_9600_07078c7af7bb3a9954a4bdc91c11f92d.a Sketch uses 266887 bytes (25%) of program storage space. Maximum is 1044464 bytes. Global variables use 34216 bytes (41%) of dynamic memory, leaving 47704 bytes for local variables. Maximum is 81920 bytes. Uploading 271040 bytes from C:\Users\Laptop\AppData\Local\Temp\arduino_build_47295/basic_iot_3.ino.bin to flash at 0x00000000 ................................................................................ [ 30% ] ................................................................................ [ 60% ] ................................................................................ [ 90% ] .....................An error occurred while uploading the sketch
This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.