Advertisement
Guest User

Untitled

a guest
Sep 15th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. /*
  2. Copyright (C) AC SOFTWARE SP. Z O.O.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16.  
  17. #include <SuplaDevice.h>
  18. #include <supla/sensor/DHT.h>
  19.  
  20. // Choose proper network interface for your card:
  21. #ifdef ARDUINO_ARCH_AVR
  22. // Arduino Mega with EthernetShield W5100:
  23. #include <supla/network/ethernet_shield.h>
  24. // Ethernet MAC address
  25. uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
  26. Supla::EthernetShield ethernet(mac);
  27.  
  28. // Arduino Mega with ENC28J60:
  29. // #include <supla/network/ENC28J60.h>
  30. // Supla::ENC28J60 ethernet(mac);
  31. #elif defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
  32. // ESP8266 and ESP32 based board:
  33. #include <supla/network/esp_wifi.h>
  34. Supla::ESPWifi wifi("your_wifi_ssid", "your_wifi_password");
  35. #endif
  36.  
  37. /*
  38. * This example requires DHT sensor library installed.
  39. * https://github.com/adafruit/DHT-sensor-library
  40. */
  41.  
  42. #define DHT1PIN 24
  43. #define DHT1TYPE DHT22
  44. #define DHT2PIN 25
  45. #define DHT2TYPE DHT22
  46.  
  47. void setup() {
  48.  
  49. Serial.begin(115200);
  50.  
  51. // Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
  52. char GUID[SUPLA_GUID_SIZE] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
  53.  
  54. // Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
  55. char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
  56.  
  57. /*
  58. * Having your device already registered at cloud.supla.org,
  59. * you want to change CHANNEL sequence or remove any of them,
  60. * then you must also remove the device itself from cloud.supla.org.
  61. * Otherwise you will get "Channel conflict!" error.
  62. */
  63.  
  64. // This example adds two DHT22 sensors.
  65.  
  66. // CHANNEL0 - DHT22 Sensor
  67. new Supla::Sensor::DHT(DHT1PIN, DHT1TYPE);
  68.  
  69. // CHANNEL1 - DHT22 Sensor
  70. new Supla::Sensor::DHT(DHT2PIN, DHT2TYPE);
  71.  
  72. /*
  73. * SuplaDevice Initialization.
  74. * Server address is available at https://cloud.supla.org
  75. * If you do not have an account, you can create it at https://cloud.supla.org/account/create
  76. * SUPLA and SUPLA CLOUD are free of charge
  77. *
  78. */
  79.  
  80. SuplaDevice.begin(GUID, // Global Unique Identifier
  81. "svr1.supla.org", // SUPLA server address
  82. "email@address", // Email address used to login to Supla Cloud
  83. AUTHKEY); // Authorization key
  84.  
  85. }
  86.  
  87. void loop() {
  88. SuplaDevice.iterate();
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement