Community project

ESP32 Sensor LCD Dashboard

Photo of ESP32 Sensor LCD Dashboard
Generated with AI

Erwin Salibongcogon

Published December 1, 2026

This project builds a multi-sensor environmental dashboard using an Arduino Uno and a 16x2 LCD display. Six sensors monitor temperature and humidity, ambient light, distance, motion detection, and soil moisture, with readings displayed in real-time on the LCD screen.

The guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions starting from a disconnected state. Included firmware cycles through each sensor's readings and can be configured to focus on individual sensors. Builders will learn I2C communication, analog and digital sensor integration, and how to manage multiple inputs on a single microcontroller.

Wiring diagram

Loading diagram…

Gather all the parts

QtyComponent
1

LCD 16x2 I2C

16x2 character LCD display with I2C backpack

1

Gravity DHT11 module DFR0067

Manufacturer rates DFR0067 for 3.3-5V; powered at 5V with 5V data logic. https://www.dfrobot.com/product-174.html

1

Light Sensor Module V3 (LM393 photoresistor)

Light sensor module with a photoresistor and an LM393 comparator on a small blue board. It outputs an analog light-level voltage on AO and a digital signal on DO that switches low when the light is brighter than the threshold set with the onboard trimmer. It runs from 3.3 to 5 V and connects through a 4-pin 2.54 mm right-angle header (VCC, GND, DO, AO).

1

HC-SR04

HC-SR04 ultrasonic distance sensor module with separate 40 kHz transmitter and receiver transducers, measuring 2 to 400 cm. A 10 us pulse on TRIG starts a measurement and ECHO stays high for the echo's round-trip time. This HC-SR04+ board runs from 3.3 V or 5 V.

1

HC-SR501 PIR Motion Sensor

HC-SR501 passive infrared (PIR) motion sensor module with a Fresnel dome lens, detecting moving people up to about 7 m away. Its OUT pin goes to 3.3 V when motion is detected, with trimmers for sensitivity and on-time and a jumper for single or repeat triggering. It runs from 4.5 to 20 V, typically 5 V.

1

Gravity SEN0308 soil moisture sensor

Manufacturer specifies 3.3-5.5V supply and 0-2.9V analog output; A1 is input only. https://wiki.dfrobot.com/sen0308/

Assemble it in 7 steps

1. Start with USB unplugged

Use an Arduino Uno, a breadboard and jumper wires. Connect Uno 5V to the breadboard positive rail and Uno GND to the ground rail. All modules share these rails. Use the named modules with their onboard support components, not bare sensors.

  • Disconnect USB before changing wires. Check printed pin labels rather than assuming pin order.

2. Connect the LCD

Connect LCD VCC to 5V and GND to ground. Connect SDA to A4 for data and SCL to A5 for the clock. Use a 16 by 2 LCD with a PCF8574 I2C backpack at address 0x27 or 0x3F.

  • Turn the small contrast screw on the backpack gently if the text is invisible.

3. Connect the temperature and humidity module

Connect the DFR0067 DHT11 module VCC to 5V, GND to ground and DATA to D2. This is a module with its support circuitry, not the bare four-pin sensor.

4. Connect the light module

Connect light module VCC to 5V, GND to ground and AO to A0 for the analog light reading. Leave DO disconnected. The display shows a raw reading from 0 to 1023, not lux.

5. Connect the distance sensor

Connect HC-SR04 VCC to 5V, GND to ground, TRIG to D6 for the start pulse and ECHO to D7 for the return pulse. Point the two round faces toward a flat target 2 to 400 cm away.

6. Connect the motion sensor

Connect HC-SR501 VCC to 5V, GND to ground and OUT to D3 for movement detection. Allow one minute after powering up for the sensor to settle.

7. Connect the soil sensor

Connect SEN0308 VCC (red) to 5V, GND (black) to ground and AOUT (yellow) to A1. Compare readings in dry and moist soil before interpreting moisture; the program reports raw readings rather than an uncalibrated percentage.

  • Keep the Uno and wiring dry. Do not immerse connectors.

Review all connections

1. Connections between "lcd" and "Arduino"

FunctionlcdArduino
powerVCC5V
groundGNDGND
i2cSDAGPIO 18
i2cSCLGPIO 19

2. Connections between "climate" and "Arduino"

FunctionclimateArduino
powerVCC5V
groundGNDGND
dataDATAGPIO 2

3. Connections between "light" and "Arduino"

FunctionlightArduino
powerVCC5V
groundGNDGND
analogAOGPIO 14

4. Connections between "distance" and "Arduino"

FunctiondistanceArduino
powerVCC5V
groundGNDGND
digitalTRIGGPIO 6
digitalECHOGPIO 7

5. Connections between "motion" and "Arduino"

FunctionmotionArduino
powerVCC5V
groundGNDGND
digitalOUTGPIO 3

6. Connections between "soil" and "Arduino"

FunctionsoilArduino
powerVCC5V
groundGNDGND
analogAOUTGPIO 15

Deploy the firmware

#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
// 0: rotate all examples; 1: climate; 2: light; 3: distance;
// 4: motion; 5: soil. Change this number to run just one example.
const byte EXAMPLE = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT climate(2, DHT11);
char previous[2][17] = {{0}, {0}};
bool screenReady = false;
void line(byte row, const char *text) {
  char padded[17];
  memset(padded, ' ', 16);
  padded[16] = 0;
  for (byte i=0; i<16 && text[i]; ++i) padded[i]=text[i];
  if (strcmp(padded, previous[row]) != 0) {
    if (screenReady) { lcd.setCursor(0,row); lcd.print(padded); }
    strcpy(previous[row], padded);
    Serial.println(padded);
  }
}
// Example 1: DHT11 temperature and humidity.
void exampleClimate() {
  float t=climate.readTemperature(), h=climate.readHumidity();
  char text[17];
  if (isnan(t) || isnan(h)) {
    line(0,"1: Climate"); line(1,"Check DHT wiring"); return;
  }
  snprintf(text,sizeof(text),"1: Temp %d C",(int)t); line(0,text);
  snprintf(text,sizeof(text),"Humidity %d%%",(int)h); line(1,text);
}
// Example 2: raw light reading, not calibrated lux.
void exampleLight() {
  char text[17]; line(0,"2: Light level");
  snprintf(text,sizeof(text),"Raw: %d",analogRead(A0)); line(1,text);
}
// Example 3: ultrasonic distance with a bounded echo wait.
void exampleDistance() {
  digitalWrite(6,LOW); delayMicroseconds(2);
  digitalWrite(6,HIGH); delayMicroseconds(10); digitalWrite(6,LOW);
  unsigned long us=pulseIn(7,HIGH,25000UL);
  line(0,"3: Distance");
  char text[17];
  if (!us || us<116 || us>23200) line(1,"Out of range");
  else { snprintf(text,sizeof(text),"%lu cm",us/58); line(1,text); }
}
// Example 4: PIR detects movement, not guaranteed occupancy.
void exampleMotion() {
  line(0,"4: Motion");
  if (millis()<60000UL) line(1,"Warming up...");
  else line(1,digitalRead(3)==HIGH ? "Motion detected" : "No motion");
}
// Example 5: raw soil reading; compare dry and wet soil to calibrate.
void exampleSoil() {
  char text[17]; line(0,"5: Soil moisture");
  snprintf(text,sizeof(text),"Raw: %d",analogRead(A1)); line(1,text);
}
void setup() {
  Serial.begin(9600); Wire.begin();
  // Common backpack addresses: only one LCD should be on this bus.
  const byte addresses[]={0x27,0x3F};
  for (byte a : addresses) {
    Wire.beginTransmission(a);
    if (Wire.endTransmission()==0) {
      lcd=LiquidCrystal_I2C(a,16,2); lcd.init(); lcd.backlight();
      screenReady=true; break;
    }
  }
  if (!screenReady) Serial.println(F("LCD not found at 0x27 or 0x3F"));
  climate.begin();
  pinMode(6,OUTPUT); digitalWrite(6,LOW);
  pinMode(7,INPUT); pinMode(3,INPUT);
}
void loop() {
  static unsigned long last=0;
  if (millis()-last<2000UL) return;
  last=millis();
  byte selected=EXAMPLE ? EXAMPLE : (millis()/6000UL)%5+1;
  switch(selected) {
    case 1: exampleClimate(); break;
    case 2: exampleLight(); break;
    case 3: exampleDistance(); break;
    case 4: exampleMotion(); break;
    case 5: exampleSoil(); break;
    default: line(0,"Set EXAMPLE 0-5"); break;
  }
}

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