Created
May 31, 2017 17:35
-
-
Save maxpromer/3381818a167056be4f947635360d87a8 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 <WiFi.h> | |
| #include <HTTPClient.h> | |
| #define WIFI_STA_NAME "xxxxxxxxxx" | |
| #define WIFI_STA_PASS "xxxxxxxxxx" | |
| void setup() { | |
| Serial.begin(115200); | |
| pinMode(LED_BUILTIN, OUTPUT); | |
| Serial.println(); | |
| Serial.println(); | |
| Serial.print("Connecting to "); | |
| Serial.println(WIFI_STA_NAME); | |
| WiFi.mode(WIFI_STA); | |
| WiFi.begin(WIFI_STA_NAME, WIFI_STA_PASS); | |
| while (WiFi.status() != WL_CONNECTED) { | |
| delay(500); | |
| Serial.print("."); | |
| digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); | |
| } | |
| digitalWrite(LED_BUILTIN, HIGH); | |
| Serial.println(""); | |
| Serial.println("WiFi connected"); | |
| Serial.println("IP address: "); | |
| Serial.println(WiFi.localIP()); | |
| String url = "http://ioxhop.info/files/request.php"; | |
| Serial.println(); | |
| Serial.println("Get content from " + url); | |
| HTTPClient http; | |
| http.begin(url); | |
| int httpCode = http.POST("id=1&temp=30&time=12%3A50"); | |
| if (httpCode == 200) { | |
| String content = http.getString(); | |
| Serial.println("Content ---------"); | |
| Serial.println(content); | |
| Serial.println("-----------------"); | |
| } else { | |
| Serial.println("Fail. error code " + String(httpCode)); | |
| } | |
| Serial.println("END"); | |
| } | |
| void loop() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment