Arduino Sensors Guide: The 12 Most Used Sensors
The most used sensors with Arduino: DHT11, DHT22, HC-SR04, LDR, PIR, MQ-2, NTC, flame, soil moisture, RFID and more. What they measure, how to wire them and what to watch out for.
Sensors are the parts that let an Arduino sense the outside world. A sensor turns a physical quantity it measures (temperature, distance, light, gas) into a signal the Arduino can read. In this guide you'll find the most used sensors, what they do and what to watch out for when wiring them.



Sensor output types: analog, digital and bus-based
- Analog sensors (LDR, potentiometer, NTC, MQ gas) give their value as a voltage, read with analogRead as 0–1023.
- Digital sensors (PIR, flame, reed switch) only report yes/no, read with digitalRead as HIGH/LOW.
- Bus-based sensors (DHT22, BMP280, RC522) send data over I2C, SPI or their own protocol; they usually need a library.
Temperature and humidity sensors
| Sensor | Measures | Accuracy | Note |
|---|---|---|---|
| DHT11 | Temperature + humidity | ±2 °C, ±5% | Cheap, 1 reading per second |
| DHT22 | Temperature + humidity | ±0.5 °C, ±2–5% | More accurate, wider range |
| NTC thermistor | Temperature | Depends on calibration | Analog, very cheap |
| DS18B20 | Temperature | ±0.5 °C | Waterproof version available, single wire |
| BME280 | Temperature + humidity + pressure | ±1 °C, ±3% | I2C, ideal for a weather station |
Distance sensor: HC-SR04
The HC-SR04 sends out a sound wave and measures how long the echo takes to come back; it can measure roughly 2–400 cm. It's the basis of parking sensors, obstacle-avoiding robots and level gauges. It runs on 5 V; with an ESP32 or Pico, put a voltage divider on the ECHO pin.
Light sensor: LDR
An LDR (photoresistor) is a part whose resistance drops in the light. It's read from an analog pin by building a voltage divider with a 10 kΩ resistor. It's used in night lights, automatic blinds and laser alarm projects. For precise light measurement (lux), I2C sensors like the BH1750 are preferred.
Motion sensor: PIR (HC-SR501)
A PIR sensor detects changes in the heat given off by the human body and sets its output HIGH when it sees motion. Its two potentiometers adjust the sensitivity (3–7 m) and how long the output stays on. After power-up it needs about a minute to warm up.
Gas and flame sensors
| Sensor | Detects |
|---|---|
| MQ-2 | Smoke, LPG, methane, hydrogen |
| MQ-4 | Methane (natural gas) |
| MQ-7 | Carbon monoxide |
| MQ-135 | Air quality (ammonia, CO2-like gases) |
| Flame sensor | The infrared light of a flame |
Other commonly used sensors
- Soil moisture sensor: for automatic watering projects. Capacitive models don't corrode, so they last longer.
- Reed switch: closes when a magnet comes near; used in door and window sensors.
- RC522 RFID: reads the IDs of cards and key fobs; used in door locks and attendance systems. It must be powered from 3.3 V.
- IR receiver (VS1838B/TSOP): reads the signals of TV remotes.
- Joystick: a two-axis analog controller used in robot and game projects.
- Sound sensor: detects sound level for projects like turning on a lamp with a clap.
What to look for when choosing a sensor
- Operating voltage: does the sensor need 5 V or 3.3 V? Is it compatible with your board's logic level?
- Output type: analog, digital or I2C/SPI? Does your board have enough suitable pins?
- Accuracy and range: is the value you want to measure within the sensor's range?
- Library support: is there an up-to-date, widely used library for the Arduino IDE?
- Environment: do you need a model that withstands humidity, water, dust or high temperatures?
Making sensor readings stable
Small fluctuations are normal with analog sensors. Taking the average or median of several readings, using hysteresis for thresholds (two separate thresholds for on and off) and updating the display only a few times per second make readings look much more stable. In battery-powered sensor projects, lengthening the measurement interval noticeably extends battery life; you can estimate it with the battery life calculator.
Frequently asked questions
What's the best temperature sensor for Arduino?
The DHT11 is enough to start. For more accurate measurements choose the DHT22 or DS18B20, and the BME280 if you also want to measure pressure.
How many sensors can I connect to one Arduino?
It depends on the pin count and sensor type. I2C sensors can share the same two wires, so dozens can be connected; for analog sensors the Uno has 6 analog inputs and the Mega 16.
Why do my sensor values keep changing?
Noise, long wires and supply fluctuations cause it. Average several readings, keep wires short and add a 100 nF capacitor to the sensor's supply.
Can I connect a 5 V sensor to an ESP32?
The sensor can be powered from 5 V, but its output signal must be brought down to 3.3 V before it reaches the ESP32. Use a voltage divider or a level shifter; some sensors also come in 3.3 V-compatible versions.
How do I convert an analog sensor value to real units?
First convert the reading to a voltage (value × 5 / 1023), then use the formula from the sensor's datasheet to turn it into a real unit such as temperature, light or gas concentration. Some sensors need calibration.
More articles
From temperature to distance, gas to motion: the sensors used most in Arduino projects, with wiring tips and common mistakes, all in one place.









