Last active
May 2, 2019 04:35
-
-
Save phwt/097a075ee32ed964971c335e5ae8a04e to your computer and use it in GitHub Desktop.
This file contains 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> | |
#include <ESP8266HTTPClient.h> | |
const char* ssid = "LAB304-2.4GHz"; | |
const char* password = "304304304"; | |
void Line_Notify(int value1, int value2, int value3) { | |
Serial.println("hey"); | |
HTTPClient http; //Declare object of class HTTPClient | |
http.begin("http://maker.ifttt.com/trigger/requested/with/key/000000"); //Specify request destination | |
http.addHeader("Content-Type", "application/json"); //Specify content-type header | |
char postData[] = "{ \"value1\" : \"500\", \"value2\" : \"500\", \"value3\" : \"500\" }"; | |
int httpCode = http.POST(postData); //Send the request | |
String payload = http.getString(); //Get the response payload | |
Serial.println(httpCode); //Print HTTP return code | |
Serial.println(payload); //Print request response payload | |
http.end(); //Close connectio | |
} | |
void setup() { | |
Serial.begin(115200); | |
delay(10); | |
Serial.print("Connecting to "); | |
Serial.println(ssid); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED){ | |
delay(500); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.println("WiFi connected"); | |
// Print the IP address | |
Serial.print("IP="); | |
Serial.println(WiFi.localIP()); | |
pinMode(A0, INPUT); | |
} | |
void loop() { | |
Serial.println(analogRead(A0)); | |
if(analogRead(A0) > 500) | |
Line_Notify(500, 500, 500); | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment