Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #include <UbidotsMicroESP8266.h>
- #include <ESP8266WiFi.h>
- #define LEAK_PIN 2 // Arduino Digital I/O pin number
- #define TOKEN "MY-API-TOKEN-HERE"
- #define TEMP "TEMP"
- #define HUMID "Variable Token Here"
- #define LIGHT "Variable Token Here"
- #define MOISTURE "vochtwaarde"
- // constante
- const char* ssid = "iPhone van Jay";
- const char* password = "jay929292";
- // sync ubidots client
- Ubidots client(TOKEN);
- void setup() {
- Serial.begin(115200);
- Serial.println("Start");
- //initialiseer led lampje
- pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
- // We start by connecting to a WiFi network
- Serial.println();
- Serial.println();
- Serial.print("Connecting to ");
- Serial.println(ssid);
- WiFi.begin(ssid, password);
- // check connection
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- // print connection details
- Serial.println("");
- Serial.println("WiFi connected");
- Serial.println("IP address: ");
- Serial.println(WiFi.localIP());
- // variable setup
- // set an integer for the sensor value
- const float moistureValue = 0;
- const int sensorLow = 400;
- const int sensorHigh = 1000;
- // will be used to activate the refill messagel;
- pinMode(LEAK_PIN, INPUT);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- // print sensor output
- float moistureValue = analogRead(A0);
- //Serial.println(moistureValue);
- // send data to ubidots
- client.add(MOISTURE, moistureValue);
- client.sendAll(true);
- digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
- delay(1000);
- digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement