Advertisement
RuiViana

ESP8266_Cayenne_DHT11

Feb 24th, 2017
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. Iniciando com Cayenne ESP8266. Com DHT11
  2.  
  3. Logar no Cayenne.
  4.  
  5. 1. Criar novo Projeto.
  6. a. Clicar em "Add new...";
  7. a.1 Clicar em "Devices & Widgets";
  8. b. Selecionar um "Single Board Computers" (arduino para ESP8266);
  9. b.1 Clicar em "Next";
  10. b.2 Salve o AUTH TOKEN FOR THIS DEVICE:;
  11. c. Clicar em SELECT YOUR ARDUINO BOARD CONNECTION:;
  12. c.2 Click em "Arduino Uno";
  13. d.1 Selecione "WiFi Shield";
  14. d.2 Copie o sketch que se abre e cole nem um novo sketch na IDE do arduino;
  15. d.3 Digite sua SSID e sua PW nos locais indicados;
  16. d.4 Comente esta linha: #include <CayenneWiFi.h>;
  17. d.5 Acrescentes esta linhas:
  18. #include <ESP8266WiFi.h>
  19. #include "CayenneDefines.h"
  20. #include "BlynkSimpleEsp8266.h"
  21. #include "CayenneWiFiClient.h"
  22. Obs:
  23. Verifique se esta bibliotecas estão instaladas na sua IDE.
  24. d. Carregue o code no seu ESP8266;
  25. e. Abra o monitor serial e verifique se a conexão com a rede wifi foi feita.
  26. f. Ao conectar com o cayenne a tela dele abre mostrando o seu projeto na barra
  27. vertical à esquerda.
  28.  
  29. 2. Criar os Widgets.....
  30.  
  31. a. Clicar em "Add new...";
  32. a.1 Clicar em "Devices & Widgets";
  33. b. Selecionar um " Sensors, Actuators, Extensions, LoRa ou Custom Widgets ";
  34. Para o DHT11 selecione Custom "Widgets";
  35. c. Selecione "Gauge";
  36. d. Em "Enter Settings";
  37. "Name" De um nome para seu gauge;
  38. "Device" Selecione seu "projeto";
  39. "I/O" Selecione virtual;
  40. "Pin" Selecione "VO,V1....."
  41. "Data" Selecione "temperature ou Humidity"
  42. "Unit" Se for temperature selecione a mdidada "Celsius/Fahrenheit," etc
  43.  
  44. e. Salve clicando em Step 2: Add Widget.
  45.  
  46.  
  47. Iniciando com Cayenne ESP8266. Controlando um LED
  48.  
  49. Logar no Cayenne.
  50.  
  51. A parte Incial é igual a de criar um projeto descrita em :
  52. " Iniciando com Cayenne ESP8266. Com DHT11 "
  53.  
  54. 2. Criar os Widgets.....
  55.  
  56. a. Clicar em "Add new...";
  57. a.1 Clicar em "Devices & Widgets";
  58. b. Selecionar um " Sensors, Actuators, Extensions, LoRa ou Custom
  59.  
  60. Widgets ";
  61. Para controlar um LED click em "Actuators";
  62. c. Selecione "Generic";
  63. d. Selecione "Digital";
  64. e. Em "Enter Settings";
  65. "Digital Output" De um nome para seu gauge;
  66. "Select Device" Selecione seu "projeto";
  67. "Connectivity" Selecione "Digital;
  68. "Pin" Selecione ""DO,D1....."
  69. "Choose Widget" Selecione "Button"
  70. "Choose icon" Selecione um Icone;
  71.  
  72. e. Salve clicando em Step 2: Add Widget.
  73.  
  74. Exemplo de code par o DHT11
  75.  
  76. //#define CAYENNE_DEBUG // Comente para nao mostrar menssagen de debugs
  77. #define CAYENNE_PRINT Serial // Comente para impedir impressoes no serial monitor e salvar espaço
  78. #include <ESP8266WiFi.h> // Bibioteca em http:.................
  79. #include "CayenneDefines.h" // Bibioteca em http:.................
  80. #include "BlynkSimpleEsp8266.h" // Bibioteca em http:.................
  81. #include "CayenneWiFiClient.h" // Bibioteca em http:.................
  82.  
  83. #include <DHT.h> // Biblioteca do DHT11
  84. #include "Wire.h" // Bibioteca de I2C Standard do Arduino
  85.  
  86. #define DHTTYPE DHT11 // Define o tipo de sensor utilizado DHT11/DHT22.....
  87. #define DHTPIN 14 // Port onde esta conectado o pino data do DHT11
  88. float pot = A0; // Port onde esta conectado o potenciometro (Setpoint)
  89. float valor = 0; // Variavel que armazena o valor lido no potencioment
  90.  
  91. char token[] = "ttttt"; // Cayenne auth token. Valor encontrado no site ao criar o projeto novo ou no settings
  92. char ssid[] = "sssssssss"; // Digite seu SSID e sua PW
  93. char password[] = "ppppppppp";
  94.  
  95. DHT dht(DHTPIN, DHTTYPE, 15); // Cria o objeto dht
  96.  
  97. //---------------------------
  98. void setup()
  99. {
  100. Serial.begin(9600); // Inicia a serial
  101. Cayenne.begin(token, ssid, password); // Estabelece comunicacao com o site Cayenne
  102. dht.begin();
  103. }
  104. //---------------------------
  105. void loop()
  106. {
  107. Cayenne.run(); // Roda o projeto no site
  108. delay(100); // Delay
  109. }
  110. //-----------------------------------
  111. CAYENNE_OUT(V0) // Estas funcoes e chamada quando um widget requer dados do pin virtual
  112. {
  113. Cayenne.virtualWrite(V0, dht.readTemperature()); // Imprime Temperatura em celsius no pin virtual V0
  114. }
  115. //-----------------------------------
  116. CAYENNE_OUT(V1)
  117. {
  118. Cayenne.virtualWrite(V1, dht.readHumidity()); // Imprime Umidade em porcentagem no pin virtual V1
  119. }
  120. //-------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement