SHARE
TWEET

kecském

a guest Jan 24th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define IO_USERNAME    "Addamm"
  2. #define IO_KEY         "1dc26502236e48eb93cd338fb89a5286"
  3.  
  4. #define WIFI_SSID       "csillamfaszlama"
  5. #define WIFI_PASS       "fulopphone"
  6.  
  7. #include "AdafruitIO_WiFi.h"
  8. AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
  9. //--------------------------------------------------------------------------------
  10. //bool current = false;
  11. //bool last = false;
  12. #include <Wire.h>
  13. #include <Adafruit_ADS1015.h>
  14. #include <Adafruit_Sensor.h>
  15. #include <DHT.h>
  16.  
  17. Adafruit_ADS1115 ads;  // ads pinje: D1(scl)-- D2(sda)
  18. //Adafruit_ADS1015 ads;
  19.  
  20. #define DHTPIN D5     //dht pinje D5
  21. //#define DHTTYPE DHT11
  22. #define DHTTYPE DHT22
  23. DHT dht(DHTPIN, DHTTYPE);
  24.  
  25. AdafruitIO_Feed *temperature = io.feed("temperature");//Hőmérséklet
  26. AdafruitIO_Feed *humidity = io.feed("humidity");//Páratartalom
  27. AdafruitIO_Feed *adc00 = io.feed("adc0");
  28. AdafruitIO_Feed *adc01 = io.feed("adc1");
  29. AdafruitIO_Feed *adc02 = io.feed("adc2");
  30. AdafruitIO_Feed *adc03 = io.feed("adc3");
  31.  
  32.  
  33. unsigned long startMillis;  
  34. unsigned long currentMillis;
  35. const unsigned long period = 20000;  
  36.  
  37.  
  38. void setup(void) {
  39.   Serial.begin(9600);
  40.   startMillis = millis();
  41.   ads.begin();
  42.   dht.begin();
  43.  
  44.   Serial.print("Connecting to Adafruit IO");
  45.   io.connect();
  46.   while (io.status() < AIO_CONNECTED) {
  47.     Serial.print(".");
  48.     delay(500);
  49.   }
  50.   Serial.println();
  51.   Serial.println(io.statusText());
  52. }
  53.  
  54. void loop(void) {
  55.   io.run();
  56.   int16_t adc0, adc1, adc2, adc3;
  57.  
  58.   adc0 = ads.readADC_SingleEnded(0);
  59.   adc1 = ads.readADC_SingleEnded(1);
  60.   adc2 = ads.readADC_SingleEnded(2);
  61.   adc3 = ads.readADC_SingleEnded(3);
  62.  
  63.   adc0 = map(adc0, 0, 17720, 0, 100);
  64.   adc1 = map(adc1, 0, 17720, 0, 100);
  65.   adc2 = map(adc2, 0, 17720, 0, 100);
  66.   adc3 = map(adc3, 0, 17720, 0, 100);
  67.  
  68.   currentMillis = millis();  
  69.   if (currentMillis - startMillis >= period)  {
  70.     startMillis = currentMillis;
  71.    
  72.       float hum = dht.readHumidity();
  73.       float temp = dht.readTemperature();
  74.         Serial.print("celsius: ");
  75.         Serial.print(temp);
  76.         Serial.println("C");
  77.         Serial.print("Humidity: ");
  78.         Serial.print(hum);
  79.         Serial.println("%");
  80.         Serial.println("...................................");
  81.   //***********************************************************  
  82.   Serial.print("AIN0: "); Serial.println(adc0);
  83.   Serial.print("AIN1: "); Serial.println(adc1);
  84.   Serial.print("AIN2: "); Serial.println(adc2);
  85.   Serial.print("AIN3: "); Serial.println(adc3);
  86.   Serial.println(" ");
  87.  
  88.       temperature->save(temp);
  89.       humidity->save(hum);
  90.       adc00->save(adc0);
  91.       adc01->save(adc1);
  92.       adc02->save(adc2);
  93.       adc03->save(adc3);
  94.   }
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top