Last active
November 7, 2019 20:07
-
-
Save ubi-gists/f085582285679908d068ee655d5beff1 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
/* | |
* The sample code requires the ESP8266 v.2.0.0 library for proper operation. | |
* (https://github.com/ubidots/ubidots-esp8266/releases/tag/2.0.0) | |
* However, is strongly recommended to migrate the code to the latest library version. | |
* (https://github.com/ubidots/ubidots-esp8266) | |
*/ | |
#include "UbidotsMicroESP8266.h" | |
#define ID "223e6b1176254235a7xxxxx" // Put here your Ubidots variable ID | |
#define TOKEN "bbN8FrVulRYGuPTkaaaiR9Myxxxxx" // Put here your Ubidots TOKEN | |
#define WIFISSID "WiFi_SSID" | |
#define PASSWORD "WiFI_PASSWORD" | |
#define RELAY 12 | |
#define LED 13 | |
Ubidots client(TOKEN); | |
void setup(){ | |
Serial.begin(115200); | |
delay(10); | |
pinMode(RELAY, OUTPUT); | |
pinMode(LED, OUTPUT); | |
digitalWrite(LED, HIGH); | |
client.wifiConnection(WIFISSID, PASSWORD); | |
} | |
void loop(){ | |
float value = client.getValue(ID); | |
Serial.println(value); | |
if (value == 1.00) { | |
digitalWrite(RELAY, HIGH); //On relay | |
digitalWrite(LED, LOW); //On led | |
} | |
if (value == 0.00) { | |
digitalWrite(RELAY, LOW); //Off relay | |
digitalWrite(LED, HIGH); //Off led | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment