2018年11月11日 星期日

ESP32_Blynk_DHT11


// Robo India Tutorial
// Digital Output on LED
// Hardware: NodeMCU Blynk Board

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <SimpleTimer.h>   //including the library of SimpleTimer

#include "DHT.h"           // including the library of DHT11 temperature and humidity sensor
#define DHTTYPE DHT11      // DHT 11

#define dht_dpin 23
DHT dht(dht_dpin, DHTTYPE);
SimpleTimer timer;
char auth[] = "92e8d542e63184fa4bc2c3d0a3694f5da";            // You should get Auth Token in the Blynk App.
                                                             // Go to the Project Settings (nut icon).

char ssid[] = "abex99ufo";           // Your WiFi credentials.
char pass[] = "aedx93981";           // Set password to "" for open networks.
float t;                                   // Declare the variables
float h;



void setup()
{
    Serial.begin(115200);// Debug console
    Blynk.begin(auth, ssid, pass);
    dht.begin();
    timer.setInterval(2000, sendUptime);
}

void sendUptime()
{
 
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  Serial.println("Humidity and temperature\n\n");
  Serial.print("Current humidity = ");
  Serial.print(h);
  Serial.print("%  ");
  Serial.print("temperature = ");
  Serial.print(t);
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);
 
}

void loop()
{
  Blynk.run();
  timer.run();
}





























沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...