Created
April 24, 2020 07:31
-
-
Save EDISON-SCIENCE-CORNER/c59bad9b9a8f9711ddf268b6ed64e255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//EDISON SCIENCE CORNER | |
//EDISON SCIENCE CORNER | |
//EDISON SCIENCE CORNER | |
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space | |
#include <SPI.h> | |
#include <ESP8266WiFi.h> | |
#include <BlynkSimpleEsp8266.h> | |
#include <SimpleTimer.h> | |
#include <DHT.h> | |
char auth[] = "ESCESCESCECSCECSCSCSCEC"; //Enter the Auth code which was send by Blink | |
char ssid[] = "edison science corner"; //Enter your WIFI Name | |
char pass[] = "eeeeeeee"; //Enter your WIFI Password | |
#define DHTPIN 2 // Digital pin 4 | |
#define DHTTYPE DHT11 | |
DHT dht(DHTPIN, DHTTYPE); | |
SimpleTimer timer; | |
int ANALOG = A0; // CONNECT ANALOG SENSOR | |
int data = 0; | |
void sendSensor() | |
{ | |
float h = dht.readHumidity(); | |
float t = dht.readTemperature(); | |
if (isnan(h) || isnan(t)) { | |
Serial.println("Failed to read from DHT sensor!"); | |
return; | |
} | |
Blynk.virtualWrite(V5, h); //V5 is for Humidity | |
Blynk.virtualWrite(V6, t); //V6 is for Temperature | |
} | |
void setup() | |
{ | |
Serial.begin(9600); | |
Blynk.begin(auth, ssid, pass); | |
dht.begin(); | |
timer.setInterval(1000L, getSendData); | |
timer.setInterval(1000L, sendSensor); | |
} | |
void loop() | |
{ | |
Blynk.run(); // Initiates Blynk | |
timer.run(); // Initiates SimpleTimer | |
} | |
void getSendData() | |
{ | |
data = analogRead(ANALOG); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment