My Blynk app switch not working. I have connected the water pump with relay module. and the relay module is connected with ESP8266 nodemcu. I added a switch to turn on the water pump but when I am pressing it, it is not working. Please help me
My project is about Plant monitoring. It has soil moisture sensor, Humidity sensor, Temperature sensor. my idea is - we can see soil moisture, humidity, temperature on the app. Water pump and LED is also attached. I used switch for LED and water pump. But when I give power to the ESP8266 and turn on the switch of water pump, it does not turn on. here is the code I used, Please tell me my mistake. Please
pensive: pensive:
#define BLYNK_TEMPLATE_ID "TMPLH3002sX_"
#define BLYNK_DEVICE_NAME "CPI project"
#define BLYNK_AUTH_TOKEN "h26aw15t_uu5oTfhwIKroGdEh9n_UlwM"
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <SPI.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Fog-1";
char pass[] = "amiseemu33";
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V5, h); //V5 is for Humidity
Blynk.virtualWrite(V6, t); //V6 is for Temperature
}
void setup()
{
Serial.begin(9600);
dht.begin();
timer.setInterval(1000L, sendSensor);
Blynk.begin(auth, ssid, pass);
sensors.begin();
}
int sensor=0;
int output=0;
void sendTemps()
{
sensor=analogRead(A0);
output=(145-map(sensor,0,1023,0,100)); //in place 145 there is 100(it change with the change in sensor)
delay(1000);
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0);
Serial.println(temp);
Serial.print("moisture = ");
Serial.print(output);
Serial.println("%");
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2,output);
delay(1000);
}
void loop()
{
Blynk.run();
timer.run();
sendTemps();
}
And these are the pins I used:
Soil Moisture - V2
Humidity - V5
Temperature - V6
LED - D3
Water pump - D5