Community project

temperatura ventilador

Photo of temperatura ventilador
Generated with AI

EJEZ3D

Published November 30, 2026

This project combines temperature and humidity monitoring with presence detection and automatic fan control on an ESP32. The round 1.28-inch display shows real-time DHT22 sensor readings, while the HLK-LD2410C radar module detects nearby movement. When motion is detected, the system can automatically trigger a brushed DC motor (fan) via an NPN transistor driver circuit.

The guide provides a complete wiring diagram connecting the GC9A01A display, DHT22 sensor, presence radar, and motor control circuit to the ESP32. Assembly steps cover safe component connection with power disconnected, sensor testing procedures, and firmware upload. Readers will receive the full source code, parts list, and step-by-step instructions to build a smart ventilation controller with visual feedback.

Wiring diagram

Wiring diagram for temperatura ventilador
Loading diagram…

Gather all the parts

QtyComponent
1

GC9A01 Round TFT LCD 1.28 inch 240x240

1.28 inch round IPS TFT LCD display module with GC9A01/GC9A01A driver IC. 240x240 RGB resolution, 4-wire SPI interface, and 3.3V/5V module input. Module-side labels are VCC, GND, DIN, CLK, CS, DC, RST, and BL/BLK. The display is write-only over SPI, so no MISO line is required for the LCD. Supported by Adafruit GC9A01A and TFT_eSPI libraries in Arduino-compatible firmware projects.

1

DHT22

AM2302 on V182 adapter with integrated pull-up

Digital temperature and humidity sensor

1

Hi-Link HLK-LD2410C V1.1

Exact C variant with 3.3 V OUT per Hi-Link; generic LD2410 catalog levels do not apply.

1

130 Brushed DC Motor

Two-terminal 130-size brushed motor.

1

NPN Transistor (2N2222 / BC547)

PN2222

General-purpose NPN bipolar junction transistor (BJT) in TO-92 package. Used as a low-side switch to drive loads (e.g. buzzers) whose current exceeds ESP32 GPIO source capability (~12 mA). A ~1 kΩ base resistor is placed between the ESP32 GPIO and the transistor base. The collector connects to the load negative terminal (buzzer –), and the emitter connects to GND. When the GPIO goes HIGH (3.3 V), the transistor saturates and switches the load on. Compatible with both 2N2222/2N2222A and BC547/BC547B variants. Add a flyback diode (e.g. 1N4148) across inductive load terminals.

1

Resistor

220 Ω

Through-hole resistor (current-limiting in series with an LED)

1

1N4007 Diode

General-purpose silicon rectifier diode in DO-204AL (DO-41) axial through-hole package. Rated 1A average forward current and 1000V peak reverse voltage (VRRM). Forward voltage drop ~0.7V at typical load (up to 1.1V at full 1A). Used here in series with LM7805 Vout for reverse polarity protection: anode to LM7805 output, cathode to 5V rail, resulting in ~4.3V on the output rail. Not suitable for high-frequency switching (reverse recovery ~2µs–30µs); intended for DC or 50/60Hz rectification only.

Assemble it in 5 steps

1. Conecta la pantalla sin alimentación

Desenchufa el USB. Conecta VCC a 3V3 y GND a GND. Conecta SCL a GPIO18, SDA a GPIO23, DC a GPIO27, CS a GPIO25 y RST a GPIO26.

  • No uses VIN ni 5V. Guíate por las etiquetas: VCC y SDA son ambos morados.

2. Añade el DHT22 V182

Con el USB desconectado, conecta VCC a 3V3, GND a GND y DATA a GPIO32. Sigue las etiquetas del módulo, no la posición de los pines. Comparte alimentación y tierra con la pantalla. No añadas otra resistencia.

3. Prueba el sensor

Conecta el USB y pulsa Deploy. La pantalla muestra temperatura y humedad sin Wi-Fi. Si aparece Sin lectura, revisa los tres cables del sensor.

4. Añade el radar de presencia

Desenchufa el USB. Identifica los pines por las etiquetas impresas, no por la orientación del dibujo. El orden numerado por Hi-Link es 1 TX, 2 RX, 3 OUT, 4 GND y 5 VCC. Conecta VCC del radar a VIN (5 V del USB), GND a GND y OUT a GPIO33. Deja TX y RX sin conectar; solo se usan para comunicación serie y no hacen falta para detectar presencia. Reconecta el USB y prueba entrando y saliendo de la zona de detección. La pantalla conserva temperatura y humedad y muestra persona detectada cuando OUT se activa.

  • No conectes VCC del radar a 3V3 ni una fuente externa a VIN mientras uses USB.

5. Cablea el motor con ambas alimentaciones desconectadas

Conecta GPIO21 a la base mediante la resistencia de 220 Ω. Une el emisor a GND común y el colector a M-. Conecta el diodo en paralelo con el motor, con la franja gris hacia M+ y el extremo sin franja hacia M-. Usa una fuente independiente del voltaje nominal del motor, positivo a M+ y negativo a GND del ESP32. El programa enciende a partir de 25 °C y apaga a 24 °C o menos. Entre ambos umbrales conserva el estado anterior; también apaga si falla la lectura.

  • Verifica las patas B, C y E en la hoja de datos de tu transistor exacto. No siguen el mismo orden en todos los modelos.
  • No conectes el motor a 3V3, VIN ni a un GPIO. Antes de alimentarlo verifica que la corriente de arranque o bloqueo del motor sea compatible con la corriente que el transistor puede conmutar con esta resistencia. Si no, usa un controlador de motor dimensionado para esa corriente.

Review all connections

1. Connections between "tft" and "ESP32"

FunctiontftESP32
powerVCC3V3
groundGNDGND
spiSCK → SCL azul en tu pantallaGPIO 18
spiMOSI → SDA morado en tu pantallaGPIO 23
digitalDCGPIO 27
spiCSGPIO 25
digitalRSTGPIO 26

2. Connections between "sensor" and "ESP32"

FunctionsensorESP32
powerVCC3V3
groundGNDGND
dataDATAGPIO 32

3. Connections between "radar" and "ESP32"

FunctionradarESP32
powerVCC → Alimentación de 5 V desde el USB del ESP32VIN
groundGNDGND
digitalOUT → Señal de presencia de 3,3 V. TX y RX se dejan sin conectar.GPIO 33

4. Connections between "base_resistor" and "ESP32"

Functionbase_resistorESP32
digitalP1GPIO 21
digitalP2 → NPN Transistor (2N2222 / BC547) BASEEXT

5. Connections between "transistor" and "ESP32"

FunctiontransistorESP32
groundEMITTERGND

6. Connections between "motor" and "ESP32"

FunctionmotorESP32
dataM- → NPN Transistor (2N2222 / BC547) COLLECTOREXT
powerM+ → Motor supply positiveEXT

7. Connections between "flyback" and "ESP32"

FunctionflybackESP32
powerAnode → NPN Transistor (2N2222 / BC547) COLLECTOREXT
powerCathode → 130 Brushed DC Motor M+EXT

Deploy the firmware

#include <Arduino.h>
#include <Adafruit_GC9A01A.h>
#include <DHT.h>

Adafruit_GC9A01A tft(25, 27, 26);
DHT sensor(32, DHT22);
String oldTemp, oldRH, oldStatus;
constexpr int radarOutPin = 33;
constexpr int motorPin = 21;
bool motorOn = false;
uint32_t lastRead;

void center(int y, int size, uint16_t color, const String &text) {
  tft.setTextSize(size);
  tft.setTextColor(color);
  tft.setCursor((240 - 6 * size * int(text.length())) / 2, y);
  tft.print(text);
}
void update(String &old, const String &text, int y, int size, uint16_t color) {
  if (old == text) return;
  old = text;
  tft.fillRect(40, y, 160, size * 8, 0);
  center(y, size, color, text);
}
void setup() {
  pinMode(motorPin, OUTPUT);
  digitalWrite(motorPin, LOW);
  pinMode(radarOutPin, INPUT_PULLDOWN);
  tft.begin(10000000);
  tft.fillScreen(0);
  tft.drawCircle(120, 120, 116, 0x03EF);
  center(31, 2, 0xFFFF, "DHT22");
  center(65, 2, 0xFFE0, "Temperatura");
  center(124, 2, 0x07FF, "Humedad");
  update(oldStatus, "Iniciando...", 189, 1, 0xFFFF);
  sensor.begin();
  lastRead = millis();
}
void loop() {
  bool present = digitalRead(radarOutPin) == HIGH;
  // OUT indica presencia; no hace falta conectar TX ni RX.
  static int lastPresence = -1;
  if (lastPresence != present) {
    lastPresence = present;
    tft.fillRoundRect(53, 200, 134, 18, 5, present ? 0x07E0 : 0x2104);
    center(205, 1, present ? 0x0000 : 0xFFFF,
           present ? "persona detectada" : "Sin presencia");
  }
  uint32_t now = millis();
  if (now - lastRead < 2500) return;
  lastRead = now;
  float h = sensor.readHumidity();
  float t = sensor.readTemperature();
  bool ok = isfinite(h) && isfinite(t) && h >= 0 && h <= 100 && t >= -40 && t <= 80;
  // Compare in tenths, matching the DHT22 and the displayed reading.
  const int tenths = ok ? lroundf(t * 10.0f) : 0;
  if (!ok || tenths <= 240) motorOn = false;
  else if (tenths >= 250) motorOn = true;
  digitalWrite(motorPin, motorOn ? HIGH : LOW);
  update(oldTemp, ok ? String(t, 1) + " C" : "-- C", 88, 3, 0xFFE0);
  update(oldRH, ok ? String(h, 1) + " %" : "-- %", 147, 3, 0x07FF);
  update(oldStatus, ok ? (motorOn ? "Motor: ON" : "Motor: OFF") : "Sin lectura: revisa DATA", 189, 1, ok ? 0x07E0 : 0xF800);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik