Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. /****************************************
  2. * Include Libraries
  3. ****************************************/
  4. #include "UbidotsESPMQTT.h"
  5. #include <AM232X.h>
  6.  
  7.  
  8. /****************************************
  9. * Define Constants
  10. ****************************************/
  11. #define TOKEN "ffffffffff" // Your Ubidots TOKEN
  12. #define WIFINAME "fifi" //Your SSID
  13. #define WIFIPASS "papieje" // Your Wifi Pass
  14.  
  15. Ubidots client(TOKEN);
  16.  
  17. //AM232X AM2322;
  18.  
  19.  
  20. /****************************************
  21. * Auxiliar Functions
  22. ****************************************/
  23.  
  24. void callback(char* topic, byte* payload, unsigned int length) {
  25. Serial.print("Message arrived [");
  26. Serial.print(topic);
  27. Serial.print("] ");
  28. for (int i=0;i<length;i++) {
  29. Serial.print((char)payload[i]);
  30. }
  31. Serial.println();
  32. }
  33.  
  34. /****************************************
  35. * Main Functions
  36. ****************************************/
  37.  
  38. void setup() {
  39. // put your setup code here, to run once:
  40. ESP.wdtDisable();
  41.  
  42. client.ubidotsSetBroker("industrial.api.ubidots.com"); // Sets the broker properly for the industrial account
  43. client.setDebug(true); // Pass a true or false bool value to activate debug messages
  44. Serial.begin(9600);
  45. client.wifiConnection(WIFINAME, WIFIPASS);
  46. client.begin(callback);
  47.  
  48. // if (! AM2322.begin() )
  49. // {
  50. // Serial.println("Sensor not found");
  51. //// while (1);
  52. // }
  53. Serial.println("Zainicjalizowano\n");
  54. }
  55.  
  56. void loop() {
  57. // put your main code here, to run repeatedly:
  58. delay(5000);
  59. if(!client.connected()){
  60. client.reconnect();
  61. }
  62.  
  63. //float value1 = AM2322.getTemperature();
  64. // float value2 = AM2322.getHumidity();
  65. float value1 = 1.0;
  66. float value2 = 2.0;
  67. client.add("temperature", value1);
  68. client.add("humidity", value2);
  69. client.ubidotsPublish("esp8266");
  70. client.loop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement