Advertisement
Guest User

ESP-01+Aduino Pro Mini + Blynk

a guest
Sep 21st, 2015
1,645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <ESP8266.h>
  2. #include <BlynkSimpleShieldEsp8266.h>
  3. #include <DHT.h>
  4. #include <SimpleTimer.h>
  5. #define DHTPIN 2
  6. #define DHTTYPE DHT11   // DHT 22 Change this if you have a DHT11
  7. DHT dht(DHTPIN, DHTTYPE);
  8. // Set ESP8266 Serial object
  9. #define EspSerial Serial
  10. ESP8266 wifi(EspSerial);
  11. SimpleTimer timer;
  12.  
  13.  
  14. // Declare Constants
  15.  
  16. const int ledPin = 13;             // Built-in LED
  17. const int RelayPin = 4;             // Relay Pin
  18.  
  19. char auth[] = "Auth_Token";
  20. void setup()
  21. {
  22.  //No Serial console as the Nano only has 1 HW Serial
  23.   EspSerial.begin(115200);  // Set ESP8266 baud rate
  24.   delay(10);
  25.   Blynk.begin(auth, wifi, "WifiNetworkName", "WifiPassword");
  26.   timer.setInterval(1000, sendData);
  27.     pinMode(ledPin, OUTPUT);
  28.     pinMode(RelayPin, OUTPUT);
  29. }
  30. void sendData()
  31. {
  32. //Read the Temp and Humidity from DHT
  33.   float h = dht.readHumidity();
  34.   float t = dht.readTemperature();
  35. //Write values to V04 and V05
  36.   Blynk.virtualWrite(4, h);
  37.   Blynk.virtualWrite(5, t);
  38. }
  39. void loop()
  40. {
  41.   Blynk.run();
  42.   timer.run();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement