My LCD and Blynk cant ran together

Sry for my english, btw i have project here name “Temperature Monitoring with Blynk + LCD I2C” , The issues is my LCD didnt work properly i mean theres no word in it. Thanks for your time :bowing_man:

Details :

MCU : Arduino Uno
Wifi Module : esp8266-01
Sensor : DHT-22
LCD : LCD 16x2 I2C

CODE = ----------------------------------------------------------------------------------------------------------------

#define BLYNK_TEMPLATE_ID           "****************************"
#define BLYNK_DEVICE_NAME          "****************************"
#define BLYNK_AUTH_TOKEN           "****************************"

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <DHT.h>

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = "****************************";
char ssid[] = "****************************";
char pass[] = "****************************";

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

#define ESP8266_BAUD 9600// Your ESP8266 baud rate:

ESP8266 wifi(&EspSerial);

BlynkTimer timer;

LiquidCrystal_I2C lcd(0x27, 16, 2);
#define DHTPIN 4          // What digital pin we're connected to
#define DHTTYPE DHT22   
DHT dht(DHTPIN, DHTTYPE);


void setup() {  
  Serial.begin(9600);
  
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);

  timer.setInterval(1000L, sendSensor);
  
  lcd.begin();
  lcd.backlight();  
  dht.begin();

}

void sendSensor()
{
  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;
  }
  
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  
}

void loop(){
  float h = dht.readHumidity();
  float t = dht.readTemperature(); 
  
  lcd.setCursor(0, 0); 
  lcd.print("H : ");
  lcd.print(h);
  lcd.print("%");
  
  lcd.setCursor(0, 1);
  lcd.print("T : ");
  lcd.print(t);
  lcd.print("C");

  Blynk.run();
  timer.run();

}

Please edit your post, and add triple backticks ``` before and after your whole sketch.

1 Like

This peice of code should be moved from the void loop to the sendsensor function.
Also, you should always keep the void loop clean.

1 Like

The LCD still dont run, and Blynk didnt run properly, its like online need time for 23 sec and then offline in 10 sec.

void sendSensor()
{
  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;
  }
  
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  
  lcd.setCursor(0, 0);
  lcd.print("H : ");
  lcd.print(h);
  lcd.print("%");
  
  lcd.setCursor(0, 1);
  lcd.print("T : ");
  lcd.print(t);
  lcd.print("C");
  
}

void loop(){

  Blynk.run();
  timer.run();
}

Are you sure that the LCD is wired properly?
Are you using the latest version of the LiquidCrystal_I2C.h library?
Have you tried LCD.init() instead of LCD.begin()?

You’re using an old, unstable method (Arduino + esp8266 WiFi shield). I’d suggest using esp32 or nodemcu instead.

1 Like

Its wired properly, i had try run this program separate i mean i run monitoring DHT22 + Blynk & monitoring DHT22 + LCD I2C and it work perfect but when i try mix it, the LCD didnt show any and Blynk didnt run properly.


#define BLYNK_TEMPLATE_ID           "--------------------------------"
#define BLYNK_DEVICE_NAME          "--------------------------------"
#define BLYNK_AUTH_TOKEN           "--------------------------------"

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>

char auth[] = "--------------------------------";
char ssid[] = "--------------------------------";// Your WiFi credentials.
char pass[] ="--------------------------------";// Set password to "" for open networks.

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX [hubungkan pin rx esp -> pin tx arduino dan pin tx esp -> pin rx arduino]

#define ESP8266_BAUD 9600// Your ESP8266 baud rate:

ESP8266 wifi(&EspSerial);

#define DHTPIN 4          // What digital pin we're connected to

#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

void sendSensor()
{
  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;
  }
  
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

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

This is code for Monitoring DHT22 with LCD I2C

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <DHT.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
#define DHTPIN 4          // What digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
DHT dht(DHTPIN, DHTTYPE);


void setup() {  
  Serial.begin(9600);
  dht.begin();
  lcd.begin();

}

void loop(){
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  
  lcd.setCursor(0, 0); //
  lcd.print("H : ");
  lcd.print(h);
  lcd.print("%");
  
  lcd.setCursor(0, 1);
  lcd.print("T : ");
  lcd.print(t);
  lcd.print("C");
}

How exactly are you powering your LCD display and your ESP-01 ?

Pete.

1 Like

LCD I2C:

VCC : 5 V
GND : GND
SDA : Pin Analog 4
SCL : Pin Analog 5

ESP8266-01 :

VCC : 3.3 V
CH_PD : 3.3 V
TX: Pin 2 Digital
RX : Pin 3 Digital
GND : GND

So all powered from either the USB connector on the Arduino or via the 9-12v power connector on the Arduino?

I suspect that this is your problem.
The backlight on these LCDs consumes quite a bit of power, and the ESP-01 also consumes more power than you think in Tx mode.

I’d add a separate 5v power supply to power the LCD, but make sure that you have a common ground between the LCD power and the Uno.

Pete.

i use Adaptor =
VOut : 9V
I : 1 A

But when i test 1st code i just use LCD I2C.

That goes through the Arduino’s onboard voltage regulators, and they can’t provide enough power for your needs.

Pete.

But sir, when i test the 1st code i just use LCD to make sure its have good source. i just use LCD to make sure the problem.

Okay, ignore my advice. It’s not a problem for me.

Pete.

I think i need another MCU and Censor for LCD.

That’s not the approach I’d take.

Pete.

So what you will do sir, if you found problem like this ?
Any advice of code for making Monitoring Tempreature using Bylnk + LCD I2C ?

I’ve told you what I’d do with your hardware, but you don’t seem to want to try that solution.

But, TBH I would never build a project based around an Uno + ESP-01.
In this situation I’d probably use an ESP32, but if you were using an LCD display then you’d still need separate power for the LCD and its backlight.
There are some ESP32s with built-in OLED displays, but theses aren’t always the easiest devices to work with from a physical perspective.

Pete.

1 Like

Okke, I Will try to use seperate power for LCD I2C And i will try with another MCU too, that you have mention. Wait for next Reply :bowing_man:

Hello. The result is same :(, even i try with Nodemcu 32 and use separate 5V source for LCD

The code :

#define BLYNK_TEMPLATE_ID           "------------------------"
#define BLYNK_DEVICE_NAME           "----------------------------"
#define BLYNK_AUTH_TOKEN            "------------------------"

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

//#include <ESP8266_Lib.h>
//#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>

char auth[] = "----------------------------------";
char ssid[] = "-----------------------";// Your WiFi credentials.
char pass[] = "----------------------";// Set password to "" for open networks.

#define DHTPIN 4          // What digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

LiquidCrystal_I2C lcd(0x27, 16, 2);

  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  
void sendSensor()
{
  
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

  lcd.setCursor(0, 0); 
  lcd.print("H : ");
  lcd.print(h);
  lcd.print("%");
  
  lcd.setCursor(0, 1);
  lcd.print("T : ");
  lcd.print(t);
  lcd.print("C");
  delay (1000);
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  lcd.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

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

So how exactly is this new setup wired?

Have you tested this without connecting to Blynk and seen the LCD working with your ESP32?

With the sketch you’ve posted is it connecting to Blynk and displaying the sensor values?

As far as this sketch is concerned, you need to remove this…

And this line should be removed…

and this line…

changed to…

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

I’d also reccomend changing the baud rate from 9600 to 115200…

because this is most likely the native baud rate of your ESP32 and this will allow you to see boot messages and debug messages at the same time.

Pete.