hello engrs i am building a project Fan controlling Temperature so when Temperature reaches at level min 28 turned of the problem desnt turn off fan. please help me
i the code i had used is
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <DHT.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “695ac0046cd746c7b75842922ebcccc6”;
#define W5100_CS 10
#define SDCARD_CS 4
int Pirpin =6;
int pins=12;
#define DHTPIN 7 // What digital pin we’re connected to
// Uncomment whatever type you’re using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino’s up time every second to Virtual Pin (5).
// In the app, Widget’s reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
float hum = dht.readHumidity();
float tem = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
t = ((int) (t * 10) / 10.0);
h = ((int) (h * 10) / 10.0);
if (isnan(hum) || isnan(tem)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}
Blynk.virtualWrite(V6, tem);
Blynk.virtualWrite(V5, hum);
Blynk.syncVirtual(V6);
if (hum<=70 || tem<=28 )
{ digitalWrite(8,LOW);
}
else
{
digitalWrite(8,HIGH);
}
// You can send any value at any time.
// Please don’t send more that 10 values per second.
// Blynk.digitalWrite(,HIGH)
}
//BLYNK_READD(V6)
//{ Blynk.virtualWrite(v6,val);
// }
// BLYNK_WRITE(6){
// int TempDes = param.asInt();
// Blynk.virtualWrite(6,TempDes);
//
//}
//BLYNK_WRITE(V0){
// int TempDes = param.asInt();
// Blynk.virtualWrite(V0,HIGH);
// Blynk.syncVirtual(V0);
//}
void emailOnPirSensor()
{
// *** WARNING: You are limited to send ONLY ONE E-MAIL PER 15 SECONDS! ***
// Let’s send an e-mail when you press the button
// connected to digital pin 2 on your Arduino
int isPirSensor = !digitalRead(6); // Invert state, since button is “Active LOW”
if (isPirSensor) // You can write any condition to trigger e-mail sending
{
Serial.println(“Bath Room Lamp is On.”); // This can be seen in the Serial Monitor
Blynk.email("ukaash143@gmail.com", “Subject”, “You just Turned On Lamp Second ago…”);
// Or, if you want to use the email specified in the App (like for App Export):
//Blynk.email(“Subject: Button Logger”, “You just pushed the button…”);
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(Pirpin, INPUT);
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
pinMode(pins, OUTPUT);
pinMode(8,OUTPUT);
digitalWrite(8,LOW);
Blynk.begin(auth);
dht.begin();
Blynk.email("ukaash143@gmail.com", “Subject”, “My Blynk project is online.”);
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
// You can also specify server:
//Blynk.begin(auth, “blynk-cloud.com”, 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8442);
// For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example
}
void loop()
{
Blynk.run();
timer.run();
getPirValue();
// int PirValue=digitalRead(Pirpin);
// if(PirValue==HIGH)
// {
// Blynk.notify(“Bath Room Lamp Is ON”);
// //BATHROOM.on();
// Blynk.virtualWrite(V4,HIGH);
// delay(1000);
// }
// else
// {
// //Blynk.notify(“Bath Room Lamp Is OFF”);
// // BATHROOM.off();
// // Blynk.digitalWrite(D12,LOW);
// delay(1000);
// }
}
void getPirValue(void)
{
int Pirpin =6;
int pirValue = digitalRead(Pirpin);
if (pirValue)
{
Serial.println("==> Motion detected");
Blynk.notify(“T==> Motion detected”);
}
digitalWrite(12, pirValue);
}