Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//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