ESP266 Relay Timer
Posted: Tue May 10, 2022 1:47 pm
hello. I am new to the community.
I have an ESP2866 + relay module, which I bought on Aliexpress, in order to place a timer on some electric stoves that I have in my house. The relay cuts off the flow of current to the stove after 40 minutes. It is something very simple.
Initially I did it through Blink to be able to control them over the internet, but after a while it was more useful and faster to just reset the ESP2866 using the reset button, since when resetting, the module connects to Wi-Fi again and reconnects the relay up to 40 minutes, so I hardly use the blynk app anymore.
The issue is that I want to unlink the modules from the internet, that is, since I am not using the blynk app, I do not need them to connect to wifi. I tried to do it by modifying the code they currently use, but it doesn't work for me. For some reason the ESP2866 doesn't do what I want if it's not connected to wifi.
This is the code I have
I have tried to eliminate everything related to blink but it does not work. What I need is that the module, after turning it on/reset it, connects the relay for 40 minutes and then turns it off. No internet, no wifi, nothing, just that.
Can the module work without Wi-Fi or does it need to be connected? I do not think so...
Can you help me please? THANKS!!
I have an ESP2866 + relay module, which I bought on Aliexpress, in order to place a timer on some electric stoves that I have in my house. The relay cuts off the flow of current to the stove after 40 minutes. It is something very simple.
Initially I did it through Blink to be able to control them over the internet, but after a while it was more useful and faster to just reset the ESP2866 using the reset button, since when resetting, the module connects to Wi-Fi again and reconnects the relay up to 40 minutes, so I hardly use the blynk app anymore.
The issue is that I want to unlink the modules from the internet, that is, since I am not using the blynk app, I do not need them to connect to wifi. I tried to do it by modifying the code they currently use, but it doesn't work for me. For some reason the ESP2866 doesn't do what I want if it's not connected to wifi.
This is the code I have
Code: Select all
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "XXXXXXXXXXXXXXXXXX";
char ssid[] = "XXXXX";
char pass[] = "XXXXXX";
const int buttonPin = 0;
int buttonState = 0;
unsigned long tiempo1 = 0;
unsigned long tiempo2 = 0;
unsigned long tiempoSegundos = 0;
int GPIO_0 = 0; //To control Device
int GPIO_0State; //State of device
void setup()
{
Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
GPIO_0State = digitalRead(GPIO_0); //State of device 2 (on/Off)
if (GPIO_0State == 0) {
tiempo2 = millis();
} else{
tiempo1 = millis();
}
if ((tiempo2 - tiempo1) > 2400000){ //40 minutos de uso
digitalWrite(GPIO_0, HIGH);
}
Serial.println(tiempo1);
Serial.println(tiempo2);
Serial.println(GPIO_0State);
}
I have tried to eliminate everything related to blink but it does not work. What I need is that the module, after turning it on/reset it, connects the relay for 40 minutes and then turns it off. No internet, no wifi, nothing, just that.
Can the module work without Wi-Fi or does it need to be connected? I do not think so...
Can you help me please? THANKS!!