GROUU · Projects · Basic Sensor Node
Completed · replicable recipe

Basic Sensor Node

GROUU's basic node for local sensing: an ESP32 that reads a sensor and publishes JSON over WiFi + MQTT, with reconnect logic and over-the-air updates. A complete, forkable firmware template — the learning module the water and climate nodes build on.

ESP32 DHT22 MQTT · PubSubClient ArduinoOTA PlatformIO
The basic WiFi sensor node — ESP32 + DHT22
01 · Overview

What it is

The basic node is the completed, replicable starting point of GROUU: an ESP32 that reads a sensor and publishes JSON over WiFi + MQTT to the shared stack, reconnecting on its own and updatable over the air. In the research process it is the foundational learning module the water and climate nodes extend.

Overview
Sense, publish, stay reachable

Sense → publish over WiFi / MQTT → the shared stack picks it up.

Sensor
DHT22
temperature + humidity · single-wire
data
Node
ESP32 (XIAO-C3)
read · JSON · auto-reconnect · OTA
WiFiMQTT
Broker
Mosquitto
<host>/sensors · system/set · system/log
Stack
Node-RED · InfluxDB · Grafana
store + visualise
02 · Design

Naming & topics convention

The node is a convention as much as code: each node is named by the GROUU scheme, and its MQTT topics derive automatically — so a fleet stays organised and any node's data is addressable without per-node wiring.

Grouu[Installation][Type][ID]
<host>/sensors
Publishes the JSON reading every 3 s
system/set/<host>
Subscribes for control — OTA_ON / REBOOT
system/log/<host>
Publishes connection & status logs
03 · Hardware

Two parts on a dev board

Runs on a stock ESP32 dev board — no custom PCB. Breadboard-simple: an MCU, a sensor and a pull-up.

PartRoleSource
ESP32 dev boardMCU + WiFi (the PlatformIO env targets a XIAO ESP32-C3)
DHT22 (AM2302)Temperature + humidity (factory-calibrated, no user cal), data on pin D7
4.7k–10k pull-upOn the DHT data line
MQTT brokerAny — e.g. the GROUU StackServer Stack
04 · Software

Read, publish, stay reachable

One PlatformIO/Arduino project: join WiFi with auto-reconnect, read the DHT22, publish {"t2":x,"h2":x} every 3 s, and stay updatable over the air. Libraries: WiFi, Adafruit_Sensor + DHT, ArduinoJson, PubSubClient, ArduinoOTA.

src/main.cpp — read the DHT22, publish JSON over MQTT

void publishValues() {
  JsonDocument doc;
  char output[80];
  float newT = dht.readTemperature();
  float newH = dht.readHumidity();
  if (isnan(newT)) {
    Serial.println("Failed to read from DHT sensor!");
  } else {
    doc["t2"] = newT;
    doc["h2"] = newH;
    serializeJson(doc, output);
    client.publish(MQTT_room_sensors_PUBLISH_TOPIC.c_str(), output);
  }
}
05 · Process

Done — four steps to a running node

This node is complete as a firmware template. To reuse it: clone, configure, flash, point it at a broker.

01
Clone

Pull the basic-node folder from the repo.

02
Configure

Set installation, WiFi and broker; wire the DHT22.

03
Flash

Build & upload with PlatformIO.

04
Point at a broker

Any MQTT broker — e.g. the GROUU Stack.

Gallery

Node & variants

Soil-sensor variant sketch for the basic node
Soil-sensor variant — sketch