Why my pump won't work?

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?? :frowning:

You shouls post in the correct category.

I have moved this post for you.

Topic moved !! Please do not post in "Uncategorized"; see the sticky topics in https://forum.arduino.cc/c/using-arduino/uncategorized/184.

You might want to look at this How to get the best out of this forum before you proceed any further.

ooh right! sorry i haven't familiar with this forum. thanks for correcting me. But do you have any idea or found similar regarding the problem?

At this stage you should post a schematic of what you have, because word salad doesn't cut it in electronics.

Using a battery requires you take certain precautions, so that is why we need to see a proper schematic of what you have. Hand drawn is fine photographed and posted in the same orientation as the reader of the forum would see it.

Maybe pump code would like to have some pin setup as well?

1 Like

OH RIGHT! I forgot to add it and doesn't notice to the small detail. THANK YOU!!

You're welcome!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.