Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include "IFTTTWebhook.h"
- #define WIFI_SSID "your SSID here"
- #define WIFI_PASSWORD "your password here"
- #define IFTTT_API_KEY "ceubX8trC3ZXKFTrEMXc-Z" //the Webhooks key.
- #define IFTTT_EVENT_NAME "oximetry_heart_rate_sensor" //the event name.
- int adc_id = 0;
- int HistoryValue = 0;
- char printBuffer[128];
- // constants won't change
- const int RELAY_PIN = A5; // the Arduino pin, which connects to the IN pin of relay
- void setup()
- WiFi.mode(WIFI_STA);
- WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
- IFTTTWebhook wh(IFTTT_API_KEY, IFTTT_EVENT_NAME);
- wh.trigger(value);
- {
- Serial.begin(9600);
- pinMode(RELAY_PIN, OUTPUT); // initialize digital pin A5 as an output.
- digitalWrite(RELAY_PIN, LOW); // turn off pump
- }
- void loop()
- {
- int value = analogRead(adc_id); // get adc value from A0
- if(((HistoryValue>=value) && ((HistoryValue - value) > 10)) || ((HistoryValue<value) && ((value - HistoryValue) > 10)))
- {
- sprintf(printBuffer,"ADC%d level is %d\n",adc_id, value);
- Serial.print(printBuffer);
- HistoryValue = value;
- }
- if(value < 50) // parameter should be adjusted to the waterer low level
- {
- digitalWrite(RELAY_PIN, HIGH); // turn on pump
- }
- if(value > 600) // parameter should be adjusted to the waterer high level
- {
- digitalWrite(RELAY_PIN, LOW); // turn off pump
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment