Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <ESP8266HTTPClient.h>
  2. #include <SimpleButton.h>
  3. using namespace simplebutton;
  4. #include <ESP8266WiFi.h>
  5.  
  6.  
  7. HTTPClient http;
  8.  
  9. const char* ssid     = "JWSystems";
  10. const char* password = "jamescool192";
  11.  
  12. Button* b = NULL;
  13.  
  14. void setup() {
  15.   b = new Button(0);
  16.  
  17.   Serial.begin(115200);
  18.   delay(10);
  19.  
  20.   // We start by connecting to a WiFi network
  21.  
  22.   Serial.println();
  23.   Serial.println();
  24.   Serial.print("Connecting to ");
  25.   Serial.println(ssid);
  26.  
  27.   WiFi.begin(ssid, password);
  28.  
  29.   while (WiFi.status() != WL_CONNECTED) {
  30.     delay(500);
  31.     Serial.print(".");
  32.   }
  33.  
  34.   Serial.println("");
  35.   Serial.println("WiFi connected");  
  36.   Serial.println("IP address: ");
  37.   Serial.println(WiFi.localIP());
  38. }
  39.  
  40. int value = 0;
  41.  
  42. void loop() {
  43.   b->update();
  44.   if (b->clicked()) {
  45.     Serial.println("BUTTON");
  46.     http.begin("http://doorpi.lan/api");
  47.     http.POST("username=api&password=q8tFpTn9gxvs&type=5sec");
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement