I was trying to display the readings of my dht11 sensor on the Blynk dashboard but I am struggling a lot. A little help would be really appreciated.
#define BLYNK_PRINT Serial
/* Fill in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL3cu_fjr1u"
#define BLYNK_TEMPLATE_NAME "DHT11 Example"
#define BLYNK_AUTH_TOKEN "bpPlBa8ehOqw0sJLKJeO1thMlulVXUCY"
#include <DHT.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***";
char pass[] = "***";
#define DHTPIN 2 // What digital pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5)
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);
Blynk.virtualWrite(V6, t);
}
void setup()
{
// Debug console
Serial.begin(9600);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}
When I run this, it gets uploaded with no error, but Blynk shows that the device is offline and this is shown in the serial monitor of Arduino IDE:
15:38:20.658 -> ELF file SHA256: 4b7072eae
15:38:20.699 ->
15:38:20.735 -> Rebooting...
15:38:20.735 -> �[5001] Connecting to 0.0.0.0
15:38:26.059 ->
15:38:26.092 -> assert failed: xQueueSemaphoreTake queue.c:1709 (( pxQueue ))
15:38:26.181 ->
15:38:26.181 ->
15:38:26.181 -> Backtrace: (some lot of characters)
15:38:26.512 ->
15:38:26.512 ->
15:38:26.545 ->
15:38:26.545 ->
15:38:26.545 -> ELF file SHA256: 4b7072eae
15:38:26.578 ->
15:38:26.578 -> Rebooting...
15:38:26.614 -> ��[5001] Connecting to 0.0.0.0
15:38:35.107 ->
15:38:35.140 -> assert failed: xQueueSemaphoreTake queue.c:1709 (( pxQueue ))
15:38:35.206 ->
15:38:35.206 ->
15:38:35.206 -> Backtrace: (some lot of characters)
15:38:35.590 ->
15:38:35.590 ->
15:38:35.590 ->
15:38:35.590 ->
15:38:35.626 -> ELF file SHA256: 4b7072eae
15:38:35.626 ->
15:38:35.626 -> Rebooting...
15:38:35.668 -> �
Please help
-
1you don't have the necessary WiFi credentials to connect to your LANjsotola– jsotola04/08/2025 19:20:18Commented Apr 8 at 19:20
-
1@jsotola I do, I have removed them before posting the codeKnightRiderDutt– KnightRiderDutt04/09/2025 06:22:51Commented Apr 9 at 6:22
2 Answers 2
Call Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass)
to establish a WiFi connection first.
See ESP32_WiFi.ino example.
You're missing the Blynk.begin(auth, ssid, pass) call. Without it, Blynk never initializes properly, and that causes the queue/semaphore crash. The setup must look like this:
void setup()
{
Serial.begin(9600);
delay(1000); // Give time to serial to initialize
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
dht.begin();
timer.setInterval(1000L, sendSensor);
}