
2 minute read
Sound Sensor 5. Servo Motor 6. DC Battery
E. Dumped Code #define BLYNK_PRINT Serial #include <Servo.h> Servo myservo; // create servo object to control a servo // twelve servo objects can be created on most boards int pos = 0; // variable to store the servo position #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include <DHT.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "dyBhHOMy6udsSrLm1nZz8nyAh0_uM1qS"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "iPhone"; char pass[] = "harsh123"; #define DHTPIN D3 // D3 // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); BlynkTimer timer; void sendSensor() {
float h = dht.readHumidity(); float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V5, t); Blynk.virtualWrite(V6, h);
Advertisement
} void setup() {
// Debug console Serial.begin(9600); Blynk.begin(auth, ssid, pass); pinMode(D5,OUTPUT); pinMode(D6,OUTPUT); pinMode(D7,OUTPUT); pinMode(D8,OUTPUT); // digitalWrite(D5,HIGH); digitalWrite(D6,HIGH); digitalWrite(D7,HIGH); digitalWrite(D8,HIGH); myservo.attach(D5); myservo.write(90); dht.begin();
// Setup a function to be called every second timer.setInterval(1000L, sendSensor);
} void loop() {
Blynk.run(); timer.run(); int a=analogRead(A0); int c =map(a,1024,400,0,100); int b=digitalRead(D2); Serial.println(a); Serial.println(c); Blynk.virtualWrite(V4, c); Blynk.virtualWrite(V3, b); if(a>800) {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position }
} else { myservo.write(90) }
IV. RESULTS AND DISCUSSION
A. Results of Hardware Implementation



Figure 5: view of Hardware prototype
B. Result of Bylnk IOT Notification App (i.e. Available on Playstore for free)


Figure 6: view of IOT Blynk App