Created
June 29, 2022 21:45
-
-
Save veritem/95c4f1f45e00d0af49df001c809914ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
WiFiClient wifiClient; | |
void setup(){ | |
Serial.begin(9600); | |
WiFi.begin("RCA-WiFi", "rca@2019"); | |
} | |
void loop(){ | |
String mData=""; | |
String device_name = "Front001-Device"; | |
String distance = "32 cm v1"; | |
mData = "device="+device_name+"&distance="+distance; | |
sendData(80, "insecure.benax.rw", "/iot/" , mData); | |
delay(5000); | |
} | |
void sendData(const int Port, const char* host,const char* filepath , String data){ | |
wifiClient.connect(host, Port); | |
wifiClient.println("POST "+(String)filepath+" HTTP/1.1"); | |
wifiClient.println("Host: " + (String)host); | |
wifiClient.println("User-Agent: ESP8266/1.0"); | |
wifiClient.print(data); | |
Serial.println("Response: " + wifiClient.readStringUntil('\n')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment