Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************
- * Include Libraries
- ****************************************/
- #include "UbidotsESPMQTT.h"
- #include <AM232X.h>
- /****************************************
- * Define Constants
- ****************************************/
- #define TOKEN "ffffffffff" // Your Ubidots TOKEN
- #define WIFINAME "fifi" //Your SSID
- #define WIFIPASS "papieje" // Your Wifi Pass
- Ubidots client(TOKEN);
- //AM232X AM2322;
- /****************************************
- * Auxiliar Functions
- ****************************************/
- void callback(char* topic, byte* payload, unsigned int length) {
- Serial.print("Message arrived [");
- Serial.print(topic);
- Serial.print("] ");
- for (int i=0;i<length;i++) {
- Serial.print((char)payload[i]);
- }
- Serial.println();
- }
- /****************************************
- * Main Functions
- ****************************************/
- void setup() {
- // put your setup code here, to run once:
- ESP.wdtDisable();
- client.ubidotsSetBroker("industrial.api.ubidots.com"); // Sets the broker properly for the industrial account
- client.setDebug(true); // Pass a true or false bool value to activate debug messages
- Serial.begin(9600);
- client.wifiConnection(WIFINAME, WIFIPASS);
- client.begin(callback);
- // if (! AM2322.begin() )
- // {
- // Serial.println("Sensor not found");
- //// while (1);
- // }
- Serial.println("Zainicjalizowano\n");
- }
- void loop() {
- // put your main code here, to run repeatedly:
- delay(5000);
- if(!client.connected()){
- client.reconnect();
- }
- //float value1 = AM2322.getTemperature();
- // float value2 = AM2322.getHumidity();
- float value1 = 1.0;
- float value2 = 2.0;
- client.add("temperature", value1);
- client.add("humidity", value2);
- client.ubidotsPublish("esp8266");
- client.loop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement