Advertisement
peko

wifi esp8266 code

Oct 21st, 2015
6,887
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <ESP8266WiFi.h>
  3. #include <ThingerWifi.h>
  4.  
  5. #define USERNAME "username"
  6. #define DEVICE_ID "deviceid"
  7. #define DEVICE_CREDENTIAL "devicecredentials"
  8.  
  9. #define SSID "networkName"
  10. #define SSID_PASSWORD "networkPassword"
  11.  
  12. ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
  13.  
  14. void setup() {
  15. pinMode(0, OUTPUT);
  16. pinMode(1, OUTPUT);
  17.  
  18. thing.add_wifi(SSID, SSID_PASSWORD);
  19.  
  20. // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
  21. thing["bojler"] << [](pson& in){ digitalWrite(0, in ? HIGH : LOW); };
  22.  
  23. // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
  24. thing["vrata"] << [](pson& in){ digitalWrite(2, in ? HIGH : LOW); };
  25. }
  26.  
  27. void loop() {
  28. thing.handle();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement