It does not display the temperature. Displays different characters

It does not display the temperature. Displays different characters.
Previously it worked normally.

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <LiquidCrystal_I2C.h> 
#include <OneWire.h>
#include <DallasTemperature.h>
  int nastaw = 27; // ustaw temperature
 int przekaznik = D3; // pin przekaznik 
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS D4
 LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Ustawienie adresu ukladu na 0x27
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
SimpleTimer timer;
int pin = D5; // Pin cyfrowy krancówka
WidgetLED led1(V2); // Pin wirtualny krancowy 
 
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
 BLYNK_CONNECTED() {
    Blynk.syncAll();
}
void setup()
{
   pinMode(przekaznik,OUTPUT);
pinMode(pin,INPUT);
Serial.begin(9600);
Blynk.begin(auth, "", ""); // Nazwa i hasło sieci WIFI
sensors.begin();
sensors.setResolution(9);   // More on resolutions: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/
timer.setInterval(1000L, brama); //Sprawdzanie stanu 
timer.setInterval(2000L, temperatura); //Sprawdzanie stanu 
 lcd.begin(16,2);   // Inicjalizacja LCD 2x16
    lcd.backlight(); // zalaczenie podwietlenia 
  lcd.setCursor(0,0); // Ustawienie kursora w pozycji 0,0 (pierwszy wiersz, pierwsza kolumna)
  lcd.print("Temp:");
  
}
 
void loop()
{
timer.run();
Blynk.run();
  lcd.setCursor(7, 0); 
  lcd.print(sensors.getTempCByIndex(0));
  lcd.setCursor(7, 2);
  lcd.print(sensors.getTempCByIndex(1));
  lcd.setCursor(0, 1); 
 lcd.print("N=");
  lcd.print(nastaw);
 sensors.requestTemperatures();
  if (sensors.getTempCByIndex(1) < (nastaw)) {
    digitalWrite(D3,LOW);
  } else {
    digitalWrite(D3,HIGH);
  }
 
}
 
void temperatura()
{
  sensors.requestTemperatures();
  delay(5);
Blynk.virtualWrite(V1,sensors.getTempCByIndex(0)); //Pin wirtualny do temperatury
  delay(5); 
Blynk.virtualWrite(V2,sensors.getTempCByIndex(1)); //Pin wirtualny do temperatury 
}
 
void brama()
{
if(digitalRead(pin) == D2){
  led1.off();
}
else{
  led1.on();
}
}

I find that very difficult to believe with your void loop looking like that!

Pete.

1 Like

It does not work because of that. I do not know why.

Peter is right you should clean up the void loop.

The problem may be that the print routine is getting called faster than the LCD can fade.

I would empty the void loop, create a routine that does the output and get it on a timer. Your code will be more stable and things will work better.