yes it does work on link but not when i try to push it in the arduino sideÂ
The link is the GET format, where as your code is using the POST format.
Maybe you have to start over, try this code.
It only sets the switch to ON every 10 seconds, up to you to add the relay code mlater, once this works,
Test is with state=0 as well - to make sure it works, before adding the relay functions in it.
This is code from the link I previous gave you (paragraph called "Code ESP8266 HTTP GET with Arduino IDE"), just slightly adjust for the links and parameters you gave me in your previous post.
#include < ESP8266WiFi.h >
#include < ESP8266HTTPClient.h >
#include < WiFiClient.h >
const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";
//Your Domain name with URL path or IP address with path
String serverName = "http://zeint.net/IOT/esp-outputs-action.php";
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.");
}
void loop() {
//Send an HTTP POST request every 10 minutes
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
String serverPath = serverName + "action=output_update&id=8&state=1";
// Your Domain name with URL path or IP address with path
http.begin(serverPath.c_str());
// Send HTTP GET request
int httpResponseCode = http.GET();
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
String payload = http.getString();
Serial.println(payload);
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
// Free resources
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
}
I only modified the red lines.
Â
May I ask what operating system and browser you're using?
I'm not experiencing any of the issues you seem to be running into in this forum.