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();
}





























沒有留言:

張貼留言

WOKWI LED + MQTT Node-Red SQLite

WOKWI LED + MQTT Node-Red SQLite const char *mqtt_broker = "broker.mqtt-dashboard.com" ; const char *topic1 = "alex9ufo/e...