Add lilbreria wifi manager help I don't know how

In another post I put the wrong code, that’s why I started a new post, what I want is to this code that I have to add the wifi manager liberia for when I am not at home to be able to easily connect to any wifi network, I am manufacturing at home mushrooms … and I was looking for the way when I move with the equipment to be able to connect easily … if not some library similar to wifi manager?

#include <SPI.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>
#include <DHT.h>

#define DHTPIN 2          
LiquidCrystal_I2C lcd(0x27,20,4);

#define DHTTYPE DHT22    
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
WidgetLED led1(V1);

char auth[] = "JWhIMCUvU3v0SFL5w1RsfPe74uSPN0bm"; //Enter the Auth code which was send by Blink

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xeneize";  //Enter your WIFI Name
char pass[] = "laputaclave";  //Enter your WIFI Password
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 blinkLedWidget()
{
  if (led1.getValue()) {
    led1.off();
    Serial.println("LED on V1: off");
  } else {
    led1.on();
    Serial.println("LED on V1: on");
  }
   }
void setup()
{  
  lcd.init();
  lcd.backlight();
  dht.begin();
  lcd.setCursor(0, 0);
  lcd.print("TEMPERATURA:");
  lcd.setCursor(0, 1);
  lcd.print("HUMEDAD:");
  Serial.begin(9600);
 
 
  timer.setInterval(1000L, sendSensor);
}

  void loop() {

  delay(500);
 
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    lcd.print("ERROR");
    return;
  }
  lcd.setCursor(13,0);
  lcd.print(t);
  lcd.print("c");
  lcd.setCursor(9,1);
  lcd.print(h);
  lcd.print("%");
{
  Blynk.run(); // Initiates Blynk
  timer.run(); // Initiates SimpleTimer
}
}```

I could do it, but I don’t see the data from the dht22 either on the lcd or on the internet

//#define BLYNK_DEBUG           // Comment this out to disable debug and save space
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager
#include <DHT.h>
#include <Wire.h>
#include <SPI.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
#define DHTPIN 4          // Digital pin 4

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11     // DHT 11
#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
//for LED status
#include <Ticker.h>
Ticker ticker;

#include <ArduinoJson.h>          //https://github.com/bblanchon/ArduinoJson

char blynk_token[34] = "JWhIMCUvU3v0SFL5w1RsfPe74uSPN0bm";

bool shouldSaveConfig = false; //flag for saving data

#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;

void tick()
{
  //toggle state
  int state = digitalRead(BUILTIN_LED);  // get the current state of GPIO1 pin
  digitalWrite(BUILTIN_LED, !state);     // set pin to the opposite state
}

void saveConfigCallback () {  //callback notifying us of the need to save config
  Serial.println("Should save config");
  shouldSaveConfig = true;
  ticker.attach(0.2, tick);  // led toggle faster
}
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;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);  //V5 is for Humidity
  Blynk.virtualWrite(V6, t);  //V6 is for Temperature
}
void setup()
{

  Serial.begin(115200);
  Serial.println();  
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0); //Ponemos el cursor en la primera fila a la izquierda
  lcd.print("********************"); //Imprimimos un mensaje inicial
  lcd.setCursor(0,1);
  lcd.print("**HONGO HOUSE V1.0**");
  lcd.setCursor(0,2);
  lcd.print("********************");
  lcd.setCursor(0,3);
  lcd.print("****BY***PABLITO****");
 
delay(10000); //Esperamos 2 segundos
  lcd.clear(); //Borramos lo que pone a la pantalla
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  lcd.setCursor(0, 0);
  lcd.print("TEMPERATURA:");
  lcd.setCursor(2, 1);
  lcd.print("HUMUMEDAD:");
 lcd.setCursor(13,0);
  lcd.print(t);
  lcd.print("c");
  lcd.setCursor(13,1);
  lcd.print(h);
  lcd.print("%");

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
  //set led pin as output
  pinMode(BUILTIN_LED, OUTPUT);
  // start ticker with 0.5 because we start in AP mode and try to connect
  ticker.attach(0.6, tick);

  //SPIFFS.format();    //clean FS, for testing
  Serial.println("Mounting FS...");    //read configuration from FS json

  if (SPIFFS.begin()) {
    Serial.println("Mounted file system");
    if (SPIFFS.exists("/config.json")) {
      //file exists, reading and loading
      Serial.println("Reading config file");
      File configFile = SPIFFS.open("/config.json", "r");
      if (configFile) {
        Serial.println("Opened config file");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");

          strcpy(blynk_token, json["blynk_token"]);

        } else {
          Serial.println("Failed to load json config");
        }
      }
    }
  } else {
    Serial.println("Failed to mount FS");
  }
  //end read

  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
  WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 33);   // was 32 length
  
  Serial.println(blynk_token);

  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wifiManager;

  wifiManager.setSaveConfigCallback(saveConfigCallback);   //set config save notify callback

  //set static ip
  // this is for connecting to Office router not GargoyleTest but it can be changed in AP mode at 192.168.4.1
  //wifiManager.setSTAStaticIPConfig(IPAddress(192,168,10,111), IPAddress(192,168,10,90), IPAddress(255,255,255,0));
  
  wifiManager.addParameter(&custom_blynk_token);   //add all your parameters here

  //wifiManager.resetSettings();  //reset settings - for testing

  //set minimu quality of signal so it ignores AP's under that quality
  //defaults to 8%
  //wifiManager.setMinimumSignalQuality();
  
  //sets timeout until configuration portal gets turned off
  //useful to make it all retry or go to sleep, in seconds
  wifiManager.setTimeout(600);   // 10 minutes to enter data and then Wemos resets to try again.

  //fetches ssid and pass and tries to connect, if it does not connect it starts an access point with the specified name
  //and goes into a blocking loop awaiting configuration
  if (!wifiManager.autoConnect("CentralHeatingAP", "MY123PWD")) {
    Serial.println("Failed to connect and hit timeout");
    delay(3000);
    //reset and try again, or maybe put it to deep sleep
    ESP.reset();
    delay(5000);
  }
  Serial.println("Connected Central Heating System :)");   //if you get here you have connected to the WiFi
  ticker.detach();
  //turn LED off
  digitalWrite(BUILTIN_LED, HIGH);

  strcpy(blynk_token, custom_blynk_token.getValue());    //read updated parameters

  if (shouldSaveConfig) {      //save the custom parameters to FS
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    json["blynk_token"] = blynk_token;

    File configFile = SPIFFS.open("/config.json", "w");
    if (!configFile) {
      Serial.println("Failed to open config file for writing");
    }

    json.printTo(Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }

  Serial.println("local ip");
  Serial.println(WiFi.localIP());
  
  Blynk.config(blynk_token);
  Blynk.connect();

}

  void loop()
{
 
  

  Blynk.run(); // Initiates Blynk
  timer.run(); // Initiates SimpleTimer
}```

Is this a commercial project, do you sell the mushrooms, or are you planning to when you move your setup to your different locations?

Pete.

It is a project to make mushrooms to eat at home in salads, I can go on a trip and leave it to a friend, but it is to have in my home, I would like to make a code if I need to move it connect quickly

My guess is that your serial may motor says “Failed to connect and hit timeout” because of this.

Also, having your LCD code in void setup will mean that it runs only once. I explained where to put it in your other topic

Pete.

in the serial he tells me . failed to read dht sensor
Thank you very much. I will try removing that if and passing the lcd to void? Thank you very much in advance, sorry for my English, which is bad, I live in Argentina, thank you very much Pete

I didn’t say that it needed to be removed. Look at what that line of code says, and ask yourself what you think it is doing.

I’m not sure how much you’ve hacked-around the original code example, but it’s quite a mess at the moment. If the original code has changed very little then I’d recommend looking at some other WiFi manager examples, preferable on the GitHub site.
Get the code working as it is, then add-in your DHT and LCD code.

Working through the code and the serial monitor messages will help you to understand the program flow better.

Pete.

you were right and I want to apologize … I was misinterpreting the code … for years I have been programming in ubuntu c and c ++ … but the truth is that it got complicated for me with this blynk: P … can I ask you a question …? I am trying to do an if according to the temperature, but I would not know if it is done inside the void sensor … there I pass the code that I did so far, would you have any idea where I can read information on how to do it right? … thank you very much pete in advance.

my code for the moment…

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>

#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>

#include <Ticker.h>
Ticker ticker;


char auth[] = "JWhIMCUvU3v0SFL5w1RsfPe74uSPN0bm";       // You should get Auth Token in the Blynk App.

int calentador = 12;

#define DHTPIN 2         // DHT                          ( Pin D4)
#define DHTTYPE DHT22     // DHT 11
#define ledPower 16       // LED Power                    ( Pin D0 )

#define TRIGGER_PIN 0     // Button     Reset Network     ( Pin D3 )
#define LED_PIN 15       // LED        connection status ( Pin D5)

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

void tick()
{
  int state = digitalRead(LED_PIN);
  digitalWrite(LED_PIN, !state);
}
void configModeCallback (WiFiManager *myWiFiManager) {
  ticker.attach(0.2, tick);
}

void setup()
{
  Serial.begin(9600);
   
  pinMode (ledPower,OUTPUT);
  digitalWrite (ledPower, HIGH);
  pinMode(14,INPUT);
 
  pinMode(TRIGGER_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
 
  WiFiManager wifiManager;
  ticker.attach(0.6, tick);
  wifiManager.setAPCallback(configModeCallback);
  if (!wifiManager.autoConnect("Ap Name")) {                          //    your ap name
    ESP.reset();
    delay(1000);
  }
ticker.detach();
digitalWrite(LED_PIN, HIGH);

Blynk.config(auth);


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


}

void loop()
{

  Blynk.run();
  timer.run();
 
  int count = 0;
  Blynk.run();


// Reset the network
  while(digitalRead(TRIGGER_PIN) == LOW) {
    delay(100);
    count++;
    if(count > 30) {
      //ESP.eraseConfig();
      WiFi.disconnect();
      digitalWrite(LED_PIN, LOW);
      delay(1000);
      count = 0;
      digitalWrite(LED_PIN, HIGH);
      delay(100);
      ESP.reset();
      delay(1000);
    }
  }
}

BLYNK_WRITE(V1){
  int control4DigitalPins = param.asInt();
  if(control4DigitalPins == 1){

   
//    digitalWrite(D2, HIGH);                     change this
//    digitalWrite(D3, HIGH);                     change this
    digitalWrite(13, HIGH);
    
      }
      
  else{
//    digitalWrite(D2, LOW);                      change this
//    digitalWrite(D3, LOW);                      change this
    digitalWrite(13, LOW);
  
  }
}

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);
   Serial.println("Humedad:"); 
 Serial.println(h); 
  Serial.println("Temperatura:");
  Serial.println(t);
if( t >= 20)
{
digitalWrite(calentador,HIGH);
Serial.println("Calentador ON");
delay(5000);
}else{
digitalWrite(calentador,LOW);
Serial.println("Calentador OFF");
delay(5000);
}

}
}
// Wait 5 seconds before starting the next reading.
delay(5000);

}```

You need to stop using delays in the way that you are, and use SimpleTimer or BlynkTimer (preferred) to call functions at the intervals you want.

There are lots of great thermostat examples which use hysteresis to smooth out the on/off cycles here on the forum. I’d suggest that you search for these examples.

Pete.

Thank you very much Pete … the truth is that I am starting in this world is wonderful … but it gets complicated … in advance thank you very much for your help and your kindness…

what you know is incredible … thanks pete

I think I’m better with the code, I just need to finish with that if of the void sensor and refine some things … but I can’t find a way to make the heater turn on when the humidity drops to 80º … Look here for solutions, but a lot of information of aka is so that they can set the huemdad I only want that when the 80º garment rises and I cannot do it …

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
#include <Ticker.h>
Ticker ticker;
char auth[] = "JWhIMCUvU3v0SFL5w1RsfPe74uSPN0bm"; // You should get Auth Token in the Blynk App.
#define DHTPIN 2 // DHT ( Pin D4)
#define DHTTYPE DHT22 // DHT 11
#define ledPower 16 // LED Power ( Pin D0 )
#define TRIGGER_PIN 0 // Button Reset Network ( Pin D3 )
#define LED_PIN 15 // LED connection status ( Pin D5)
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void tick()
{
int state = digitalRead(LED_PIN);
digitalWrite(LED_PIN, !state);
}
void configModeCallback (WiFiManager *myWiFiManager) {
ticker.attach(0.2, tick);
}
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0,0); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("********************"); //Imprimimos un mensaje inicial
lcd.setCursor(0,1);
lcd.print("**HONGO HOUSE V1.0**");
lcd.setCursor(0,2);
lcd.print("********************");
lcd.setCursor(0,3);
lcd.print("****BY***PABLITO****");
delay(10000); //Esperamos 2 segundos
lcd.clear(); //Borramos lo que pone a la pantalla
pinMode (ledPower,OUTPUT);
digitalWrite (ledPower, HIGH);
pinMode(14,INPUT);
pinMode(TRIGGER_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
WiFiManager wifiManager;
ticker.attach(0.6, tick);
lcd.setCursor(0,0); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("CONECTAME A LA WI-FI");
lcd.setCursor(3,1); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("HONGO HOUSE AP");
lcd.setCursor(1,2); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("PASS: laputaclave");
lcd.setCursor(3,3); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("ASI EMPEZAMOS ");
wifiManager.setAPCallback(configModeCallback);
if (!wifiManager.autoConnect("Hongo House AP","laputaclave")) { // your ap name
ESP.reset();
delay(1000);
}
ticker.detach();
digitalWrite(LED_PIN, HIGH);
lcd.setCursor(0,0); //Ponemos el cursor en la primera fila a la izquierda
lcd.print(" CONECTADO WI-FI ");
lcd.setCursor(0,1); //Ponemos el cursor en la primera fila a la izquierda
lcd.print(" ***************** ");
lcd.setCursor(0,2);
lcd.print(" BIENVENIDO ");
lcd.setCursor(0,3);
lcd.print(" VAMOS A TRABAJAR ");
delay(5000); //Esperamos 2 segundos
lcd.clear();
Blynk.config(auth);
//wifiManager.resetSettings(); //resetear
dht.begin();
timer.setInterval(1000L, SendSensor);
}
void loop()
{
Blynk.run();
timer.run();
int count = 0;
Blynk.run();
// Reset the network
while(digitalRead(TRIGGER_PIN) == LOW) {
delay(100);
count++;
if(count > 30) {
//ESP.eraseConfig();
WiFi.disconnect();
digitalWrite(LED_PIN, LOW);
lcd.setCursor(0,1); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("***WI-FI OFFLINE***");
delay(1000);
lcd.clear();
count = 0;
digitalWrite(LED_PIN, HIGH);
delay(100);
ESP.reset();
delay(1000);
}
}
}
BLYNK_WRITE(V1){
int control4DigitalPins = param.asInt();
if(control4DigitalPins == 1){
// digitalWrite(D2, HIGH); change this
// digitalWrite(D3, HIGH); change this
digitalWrite(13, HIGH);
}
else{
// digitalWrite(D2, LOW); change this
// digitalWrite(D3, LOW); change this
digitalWrite(13, LOW);
}
}
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;
}
if(h >= 80.0)
{
Serial.println("Calentador ON..");
digitalWrite(12, HIGH);
}
else if(h < 80.0){
digitalWrite(12, LOW);
Serial.println("Calentador OFF");
}
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
lcd.setCursor(0,0);
lcd.print("TEMPERATURA: ");
lcd.print(t);
lcd.print("c");
lcd.setCursor(4,1);
lcd.print("HUMEDAD: ");
lcd.print(h);
lcd.print("%");
lcd.setCursor(5,3);
lcd.print("HONGO HOUSE");
timer.setInterval(1000,SendSensor);
}```

Trust me, your code is not a good place to start from.
Blynk will not tolerate delays in the void loop or within functions that are called regularly, they will cause disconnections and instability.
Added to that, your code is all wrong, with timer declarations that belong in the void setup appearing in your other functions.

Pete.

You’re right Pete, it’s my first time with blynk, and it’s kind of complicated, I’m going to look at the simple timer first, the truth is I’m going to have to look at information to use it well, can I ask you what you call an empty loop? so I can fix my code before continuing?

I assume that void loop has translated into empty loop?
This is what your void loop should look like…

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

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/keep-your-void-loop-clean

Pete.

Thank you very much Pete in advance … I figured out that I’m going to separate it into 3 sections … what is a dht22 reader on the one hand, the lcd on the other and just put it together with blynk so by the way I understand the code better since I don’t I am understanding a lot and I know that I have more libraries … and I have to change many things that is why I will do it separately and change the dely for SimpleTimer in each of the parts, I will study it better Thank you very much for your kindness to tell me things in a good way when you know they are wrong … hahaha thank you

Personally, I’d have…

A timed function which reads the current temperature and humidity.

A function called from the one above which evaluates whether the readings are outside the acceptable parameters and takes the necessary action (turn on heaters etc).

A function which updates Blynk with the latest values and statuses, and which also updates the LCD with the same info.

The rest depends on how sophisticated you want to be with auto/manual modes, temporary overrides, sensitivity parameters, etc.

Pete.

Thank you very much and you are right, I will try to do it in those steps, since it would be the right thing to do, thank you very much for the time you spend …

Paul

I do not want to bother him more, but I could order it and have a little more ordered the code, at the moment it works, I am not going to lie I do not know if it is stable, but I could improve it a little more for what little I know, if you see something that is wrong or out of place could you tell me to change it, I don’t want to steal your time thanks a lot pete…

#include <ESP8266WiFi.h>
#include <DHT.h>
#include <SimpleTimer.h>
#include <LiquidCrystal_I2C.h>
#include <BlynkSimpleEsp8266.h>
LiquidCrystal_I2C lcd(0x27,20,4); 
#include <WiFiManager.h>
#include <Ticker.h>


Ticker ticker;
char auth[] = "JWhIMCUvU3v0SFL5w1RsfPe74uSPN0bm";       // You should get Auth Token in the Blynk App.

#define DHTPIN 2         // DHT                          ( Pin D4)
#define DHTTYPE DHT22     // DHT 11
#define ledPower 16       // LED Power                    ( Pin D6 )
//#define TRIGGER_PIN 0     // Button     Reset Network     ( Pin D5 )
#define LED_PIN 15       // LED        connection status ( Pin D8)
#define relay 12

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

void tick()
{
  int state = digitalRead(LED_PIN);
  digitalWrite(LED_PIN, !state);
}
void configModeCallback (WiFiManager *myWiFiManager) {
  ticker.attach(0.2, tick);
}


float humax = 80;


BLYNK_WRITE(V1){
  int control4DigitalPins = param.asInt();
  if(control4DigitalPins == 1){

   
//    digitalWrite(D2, HIGH);                     change this
//    digitalWrite(D3, HIGH);                     change this
    digitalWrite(13, HIGH);
   
      }
     
  else{
//    digitalWrite(D2, LOW);                      change this
//    digitalWrite(D3, LOW);                      change this
    digitalWrite(13, LOW);
 
  }
}

void setup() {
  
Serial.begin(9600);
dht.begin();
lcd.init();
lcd.backlight();
pinMode (ledPower,OUTPUT);
  digitalWrite (ledPower, HIGH);
  pinMode(14,INPUT);
  pinMode(LED_PIN, OUTPUT);
lcd.setCursor(0,0); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("*Conectar a la red* ");
lcd.setCursor(0,1); //Ponemos el cursor en la primera fila a la izquierda
  lcd.print("***HONGO HOUSE AP***");
  lcd.setCursor(0,2);
  lcd.print("*Pass: laputaclave* ");
  WiFiManager wifiManager;
  ticker.attach(0.6, tick);
  wifiManager.setAPCallback(configModeCallback);
  if (!wifiManager.autoConnect("Hongo Casita AP","laputaclave")) {                          //    your ap name
    ESP.reset();
    delay(1000);
  }
ticker.detach();
digitalWrite(LED_PIN, HIGH);
lcd.clear();
lcd.setCursor(0,0); //Ponemos el cursor en la primera fila a la izquierda
lcd.print("*****CONECTADO *****");
lcd.setCursor(0,1); //Ponemos el cursor en la primera fila a la izquierda
  lcd.print("***HONGO HOUSE AP***");
  lcd.setCursor(0,3);
  lcd.print("*****BIENVENIDO*****");
  delay(5000); //Esperamos 2 segundos
  lcd.clear(); 
  
Blynk.config(auth);

pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
delay(2000);
timer.setInterval(60000, SendSensor);
timer.setInterval(2000, lcd2);

}


void SendSensor()
{


 // put your main code here, to run repeatedly:
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
  
if (h > humax) { 
lcd.setCursor(0,2);
lcd.print("Calentador OFF ");
digitalWrite(relay, LOW);
}

else if (h <= humax) {
  lcd.setCursor(0,2);
  lcd.print("Calentador ON ");
  digitalWrite(relay, HIGH);
  
}

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

}



void lcd2 () 
{ 
 
 float h = dht.readHumidity();
 float t = dht.readTemperature();
  
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  
    lcd.setCursor(0,0);
    lcd.print("Temperatura: ");
    lcd.print(t);
    lcd.print("c");
    lcd.setCursor(0,1);
    lcd.print("Humedad: ");
    lcd.print(h);
    lcd.print("%");
    

}


void loop() {

Blynk.run();
timer.run();
// Reset the network
  
 
}```