Blynk mobile and web dashboard issue

Before creating the topic

  1. Search forum for similar topics
  2. Check http://docs.blynk.cc and http://help.blynk.cc/
  3. Add details :
    • Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
    • Smartphone OS (iOS or Android) + version
    • Blynk server or local server
    • Blynk Library version
    • Add your sketch code. :point_up:Code should be formatted as example below.

Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.


void loop()

My query is for a simple plant watering system automation using ESP32 micro-controller, I’m trying to use Lcd display, relay, water pump, and soil moisture sensor. In Lcd display I can able to see the moisture value but the same is not reflecting on mobile and web dashboard of Blynk IOT app. I tried to connect everything under same Wi-fi network, still not able to notice any variation in mobile app. what could be the problem?

Impossible to say without at the very least seeing your sketch. Info about datastreams, widgets used, whether your device appears online etch etc would also be useful.

Don’t forget to follow the instructions that you didn’t delete when making your first post about code formatting.

Pete.

It’s showing online status in mobile dashboard.

[Unformatted code removed by moderator]

@Loga Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

#define BLYNK_TEMPLATE_ID "****"
#define BLYNK_TEMPLATE_NAME "****"
#define BLYNK_AUTH_TOKEN "*****"
//Include the library files
#include <LiquidCrystal_I2C.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>



#define sensor 33
#define relay 4

//Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);

BlynkTimer timer;

// Enter your Auth token
char auth[] = "******";

//Enter your WIFI SSID and password
char ssid[] = "****";
char pass[] = "*****";

void setup() {
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  lcd.init();
  lcd.backlight();
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);

  lcd.setCursor(1, 0);
  lcd.print("System Loading");
  for (int a = 0; a <= 15; a++) {
    lcd.setCursor(a, 1);
    lcd.print(".");
    delay(200);
  }
  lcd.clear();


}

//Get the ultrasonic sensor values
void soilMoisture() {
  int value = analogRead(sensor);
  value = map(value, 4095,0,100,0);
  value = (value - 74) * 1;
  if (value<0)
  {
    value=-value;
  }
  Blynk.virtualWrite(V0, value);
  Serial.println(value);
  lcd.setCursor(0, 0);
  lcd.print("Moisture :");
  lcd.print(value);
  lcd.print(" ");
}

//Get the button value
BLYNK_WRITE(V1) {
  bool Relay = param.asInt();
  if (Relay == 1) {
    digitalWrite(relay, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Motor is ON ");
  } else {
    digitalWrite(relay, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Motor is OFF");
  }
}

void loop(){
soilMoisture();
  Blynk.run();    //Run the Blynk library

  delay(200);


}

Any reason why you left your u formatted code in place and added a new post with it correctly formatted, instead of editing your earlier post?

The screenshot you posted shows the Template view, which is simply a preview of the web dashboard with dummy data,
You need to go to the Device view (magnifying glass at the top left) to see the real dashboard.

You need to remove these two lines from your void loop…

and use a BlynkTimer to call your soilMoisture function, but I suspect that doing this every 200ms is a bit of an overkill.

Pete.

#define BLYNK_TEMPLATE_ID "****"
#define BLYNK_TEMPLATE_NAME "****"
#define BLYNK_AUTH_TOKEN "*****"
//Include the library files
#include <LiquidCrystal_I2C.h>
#include <SimpleTimer.h>
#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>



#define sensor 33
#define relay 4

//Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);

BlynkTimer timer;

// Enter your Auth token
char auth[] = "******";

//Enter your WIFI SSID and password
char ssid[] = "****";
char pass[] = "*****";

void measureSoilMoisture() {
    soilMoisture(); // Call your soilMoisture function here
}


void setup() {
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  lcd.init();
  lcd.backlight();
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);

  timer.setInterval(5000, measureSoilMoisture);

  lcd.setCursor(1, 0);
  lcd.print("System Loading");
  for (int a = 0; a <= 15; a++) {
    lcd.setCursor(a, 1);
    lcd.print(".");
    delay(200);
  }
  lcd.clear();


}

//Get the soilMoisture sensor values
void soilMoisture() {
  int value = analogRead(sensor);
  value = map(value, 4095,0,100,0);
  value = (value - 74) * 1;
  if (value<0)
  {
    value=-value;
  }
  Blynk.virtualWrite(V0, value);
  Serial.println(value);
  lcd.setCursor(0, 0);
  lcd.print("Moisture :");
  lcd.print(value);
  lcd.print(" ");
}

//Get the button value
BLYNK_WRITE(V1) {
  bool Relay = param.asInt();
  if (Relay == 1) {
    digitalWrite(relay, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Motor is ON ");
  } else {
    digitalWrite(relay, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Motor is OFF");
  }
}

void loop() {
  
  Blynk.run();//Run the Blynk library
  timer.run();


}

Actually by mistake instead of editing earlier post I just posted a new reply , My bad, pardon me. Is this code okay now as it’s showing no error in arduino ide??

Why are you making this so complicated? Just call soilMoisture in your BlynkTimer.

Pete.

I have no idea how to call soil moisture function inside blynk timer . If I try like this it’s showing error.

void loop{
BlynkTimer soilMoisture();
Blynk.run();
}

You’re currently using BlynkTimer to call measureSoilMoisture

timer.setInterval(5000, measureSoilMoisture);

Change it to call soilMoisture instead…

timer.setInterval(5000, soilMoisture);

Then delete the redundant measureSoilMoisture() function from your sketch.

Pete.

But if I do call soilMoisture inside void setup() function, like this

timer.setInterval(5000, soilMoisture);

It’ll spit an error right because I defined void soilMoisture() in another subsequent scope. so, it’ll say soilMoisture was not declared in the scope. Even if I define the void soilMoisture() above the void setup() as we know it is defined locally not globally.

What EXACTLY is your error message?

Pete.

WARNING: library LiquidCrystal I2C claims to run on avr architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s).
C:\Users\lyoga\AppData\Local\Temp\.arduinoIDE-unsaved202378-15212-uaz42o.gtu0s\sketch_aug8a\sketch_aug8a.ino: In function 'void setup()':
C:\Users\lyoga\AppData\Local\Temp\.arduinoIDE-unsaved202378-15212-uaz42o.gtu0s\sketch_aug8a\sketch_aug8a.ino:54:27: error: 'SoilMoisture' was not declared in this scope
   timer.setInterval(5000, SoilMoisture)
                           ^~~~~~~~~~~~
C:\Users\lyoga\AppData\Local\Temp\.arduinoIDE-unsaved202378-15212-uaz42o.gtu0s\sketch_aug8a\sketch_aug8a.ino:54:27: note: suggested alternative: 'soilMoisture'
   timer.setInterval(5000, SoilMoisture)
                           ^~~~~~~~~~~~
                           soilMoisture

exit status 1

Compilation error: 'SoilMoisture' was not declared in this scope

Please EDIT THIS POST and replace the screenshot with the entire text copied from your IDE’s compiler screen.
Use triple backticks at the beginning and end the same way you do with code.

Pete.

And you’ve done it again!

If you edit your earlier post in the way I asked then I’ll explain why you’re getting this error.

Pete.

Can you spot the difference between these two lines of code?..

The compiler error message even tells you what the problem is, and suggests an alternative (which is correct)…

Variable names, function names, object names etc are case-sensitive in C++ and you need to take care when using them.

Pete.