Advertisement
Guest User

Untitled

a guest
Mar 17th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. #include <UbidotsMicroESP8266.h>
  3. #include <ESP8266WiFi.h>
  4. #define LEAK_PIN 2 // Arduino Digital I/O pin number
  5. #define TOKEN "MY-API-TOKEN-HERE"
  6. #define TEMP "TEMP"
  7. #define HUMID "Variable Token Here"
  8. #define LIGHT "Variable Token Here"
  9. #define MOISTURE "vochtwaarde"
  10.  
  11. // constante
  12. const char* ssid = "iPhone van Jay";
  13. const char* password = "jay929292";
  14.  
  15. // sync ubidots client
  16. Ubidots client(TOKEN);
  17.  
  18.  
  19. void setup() {
  20.  
  21. Serial.begin(115200);
  22. Serial.println("Start");
  23.  
  24. //initialiseer led lampje
  25. pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
  26.  
  27. // We start by connecting to a WiFi network
  28. Serial.println();
  29. Serial.println();
  30. Serial.print("Connecting to ");
  31. Serial.println(ssid);
  32.  
  33. WiFi.begin(ssid, password);
  34.  
  35. // check connection
  36. while (WiFi.status() != WL_CONNECTED) {
  37. delay(500);
  38. Serial.print(".");
  39. }
  40.  
  41. // print connection details
  42. Serial.println("");
  43. Serial.println("WiFi connected");
  44. Serial.println("IP address: ");
  45. Serial.println(WiFi.localIP());
  46.  
  47. // variable setup
  48. // set an integer for the sensor value
  49. const float moistureValue = 0;
  50. const int sensorLow = 400;
  51. const int sensorHigh = 1000;
  52.  
  53. // will be used to activate the refill messagel;
  54.  
  55. pinMode(LEAK_PIN, INPUT);
  56. }
  57.  
  58. void loop() {
  59. // put your main code here, to run repeatedly:
  60.  
  61. // print sensor output
  62. float moistureValue = analogRead(A0);
  63. //Serial.println(moistureValue);
  64.  
  65. // send data to ubidots
  66. client.add(MOISTURE, moistureValue);
  67. client.sendAll(true);
  68. digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
  69. delay(1000);
  70. digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement