ESP32 capabilities relevant to sensor networks
The ESP32 (manufactured by Espressif Systems) integrates a dual-core 240 MHz processor, 520 KB SRAM, Wi-Fi 802.11 b/g/n, and Bluetooth 4.2 in a single module. For sensor networking, the key advantage over standard Arduino boards is the built-in Wi-Fi: each node can connect to a router and transmit data without an additional network shield.
Development boards based on the ESP32-WROOM-32 module expose 34 GPIO pins, multiple hardware serial ports, SPI, I2C, and an ADC with multiple channels. These are programmed through the Arduino IDE using the ESP32 board support package from Espressif, or through MicroPython.
Architecture of a sensor network
A typical hobbyist setup places multiple ESP32 nodes around a building — one in each room, or outdoors for garden monitoring. Each node reads one or more sensors and publishes data to a central MQTT broker running on a Raspberry Pi or home server. A visualisation layer (Grafana, Node-RED) then reads from that broker and displays time-series data.
MQTT protocol basics
MQTT (Message Queuing Telemetry Transport) uses a publish/subscribe model. Each ESP32 node publishes sensor readings to a topic such as home/living-room/temperature. The broker (typically Eclipse Mosquitto) receives and routes messages to any subscribed clients. This architecture is lightweight and tolerant of intermittent connectivity.
Setting up the MQTT broker on Raspberry Pi
Install Mosquitto on Raspberry Pi OS:
By default, Mosquitto listens on port 1883 without authentication on the local network. For a home network with no external access, this is adequate. For stricter setups, create a password file using mosquitto_passwd.
Programming an ESP32 node
Install the ESP32 board support package in Arduino IDE by adding Espressif's board manager URL under Preferences. Then install the PubSubClient library by Nick O'Leary for MQTT communication.
When flashing an ESP32 board that uses a CH340 USB chip, hold the BOOT button on the board while clicking Upload in the Arduino IDE. Release the button once the upload starts. Some boards flash automatically without this step.
Adding a motion sensor node
A PIR HC-SR501 module connects to a single digital GPIO pin. When motion is detected, the output pin goes HIGH for a configurable duration (set by the onboard potentiometer). Publish the event via MQTT:
Visualising data with Grafana
Grafana running on the same Raspberry Pi as Mosquitto (or on a separate machine) can read MQTT data via the Grafana MQTT plugin or through an intermediate time-series database. InfluxDB is commonly paired with this stack: a Node-RED flow subscribes to all MQTT topics and writes readings to InfluxDB, which Grafana queries for dashboard panels.
The full local stack — ESP32 nodes → Mosquitto → Node-RED → InfluxDB → Grafana — runs entirely on a home network with no external cloud accounts required.
Power and enclosure considerations
An ESP32 development board draws roughly 160–240 mA during active Wi-Fi transmission. For battery-powered outdoor nodes, the deep sleep mode reduces current draw to under 10 µA between measurements. A 3000 mAh LiPo cell paired with a TP4056 charging module and a 30-minute measurement interval can sustain a node for several weeks before recharging.
Outdoor enclosures rated IP65 or higher are available at Polish electrical supply stores. The enclosure should include a cable gland for the sensor wires and ventilation holes if the sensor measures ambient air temperature.