BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Smart Watering

esp8266
#1

Guys i really need help about my project. firstly i cant connect L298N motor driver to nodemcu and i cant find anywhere anything about it. Besides, for soil moisture i reed 1023 instead of 0 from gauge. if you have any idea pls help me.

0 Likes

#2

https://www.google.com/search?q=L298N+motor+driver+nodemcu+esp8266

0 Likes

#4

Please repost your code… properly formatted as required in the Welcome Topic.

However, before doing so, you might also want to read this, and other, Help Files…


And after reading said topics… what is your Blynk related question? We don’t intend to troubleshoot or rewrite your code for you, that is your job, but we will try to help you learn about Blynk.

0 Likes

#5
void testOne() {

// turn on motor

digitalWrite(ENA, HIGH);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);

delay(5000); // now turn off

digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
}

 void getSoilData(){
  int soilM = 0;
  soilM=analogRead(sensor);
  Serial.println(soilM);
  soilM = map(soilM, 600, 0, 0, 100);
  if(soilM< 600){
    testOne();
  }else{
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
  }
  
}


void loop()
{
  Blynk.run();
  getSoilData();
 
}

when i upload, the testOne is working properly but i can only get sensor data when motor is off. I need to get soil data in second and the pump needs to work according to that. Am i missing something here.

0 Likes

#6

Hello

This is how my code looks like is out of date but maybe the code will help you Soil Moisture Sensor with gauge

0 Likes

#7
void blinkLedWidget()
{
  Sensorvalue = analogRead(A0);
  Sensorvalue = map(Sensorvalue, 0, 1023, 1023, 0);
  sensorValuePercent = (Sensorvalue / 1023) * 100; // In Prozent
  Blynk.virtualWrite(V5, sensorValuePercent);

  if (Sensorvalue<600){

// turn on motor

digitalWrite(ENA, HIGH); // set speed to 200 out of possible range 0~255
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);

delay(5000); // now change motor directions

digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
delay(2000);
  }
 
}



void loop()
{
  Blynk.run();
  blinkLedWidget();
 
}

Thank you for your reply. and i made some changes and now when sensor inside the water i read araound 380 and pump not working but when its above 400 starting. so far its okay but here is the thin that i dont understant is why am i reading hundreads value from mobile phone?

0 Likes

#8

@GoodWayne: as advised by @Gunner above, you should read those topic to get the right way to go for your case. At least for me I saw you put some avoid () at loop so each seconds it runs hundred activities then threw to your phone :joy: … tips: try with BlynkTimer() rather “so colorful” in the loop() :grinning:

0 Likes

#9
{
  Sensorvalue = analogRead(A0);
  Sensorvalue = map(Sensorvalue, 0, 1023, 1023, 0);
  sensorValuePercent = (Sensorvalue / 1023) * 100; // In Prozent
  Blynk.virtualWrite(V5,Sensorvalue );
}
void loop()
{
  Blynk.run();
 timer.run();
 
}

so its still same. I had a ATM hamework that wasnt hard this much :joy:

0 Likes

#11

I wish to see your entire code here if you think ok that let see if I can put in for some to make it “weakup” :slight_smile:

0 Likes

#12
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "1416ff8827a343c8a53585447f7df8d3";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "NetMASTER Uydunet-2E2B";
char pass[] = "A1B2c3d4";
BlynkTimer timer;
int ENA = 4;

int IN1 = 0;

int IN2 = 2;

int Sensorvalue=0;
int sensorPin=A0;
int sensorValuePercent=0;

void setup()
{
  // Debug console
  Serial.begin(9600);
  timer.setInterval(1000, blinkLedWidget);
  Blynk.begin(auth, ssid, pass);
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  
}
void blinkLedWidget()
{
  Sensorvalue = analogRead(A0);
  Sensorvalue = map(Sensorvalue, 0, 1023, 100, 0);
  sensorValuePercent = (Sensorvalue / 1023) * 100; // In Prozent
  Blynk.virtualWrite(V5,Sensorvalue );
   if (Sensorvalue<50){

           digitalWrite(ENA, HIGH); // set speed to 200 out of possible range 0~255
           digitalWrite(IN1, HIGH);
           digitalWrite(IN2, LOW);

           delay(5000); // now change motor directions

           digitalWrite(IN1, LOW);
           digitalWrite(IN2, LOW);
           delay(2000);
  }
    
}
void loop()
{ 
  Blynk.run();
  timer.run();
}

its solved know. thank you all and the problem was in the mapping instead of

sensorValue = map(sensorValue, 0, 1023, 1023, 0);
i have written
Sensorvalue = map(Sensorvalue, 0, 1023, 100, 0);
and its started to show 0 and 100 values.

1 Like