Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266.h>
- #include <BlynkSimpleShieldEsp8266.h>
- #include <DHT.h>
- #include <SimpleTimer.h>
- #define DHTPIN 2
- #define DHTTYPE DHT11 // DHT 22 Change this if you have a DHT11
- DHT dht(DHTPIN, DHTTYPE);
- // Set ESP8266 Serial object
- #define EspSerial Serial
- ESP8266 wifi(EspSerial);
- SimpleTimer timer;
- // Declare Constants
- const int ledPin = 13; // Built-in LED
- const int RelayPin = 4; // Relay Pin
- char auth[] = "Auth_Token";
- void setup()
- {
- //No Serial console as the Nano only has 1 HW Serial
- EspSerial.begin(115200); // Set ESP8266 baud rate
- delay(10);
- Blynk.begin(auth, wifi, "WifiNetworkName", "WifiPassword");
- timer.setInterval(1000, sendData);
- pinMode(ledPin, OUTPUT);
- pinMode(RelayPin, OUTPUT);
- }
- void sendData()
- {
- //Read the Temp and Humidity from DHT
- float h = dht.readHumidity();
- float t = dht.readTemperature();
- //Write values to V04 and V05
- Blynk.virtualWrite(4, h);
- Blynk.virtualWrite(5, t);
- }
- void loop()
- {
- Blynk.run();
- timer.run();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement