Memakai UbiDots Cloud Dengan NodeMcu

Cara menghubungkan nodeMCU kamu dengan unidots cloud cukup mudah, berikut contoh menggunakan DHT11, 

#include "DHT.h" 
#define DHTPIN D1
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);


#include "UbidotsMicroESP8266.h"
#define TOKEN  "A1E-kjeI6pKCeYOn6SFBDEBBiRezl68lxU"  // Put here your Ubidots TOKEN
#define WIFISSID "Nokia 3.1"
#define PASSWORD ""

Ubidots client(TOKEN);
unsigned long lastMillis = 0;

void setup(){
    Serial.begin(115200);
    dht.begin();
    delay(10);
    client.wifiConnection(WIFISSID, PASSWORD);
}
void loop(){

    if (millis() - lastMillis > 10000) {  ///every 10S

      float MyHumidity = dht.readHumidity();
      float MyTemperature = dht.readTemperature();
      
      
            lastMillis = millis();
            client.add("MyHumidity",MyHumidity );
            client.add("MyTemperature",MyTemperature );

           
            client.sendAll(true);
            
            }
   
}

 

1 Comment
  1. Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    Commenter avatars come from Gravatar.

Leave a reply