actually my sendData(); function not work its in only black color not come this code in red color so what can i do and also client.setInsecure(); this also
Hello, do yourself a favour and please read How to get the best out of this forum and post accordingly (including source code using code tags and necessary documentation for your ask).
sendData not work properly also void sendData also
#include <WiFi.h>
#include <WiFiClient.h>
#include <HttpClient.h>
#include <WiFiClientSecure.h>
const char* ssid = "ASUS";
const char* password = "xxxxx";
const char* host = "script.google.com";
const int httpsPort = 443;
String GAS_ID = "AKfycbzqJKDZOHrhxxxxxxxxxxx5iYhKqEOpsqM9zd3jAR5Vk-9";
void setup() {
pinMode(2, OUTPUT);
Serial.begin(115200);
Serial.print("connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
digitalWrite(2, LOW);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
digitalWrite(2, HIGH);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
int a,b,c;
a = 100;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
return(setup());
}
String reading = "Weight : " + String(a) + " kg";
delay(5000);
Serial.println(reading);
sendData(a); // this function not work properly also void sendData also
}
void sendData (int a){
HttpClient client;
Serial.print("connecting to ");
Serial.println(host);
//String url = "/macros/s/" + GAS_ID + "/exec?Weight=" + a;
String url= "script.google.com/macros/s/AKfycbypcBZxuahU5OHGZxxxxxxxxxxxxxxbU3yOLiVnD-dwMv_cjlbcj3M2RTinss/exec?Weight=" + a;
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: BuildFailureDetectorESP8266\r\n" +
"Connection: close\r\n\r\n");
while (client) {
String line = client.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}
String line = client.readStringUntil('\n');
if (line.startsWith("{\"state\":\"success\"")) {
Serial.println("esp8266/Arduino CI successfull!");
} else {
Serial.println("esp8266/Arduino CI has failed");
}
Serial.print("reply was : ");
Serial.println(line);
Serial.println("closing connection");
Serial.println("==========");
Serial.println();
}
I moved your new topic here. Don't double post / create more topics for your question. Keep everything in one thread.
PLEASE read How to get the best out of this forum
Are you using an ESP32? It looks like the libraries have changed. For example "HttpClient" is now "HTTPClient".
Start over with File -> Examples -> ESP32 -> HTTPClient -> BasicHttpClient
ok sir i have proper in httpclient libraries but sendData function not enable why? can you help me
Did you "Start over with File -> Examples -> ESP32 -> HTTPClient -> BasicHttpClient"?
thank you john now its working i started from basic its good now
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.