└── night_light (1).ino (1).txt /night_light (1).ino (1).txt: -------------------------------------------------------------------------------- 1 | #define BLYNK_PRINT Serial // Comment this out to disable prints and save space 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // You should get Auth Token in the Blynk App. 9 | // Go to the Project Settings (nut icon). 10 | char auth[] = "2aqctMEvoT1a3Q0ZfZTerz1aqzsSwCW7"; //Enter the Auth code which was send by Blink 11 | 12 | // Your WiFi credentials. 13 | // Set password to "" for open networks. 14 | char ssid[] = "karur"; //Enter your WIFI Name 15 | char pass[] = "karur001"; //Enter your WIFI Password 16 | 17 | #define DHTPIN 2 // Digital pin 4 18 | const int sensorpin=A0; 19 | int sensorvalue=0; 20 | int outputvalue=0; 21 | // Uncomment whatever type you're using! 22 | //#define DHTTYPE DHT11 // DHT 11 23 | #define DHTTYPE DHT22 // DHT 22, AM2302, AM2321 24 | //#define DHTTYPE DHT21 // DHT 21, AM2301 25 | 26 | DHT dht(DHTPIN, DHTTYPE); 27 | SimpleTimer timer; 28 | const int sensorPin = A0; 29 | // This function sends Arduino's up time every second to Virtual Pin (5). 30 | // In the app, Widget's reading frequency should be set to PUSH. This means 31 | // that you define how often to send data to Blynk App. 32 | void sendSensor() 33 | { 34 | float h = dht.readHumidity(); 35 | float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit 36 | if (isnan(h) || isnan(t)) { 37 | Serial.println("Failed to read from DHT sensor!"); 38 | return; 39 | } 40 | // You can send any value at any time. 41 | // Please don't send more that 10 values per second. 42 | Blynk.virtualWrite(V5, h); //V5 is for Humidity 43 | Blynk.virtualWrite(V6, t); //V6 is for Temperature 44 | } 45 | 46 | void sendSensor2() 47 | { 48 | int sensorvalue=analogRead(sensorpin); 49 | outputvalue=map(sensorvalue,0,1023,0,100); 50 | 51 | if(outputvalue>74) 52 | { 53 | Serial.println("water your plant"); 54 | Serial.print(outputvalue); 55 | Blynk.notify("water your plant"); 56 | delay(1000); 57 | } 58 | else if(outputvalue<45) 59 | { 60 | Serial.println("soil is wet enough to water"); 61 | Serial.print(outputvalue); 62 | Blynk.notify("soil is wet enough to water"); 63 | delay(1000); 64 | 65 | } 66 | Blynk.virtualWrite(V1, outputvalue); 67 | } 68 | 69 | void setup() 70 | { 71 | Serial.begin(9600); // See the connection status in Serial Monitor 72 | Blynk.begin(auth, ssid, pass); 73 | dht.begin(); 74 | // Setup a function to be called every second 75 | timer.setInterval(1000L, sendSensor); 76 | } 77 | 78 | void loop() 79 | { 80 | Blynk.run(); // Initiates Blynk 81 | timer.run(); // Initiates SimpleTimer 82 | } 83 | --------------------------------------------------------------------------------