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.
Projects to build after reading this
See all projects
Temperature and Humidity with DHT11
How warm is your room, and is the air humid or dry? The DHT11 sensor measures temperature and humidity, and the Arduino writes the values on a two-line LCD screen, refreshing every couple of seconds.

Parking Sensor with HC-SR04
A mini version of a car's parking sensor: the closer something gets, the faster the beeps.

Night Light with Ldr
A little night light that turns on by itself when it gets dark and goes off when morning comes.

Motion Detector with Motion Sensor
A simple guard that tells you when someone walks into the room. The motion sensor picks up the warmth given off by the human body, and the Arduino keeps the LED on as long as there is movement and…

Using a Gas Sensor
A little guard that notices a gas leak in the kitchen before you do. The gas sensor keeps sniffing the air; while everything is fine the green LED stays on, and when the gas in the air passes a…

Using a Flame Sensor
A little guard that spots fire before you do, in the kitchen or the workshop. The flame sensor picks up the invisible light that fire gives off; while all is well the green LED is on, and when it…

Smart Irrigation Station
A gardener that waters your plants on its own, so they don't dry out while you're on vacation.

RFID Value Reading
Your building key fob or access card hides a secret ID number, and this project reads it. Hold the card near the RFID reader and the Arduino writes the card's number to your computer screen.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

