The right sensor for every common Arduino and ESP32 project: temperature, distance, motion, light, gas, soil, current and weight. What each one measures, how it connects, and which to pick.
Pick the sensor by what you measure: DHT22 for temperature and humidity, DS18B20 for liquids, HC-SR04 for distance, PIR for motion, BH1750 for light, MPU6050 for tilt, capacitive soil sensor for plants, MQ-2 for gas, ACS712 for current and a load cell with HX711 for weight. Check 3.3V or 5V before wiring.
Start from the quantity you want to measure, then check three things: the sensor's operating voltage (3.3V or 5V), how it talks to your board (digital pin, analog pin, I2C or one-wire), and whether a ready-made Arduino library exists. Every sensor below has one, so you can get readings in a few minutes.
| Project | Sensor | Connection |
|---|---|---|
| Room temperature and humidity | DHT22 (or DHT11 on a tight budget) | 1 digital pin |
| Water or outdoor temperature | DS18B20 waterproof probe | 1-Wire, one pin for many probes |
| Distance, parking sensor, tank level | HC-SR04 ultrasonic | 2 digital pins |
| Precise short distance | VL53L0X laser time-of-flight | I2C |
| Security light, people detection | HC-SR501 PIR | 1 digital pin |
| Robot obstacle or line detection | FC-51 IR obstacle sensor | 1 digital pin |
| Light level, automatic lamp | BH1750 (lux) or LDR | I2C or analog |
| Weather station, altitude | BMP280 pressure sensor | I2C or SPI |
| Tilt, balance robot, gesture | MPU6050 accelerometer + gyro | I2C |
| Plant watering | Capacitive soil moisture sensor | Analog |
| Gas leak or smoke alarm | MQ-2 gas sensor | Analog + digital |
| Measuring current or power | ACS712 current sensor | Analog |
| Digital scale | Load cell + HX711 | 2 digital pins |
The DHT22 measures temperature and humidity with about ±0.5°C accuracy and works below freezing, which makes it the best all-round choice. The DHT11 is cheaper and fine for room conditions in classroom projects, but it reads in whole degrees and only from 0°C. For liquids, soil or outdoors use the sealed DS18B20 probe: it is waterproof, accurate to about ±0.5°C, and several probes can share one pin.
The HC-SR04 measures 2-400cm with sound pulses and is the standard for robots, parking sensors and water tanks. It runs on 5V, so divide its echo signal down to 3.3V on an ESP32. The VL53L0X uses a laser for accurate readings up to about 2 metres in a tiny I2C module, and is not affected by soft surfaces that absorb sound.
A PIR sensor (HC-SR501) detects body heat moving across its view up to several metres away and outputs a simple HIGH signal; adjust sensitivity and on-time with its two trimpots. For robots, an IR obstacle sensor reports an object a few centimetres in front, and an MPU6050 measures tilt and rotation for self-balancing robots and gesture controls.
Choose a capacitive soil moisture sensor over the older two-prong type: it has no exposed metal, so it does not corrode in wet soil. MQ-2 gas sensors detect LPG, smoke and other combustible gases after a warm-up period; use them for alarms and learning, not as certified safety devices. A BMP280 adds air pressure and altitude to a weather station.
An ACS712 module measures AC or DC current through an isolated hall-effect chip. Pick the 5A version for small loads and the 20A version for motors and inverters. A load cell with an HX711 amplifier turns force into a 24-bit reading for digital scales; calibrate it once with a known weight.
ESP32 pins work at 3.3V. I2C sensors such as the BMP280, BH1750, MPU6050 and VL53L0X run happily at 3.3V. For 5V-only sensors, power them from 5V and bring their output down to 3.3V with a voltage divider or a logic level converter.
Not sure which sensor fits your project? Send us the idea on WhatsApp and we will suggest the parts.
Start with a DHT11 or DHT22 for temperature and humidity, an HC-SR04 for distance, and a PIR sensor for motion. All three need only one or two pins, have simple libraries, and appear in most beginner tutorials.
Yes. I2C sensors share the same two pins (SDA and SCL) as long as their addresses differ, DS18B20 probes share one pin, and an Arduino Uno has 6 analog and 14 digital pins for the rest. For many analog sensors, use a Mega 2560 or an ADS1115 ADC.
Check the supply voltage, add the pull-up resistor the sensor needs (4.7k for DS18B20, 10k for DHT on bare sensors), keep wires short, and average several readings in code. MQ gas sensors also need a warm-up of a few minutes.