Introduction: ESP32 + DHT11 Weather Monitor for V-VAC Dashboard
Want to build your own tiny weather station?
In this DIY guide, we’ll use an ESP32 and a DHT11 sensor to send temperature and humidity straight to the V-VAC IoT dashboard using MQTT.
It’s super simple, beginner-friendly, and a great way to get started with real cloud-connected projects.
Let’s build it!
Supplies
- ESP32 Dev Board
- DHT11 Temperature/Humidity Sensor module
- Jumper wires
- Breadboard
- A Wi-Fi connection
- Your V-VAC MQTT topic (given by V-VAC)
Step 1: Wiring the DHT11
Connect the Esp32 and Sensor according to the connection Diagram.
Step 2: Installing Libraries
- WiFi by Arduino // This library is usually built-in, but verify that it is installed.
- DHT SENSOR LIBRARY by Adafruit
- PubSubClient by Nick O'Leary
Step 3: VVAC Cloud Setup
Steps to Connect V-VAC :
- Log in to your V-VAC account. (Create a new account if not signed up already.)
- In the Devices section add a new device.
- Select common device and enter the details of the device.
- Copy the Device Token and paste it in the MQTT section of the code.
- Copy the username and password from the setup in devices section and paste it in the MQTT section of the code.
For further details check out (How to connect to V-VAC).
Step 4: Upload the Code
#include <WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>
#define DHT11_PIN 4
DHT dht11(DHT11_PIN, DHT11);
// WiFi Configuration
const char* ssid = "Your_Wifi_SSID"; // eg. ssid = "ssid"
const char* password = "Your_Wifi_Password"; // eg. password = "password"
// MQTT Configuration
const char* mqtt_broker = "data.volkkommen.com";
const int mqtt_port = 1883;
const char* mqtt_username = "Your_MQTT_Username"; // eg. mqtt_username = "mqtt_username"
const char* mqtt_password = "Your_MQTT_Password"; // eg. mqtt_password = "mqtt_password"
const char* device_token = "Your_Device_Token"; // eg. device_token = "6810eb7g27560f46"
WiFiClient espClient;
PubSubClient mqttClient(espClient);
void setupWiFi() {
Serial.println();
Serial.print("Connecting to WiFi: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void connectMQTT() {
while (!mqttClient.connected()) {
Serial.print("Attempting MQTT connection... ");
if (mqttClient.connect(device_token, mqtt_username, mqtt_password)) {
Serial.println("connected to MQTT broker");
} else {
Serial.print("failed, rc=");
Serial.print(mqttClient.state());
Serial.println(" trying again in 5 seconds");
delay(5000);
}
}
}
String sensor_working() {
// Example data (modify with your sensor/data)
float humi = dht11.readHumidity();
// read temperature in Celsius
float tempC = dht11.readTemperature();
// read temperature in Fahrenheit
float tempF = dht11.readTemperature(true);
// check whether the reading is successful or not
if ( isnan(tempC) || isnan(tempF) || isnan(humi)) {
Serial.println("Failed to read from DHT11 sensor!");
} else {
Serial.print("Humidity: ");
Serial.print(humi);
Serial.print("%");
Serial.print(" | ");
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.print("°C ~ ");
Serial.print(tempF);
Serial.println("°F");
}
// wait a 2 seconds between readings
delay(2000);
String payload = "{\"temperature\":" + String(tempC, 3) + ",\"humidity\":" + String(humi, 3) + "}";
return payload;
}
void publishData() {
String payload = sensor_working();
String topic_p = "data/v1/" + String(device_token);
if (mqttClient.publish(topic_p.c_str(), payload.c_str())) {
Serial.println("Message published successfully " + payload);
} else {
Serial.println("Failed to publish message");
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(115200);
dht11.begin();
setupWiFi();
mqttClient.setServer(mqtt_broker, mqtt_port);
}
void loop() {
if (WiFi.status() != WL_CONNECTED) { // Maintain WiFi connection
setupWiFi();
}
if (!mqttClient.connected()) { // Maintain MQTT connection
connectMQTT();
}
mqttClient.loop();
static unsigned long lastPublishTime = 0; // Publish data every 2 seconds
if (millis() - lastPublishTime >= 2000) {
publishData();
lastPublishTime = millis();
}
}
Step 5: View Live Data in V-VAC
- In Dashboard section you can configure widgets for your required data.
- Click “Create Dashboard”.
- Give your dashboard a name (e.g., Door Status Dashboard).
- Click the 3rd icon in the dashboard to open the dashboard.
- Inside the dashboard editor, click “Edit” and click "Add Widget" to add new widgets.
- In the selection menu choose the required widget.
- Link widget to a Device telemetry key (the data your device sends).
- After customizing your widget, click the Show on Dashboard button to display it on the dashboard.
- To save your changes, click the Save button at the top-right corner of the dashboard.
- You can now remotely see the Door status from anywhere around the world.
For more IoT projects and tutorials, visit the official V-VAC Platform - V-VAC.





