#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
const char *ssid = "HUAWEI NOVA 5T";
const char *password = "0169437326";
String tempValue;
int analogValue;
int tempPin = A0;
float miliVolts;
float celcius;
String postData;
int httpCode;
String payload;
void setup(){
delay(1000);
Serial.begin(115200);
WiFi.begin(ssid,password);
Serial.println("");
Serial.println("Connecting");
while(WiFi.status()!= WL_CONNECTED){
delay(500);
Serial.println(".");
}
Serial.println("");
Serial.println("connected to");
Serial.println(ssid);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop(){
delay(5000);
analogValue = analogRead(tempPin);
miliVolts = (analogValue/1024.0)*3000;
celcius = miliVolts/10;
tempValue = String(celcius);
Serial.println(tempValue);
HTTPClient http;
postData = "tempValue=" +tempValue;
http.begin("http://192.168.43.224/dbInsert.php");
http.addHeader("Content-Type","application/x-www-form-urlencoded");
httpCode =http.POST(postData);
payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
http.end();
}
(the status always appear even i change the coding can help me to define the problem)
pratceiot:47:11: error: call to 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, url)
47 | http.begin("http://192.168.43.224/dbInsert.php");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^