WidgetLCD timeout error

Hello all.

First blynk project. Using uno and esp8266. Have been adding to my project bit by bit and all was working and then i added a lcd widget. Now i just get Login timeout.

[678] Connecting to ubnt-pico
[3841]
[7066] +CIFSR:STAIP,“192.168.1.79”
+CIFSR:STAMAC,“a0:20:a6:14:bd:9e”
[7073] Connected to WiFi
[18008] Ready (ping: 24ms).
[28060] Login timeout

[43994] Ready (ping: 34ms).
[54046] Login timeout
[70039] Ready (ping: 26ms).
[80092] Login timeout
[96026] Ready (ping: 24ms).

If i comment out the couple of lines for the WidgetLCD i connect and all goes on.
Any ideas on how to fix this would be great.

Thanks.


#define BLYNK_PRINT Serial
#include "arduino.h"

// #region    Blynk & Esp8266 Setup.
  #include <ESP8266_Lib.h>
  #include <BlynkSimpleShieldEsp8266.h>

// Blynk Project Auth Token from the Blynk App.
  char auth[] = "XXXXXXXX";

// WiFi AP Settings.
  char ssid[] = "ubnt-pico";
  char pass[] = "xxxxxx";
// Software serial for communication with ESP8266
  #include <SoftwareSerial.h>
  SoftwareSerial EspSerial(8, 9); // RX, TX
// ESP8266 baud rate:
  #define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);
BlynkTimer timer;
// #endregion
// #region    DHT22 Sensor Setup
  #include <DHT.h>
  #define DHTPIN 7
  #define DHTTYPE DHT22
  DHT dht(DHTPIN, DHTTYPE);
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
// #endregion
// #region    DS18B20 Sensor Setup
  #include <OneWire.h>
  #include <DallasTemperature.h>
// DS18S20 Temperature chip i/o on pin 10
  #define ONE_WIRE_BUS 10
// oneWire instance to communicate with any OneWire devices
  OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to Dallas Temperature.
  DallasTemperature sensors(&oneWire);
// #endregion
// #region    LCD
  #include <LiquidCrystal.h>
// initialize interface pins for LCD
  LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  WidgetLCD  blynkLCD(V1);
// #endregion

// #region    On Timer Function
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V6, millis() / 1000);
}
// #endregion
// #region    DHT Sensor Function
void sendDHT()
{
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Blynk.virtualWrite(V2, t);
  Blynk.virtualWrite(V3, h);

  Serial.print("DHT22");
      Serial.println();
      Serial.print("Temperature: ");
      Serial.print(t);
      Serial.print(" *C ");
      Serial.println();
      Serial.print("Humidity: ");
      Serial.print(h);
      Serial.print(" %\t");
      Serial.println();
      Serial.println();
  }
// #endregion
// #region    DS18B20 Sensor Function
void sendDS18B20()
{
//to issue a global temperature;
// request to all devices on the bus
  sensors.requestTemperatures();
// Send the command to get temperature readings
   sensors.requestTemperatures();
// Output To Serial
   Serial.print("Requesting temperatures...");
   Serial.println("DONE");
   delay(500);
   Serial.println("DS18B20");
   Serial.print("Fermenter 1 is: ");
   Serial.println(sensors.getTempCByIndex(0));
   Serial.print("Fermenter 2 is: ");
   Serial.println(sensors.getTempCByIndex(1));

   Blynk.virtualWrite(V4, sensors.getTempCByIndex(0));
   Blynk.virtualWrite(V5, sensors.getTempCByIndex(1));
}
// #endregion
// #region    LCD Function
  // #region    LCD Start
  void startLCD()
    {
      lcd.begin(20, 4);
      lcd.clear();
      lcd.setCursor(5,1);
      lcd.print("WELCOME TO");
      lcd.setCursor(0,2);
      lcd.print("TRIPPLE B");

      blynkLCD.print(0, 0, "Welcome To");
      blynkLCD.print(0, 1, "Tripple B");
    }
  void requestLCD()
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("REQUESTING TEMP");
      lcd.blink();
    }
  // #endregion LCD Start

  // #region    LCD Regular Update Output
  void outLCD()
    {
      lcd.clear();
      lcd.noBlink();
      lcd.setCursor(0,0);
      lcd.print("Ambiant ");
      lcd.setCursor(13,0);
      lcd.print(t);
      lcd.setCursor(18,0);
      lcd.print(" C");
      lcd.setCursor(0,1);
      lcd.print("Humidity ");
      lcd.setCursor(13,1);
      lcd.print(h);
      lcd.setCursor(18,1);
      lcd.print(" %");
      lcd.setCursor(0,2);
      lcd.print("Fermenter 1 ");
      lcd.setCursor(13,2);
      lcd.print(sensors.getTempCByIndex(0));
      lcd.setCursor(18,2);
      lcd.print(" C");
      lcd.setCursor(0,3);
      lcd.print("Fermenter 2 ");
      lcd.setCursor(13,3);
      lcd.print(sensors.getTempCByIndex(1));
      lcd.setCursor(18,3);
      lcd.print(" C");
    }
  // #endregion LCD Regular Update Output
// #endregion

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

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

// Start DHT Sensor
  dht.begin();
// Start DS18B20 Sensors
  sensors.begin();

  Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 8442);

// Output lcd startup function
  startLCD();
  timer.setTimeout(1000, requestLCD);

// Setup a function to be called every second
   timer.setInterval(1000L, myTimerEvent);
   timer.setInterval(5000L, sendDHT);
   timer.setInterval(5000L, sendDS18B20);
   timer.setInterval(5000L, outLCD);


}

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

You might be sending “Too Much, Too Fast”. Try spacing out the LCD writes in groups a few ms apart.

try to remove or reduce that 500 ms delay.

also, try to rise the baud rate from 9600 to 115200. maybe 9600 is too slow and it blocks too long until it sends the data. just an idea…

I removed all of the delays.

And i have now swapped over to hardware serial from the uno and upped the speed back to 115200. I have now got most of it up and running. A few changes still needed on my end as it is still not 100% but thanks for the help.

1 Like