NEWS
Simple_api adapter syntax problem with esp32
-
Hii
I have a project to send data using MQTT and restfull api using simple_api adapter.
I have succed to send data using post via web browserRight now, i want to use esp32 with post and get http to sending and receive data.
I want post the data the same like this in web browser via esp32192.168.0.120:8087/set/try_simple_api2?value=2I have build some code like this but still sent got nothing.
anyone can help me?
thank you very much regards#include <WiFi.h> #include <HTTPClient.h> const char* ssid = "asdasd"; const char* password = "asdasd"; const char* serverName = "http://192.168.0.120:8087/"; unsigned long lastTime = 0; unsigned long timerDelay = 2000; 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() { if ((millis() - lastTime) > timerDelay) { if(WiFi.status()== WL_CONNECTED){ HTTPClient http; http.begin(serverName); http.addHeader("Content-Type", "text/plain"); int httpResponseCode = http.POST("/set/try_simple_api2?value=7"); Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); // Free resources http.end(); } else { Serial.println("WiFi Disconnected"); } lastTime = millis(); } } -
Hii
I have a project to send data using MQTT and restfull api using simple_api adapter.
I have succed to send data using post via web browserRight now, i want to use esp32 with post and get http to sending and receive data.
I want post the data the same like this in web browser via esp32192.168.0.120:8087/set/try_simple_api2?value=2I have build some code like this but still sent got nothing.
anyone can help me?
thank you very much regards#include <WiFi.h> #include <HTTPClient.h> const char* ssid = "asdasd"; const char* password = "asdasd"; const char* serverName = "http://192.168.0.120:8087/"; unsigned long lastTime = 0; unsigned long timerDelay = 2000; 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() { if ((millis() - lastTime) > timerDelay) { if(WiFi.status()== WL_CONNECTED){ HTTPClient http; http.begin(serverName); http.addHeader("Content-Type", "text/plain"); int httpResponseCode = http.POST("/set/try_simple_api2?value=7"); Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); // Free resources http.end(); } else { Serial.println("WiFi Disconnected"); } lastTime = millis(); } }@kristfrizh Hii
i just figured it out
we don't use post at all with those syntax
thank you
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden