Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************
- * Include Libraries
- ****************************************/
- #include "UbidotsESPMQTT.h"
- /****************************************
- * Define Constants
- ****************************************/
- #define TOKEN "" // Your Ubidots TOKEN
- #define WIFINAME "" //Your SSID
- #define WIFIPASS "" // Your Wifi Pass
- Ubidots client(TOKEN);
- /****************************************
- * 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:
- client.setDebug(true); // Pass a true or false bool value to activate debug messages
- Serial.begin(115200);
- client.wifiConnection(WIFINAME, WIFIPASS);
- client.begin(callback);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- if(!client.connected()){
- client.reconnect();
- }
- float heartBeat = analogRead(A0);
- client.add("heart-beat", heartBeat);
- client.ubidotsPublish("demo-machine");
- client.loop();
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement