i upload correct code in ESP8266 with correct wifi ssd and pass and auth token
but ESP8266 is not staying connected to my Wi-Fi network and disconnects automatically after a few seconds
i Test with different Wi-Fi networks and still not work
Can’t really help unless you share your code and the output from your serial monitor.
Pete.
this is my code:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Set the credentials for your Wi-Fi network
char auth[] = "tJlgAokEfDnUFPyU7sVO-pFouxo9I_fd";
char ssid[] = "Hassan's Galaxy A22";
char pass[] = "hassan98hassan";
// Pin connected to the LED
int ledPin = 13;
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
Blynk.run();
}
// Blynk virtual pin handler for LED control
BLYNK_WRITE(V0) {
int ledStatus = param.asInt(); // Get value from Blynk app (0 or 1)
if (ledStatus == 1) {
digitalWrite(ledPin, HIGH); // Turn on the LED
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
}
}
and this is serial monitor affichage
[6530] Connecting to blynk-cloud.com:80
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Soft WDT reset
>>>stack>>>
ctx: cont
sp: 3ffffd70 end: 3fffffd0 offset: 01a0
3fffff10: 00000000 000025c6 353f7ced 002bad2d
3fffff20: 00000000 00938e4b 0000464f 002bad30
3fffff30: 0000464f 000025c6 00000000 00001981
3fffff40: 0000464f 00000000 00000000 40204796
3fffff50: 0000464f 00000000 3ffeeb18 40201a40
3fffff60: 00000000 000025c6 370a3d70 002bad2f
3fffff70: 0000004f 000000bb 3ffeebac 00001981
3fffff80: 0000464f 3ffeeb18 00000000 40201ecc
3fffff90: 40207538 8099a8c0 feefeffe feefeffe
3fffffa0: feefeffe feefeffe feefeffe 3ffeed34
3fffffb0: 3fffdad0 00000000 3ffeed08 40204208
3fffffc0: feefeffe feefeffe 3fffdab0 40100e75
<<<stack<<<
he repet that evry 10 second
@Hassan_Jabeur98 Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code and at the beginning and end of your serial output so that they display correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
Pete.
this is my code:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Set the credentials for your Wi-Fi network
char auth[] = "tJlgAokEfDnUFPyU7sVO-pFouxo9I_fd";
char ssid[] = "Hassan's Galaxy A22";
char pass[] = "hassan98hassan";
// Pin connected to the LED
int ledPin = 13;
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
Blynk.run();
}
// Blynk virtual pin handler for LED control
BLYNK_WRITE(V0) {
int ledStatus = param.asInt(); // Get value from Blynk app (0 or 1)
if (ledStatus == 1) {
digitalWrite(ledPin, HIGH); // Turn on the LED
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
}
}
and this is serial monitor affichage
[6530] Connecting to blynk-cloud.com:80
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Soft WDT reset
>>>stack>>>
ctx: cont
sp: 3ffffd70 end: 3fffffd0 offset: 01a0
3fffff10: 00000000 000025c6 353f7ced 002bad2d
3fffff20: 00000000 00938e4b 0000464f 002bad30
3fffff30: 0000464f 000025c6 00000000 00001981
3fffff40: 0000464f 00000000 00000000 40204796
3fffff50: 0000464f 00000000 3ffeeb18 40201a40
3fffff60: 00000000 000025c6 370a3d70 002bad2f
3fffff70: 0000004f 000000bb 3ffeebac 00001981
3fffff80: 0000464f 3ffeeb18 00000000 40201ecc
3fffff90: 40207538 8099a8c0 feefeffe feefeffe
3fffffa0: feefeffe feefeffe feefeffe 3ffeed34
3fffffb0: 3fffdad0 00000000 3ffeed08 40204208
3fffffc0: feefeffe feefeffe 3fffdab0 40100e75
<<<stack<<<
he repet that evry 10 second
This is the Legacy server, which is now decommissioned.
What version of the Blynk library do you have installed, and why don’t you have the three lines of firmware configuration code from the web console Device Info scree at the top of your code?
Pete.
what is the new server can i connect with it
i have blynk 1.2.0 library
you mean this?
#define BLYNK_TEMPLATE_ID "TMPL2GU2w0XOb"
#define BLYNK_TEMPLATE_NAME "final"
#define BLYNK_AUTH_TOKEN "tJlgAokEfDnUFPyU7sVO-pFouxo9I_fd"
It will connect automatically to the correct server if the compiler finds the correct Blynk library and you have the firmware configuration code at the beginning of your sketch.
Yes. That should be the first three lines of your sketch.
You should also delete this…
And replace this…
with this…
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
Do you have any other versions of the Blynk library installed?
Pete.
thanks she work
but after one hour he stop and sho me that message error
A fatal esptool.py error occurred: Failed to connect to ESP8266: Timed out waiting for packet header
You need to share the complete error message, and your updated code.
Pete.
Code
// Blynk identification
#define BLYNK_TEMPLATE_ID "TMPL2GU2w0XOb"
#define BLYNK_TEMPLATE_NAME "final"
#define BLYNK_AUTH_TOKEN "972sCqVPMONTIluNstM7lRIQvp808lRe"
#define BLYNK_PRINT Serial
// include library
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
// Wifi parametre
char ssid[] = "BREAK_TIME";
char pass[] = "18032023";
// define LED Pin
int Chauf = 5; // define chauffage pin D1
int Fri = 4; // define fridge pin D2
int Agitateur = 0; // define Agitateur pinD3
// define Capteur parametre
#define DHTPIN1 13 // define capteur tempureture Isocyanate pin D7
#define DHTPIN2 15 // define capteur tempurature Polyol pin D8
#define DHTTYPE DHT11 // define capteur type
// capteur configuration
DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
BlynkTimer timer;
//get capteur read value
void sendSensor()
{
float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature();
float h2 = dht2.readHumidity();
float t2 = dht2.readTemperature();
//function verification
if (isnan(h1) || isnan(t1) || isnan(h1) || isnan(t1))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
// transmetre tempurature read value in blink
Blynk.virtualWrite(V0, t1); // link V0 with Pol temperature
Blynk.virtualWrite(V1, t2); // link V1 with Iso temperature
}
void setup() {
Serial.begin(9600);
//Blynk connection
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// run capteur
dht1.begin();
dht2.begin();
//initialisation Chauffage pin
pinMode(Chauf, OUTPUT);
digitalWrite(Chauf, LOW);
//initialisation Fridge pin
pinMode(Fri, OUTPUT);
digitalWrite(Fri, LOW);
//initialisation Agitateur pin
pinMode(Agitateur, OUTPUT);
digitalWrite(Agitateur, LOW);
// reponse time interval
timer.setInterval(1000L, sendSensor);
}
void loop() {
//blynk and timer run
Blynk.run();
timer.run();
}
// Agitateur controle
BLYNK_WRITE(V2) {
int Switch1 = param.asInt(); // Get Switch1 value from Blynk app (0 or 1)
if (Switch1 == 1) {
digitalWrite(Agitateur, HIGH); // Turn on Agitateur
} else {
digitalWrite(Agitateur, LOW); // Turn off Agitateur
}
}
// Chauffage controle
BLYNK_WRITE(V3) {
int Switch2 = param.asInt(); // Get Switch2 value from Blynk app (0 or 1)
if (Switch2 == 1) {
digitalWrite(chauf, HIGH); // Turn on chauffage
} else {
digitalWrite(chauf, LOW); // Turn off chauffage
}
}
// Fridge controle
BLYNK_WRITE(V4) {
int Switch3 = param.asInt(); // Get Switch3 value from Blynk app (0 or 1)
if (Switch3 == 1) {
digitalWrite(Fri, HIGH); // Turn on fridge
} else {
digitalWrite(Fri, LOW); // Turn off fridge
}
}
Error message
. Variables and constants in RAM (global, static), used 30868 / 80192 bytes (38%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1532 initialized variables
╠══ RODATA 2560 constants
╚══ BSS 26776 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 61247 / 65536 bytes (93%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 28479 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 253796 / 1048576 bytes (24%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 253796 code in flash
esptool.py v3.0
Serial port COM7
Connecting........_____....._____....._____....._____....._____....._____....._____
A fatal esptool.py error occurred: Failed to connect to ESP8266: Timed out waiting for packet header
This is a compiler message that you’d see when you try to upload a sketch.
It is not a serial monitor message, and not an error that relates to the operation of the device after it’s been running the uploaded code for an hour.
You need to open the serial monitor(button in the top right of the IDE screen) and set the baud rate to the one you are using in your sketch…
I’d also recommend that you don’t try reading your DHT sensors every 1000ms. These sensors are very slow, and I wouldn’t try to read them more than once every 5 seconds.
Pete.
how can i edit read time
1000L means that the sendSensor
function is called every 1000 milliseconds.
1 second = 1000ms, so you are calling this function once every second.
Pete.