Hi! im trying to make water irrigation system with blynk using ESP8266. Im using two battery 3.7 lipo and 1 chanel 5v relay also 3v to 5 v pump. and im using these code :
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <DHT.h>
#define BLYNK_TEMPLATE_NAME " "
#define BLYNK_AUTH_TOKEN " "
#define BLYNK_TEMPLATE_ID " "
char auth[] = " ";
char ssid[] = " "; // type your wifi name
char pass[] = ""; // type your wifi password
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
WidgetLCD lcd(V3);
#define DHTPIN 4 //Connect Out pin to D2 in NODE MCU
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const int pump = 5;
void sendSensor()
{
/*int soilmoisturevalue = analogRead(A0);
soilmoisturevalue = map(soilmoisturevalue, 0, 1023, 0, 100);*/
int soilvalue = ( 100.00 - (analogRead(A0)/1024.00) * 100.00 );
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(V0, soilvalue);
Blynk.virtualWrite(V1, t);
Blynk.virtualWrite(V2, h);
Serial.print("Soil Moisture : ");
Serial.print(soilvalue);
Serial.print("Temperature : ");
Serial.print(t);
Serial.print(" Humidity : ");
Serial.println(h);
if (soilvalue == 0){
digitalWrite(pump, HIGH); // Turn on the pump
Serial.println("KERING");
lcd.print(8, 0, "KERING");
lcd.print(5, 1, "ON ");
for(int x=0; x<=10; x++){
lcd.print(9,1,"POMPA MENYALA");
lcd.print(9,1,x);delay(500);}
lcd.clear();
digitalWrite(pump, LOW); // Turn off the pump
lcd.print(8, 0, "AIR MERESAP");
lcd.print(5, 1, "TUNGGU ");
for(int x=10; x>0; x--){
lcd.print(9,1,x);delay(500);}
lcd.clear();
delay(1000);
}
else if (soilvalue > 25 && soilvalue < 40) {
Serial.println("NORMAL");
lcd.print(8, 0, "NORMAL");
lcd.print(5, 1, "OFF ");
digitalWrite(pump, LOW);
delay(1000);
}
else if (soilvalue < 40) {
Serial.println("BASAH");
lcd.print(8, 0, "BASAH");
lcd.print(5, 1, "OFF ");
digitalWrite(pump, LOW); // Keep the pump off if the soil is wet
delay(1000);
}
delay(500);
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(100L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}
so the pump suppose to turn on when the soil value == 0, when im try the pump wont turn on nor of.
i already check the pump and the relay by using these simple code :
void setup() {
Serial.begin(115200);
pinMode(relay, OUTPUT);
}
void loop() {
// Normally Open configuration, send LOW signal to let current flow
// (if you're usong Normally Closed configuration send HIGH signal)
digitalWrite(relay, LOW);
Serial.println("Current Flowing");
delay(5000);
// Normally Open configuration, send HIGH signal stop current flow
// (if you're usong Normally Closed configuration send LOW signal)
digitalWrite(relay, HIGH);
Serial.println("Current not Flowing");
delay(5000);
}
what should i do?? ![]()