Sensors are the foundation of nearly every modern electronics project. They allow microcontrollers to interact with the physical world by measuring temperature, light, motion, pressure, distance and many other environmental conditions.
This article provides a practical overview of sensor types, how they work, and how to choose the right sensor for your project.
What is a Sensor?
A sensor is a device that detects a physical property and converts it into an electrical signal that a microcontroller can read.
Common measured properties include:
- Temperature
- Humidity
- Pressure
- Light intensity
- Distance
- Motion
- Gas concentration
- Electrical current and voltage
The output of a sensor can be analog (a voltage level) or digital (a defined signal or data protocol).
Analog vs Digital Sensors
| Type | Output | Examples | Notes |
|---|---|---|---|
| Analog | Continuous voltage | NTC thermistors, LDRs, analog gas sensors | Requires ADC on the microcontroller |
| Digital | Discrete signal or data | DS18B20, AHT20, BME280 | Often more accurate and easier to use |
Common Sensor Interfaces
Digital sensors communicate using standardized protocols:
- I2C: Most common for modern sensors (DHT20, BME280, INA219)
- SPI: Faster, used for displays and some sensors
- One-Wire: Simple bus used by DS18B20
- UART: Used by some advanced or industrial sensors
- Analog output: Direct voltage reading
I2C is the most widely used interface in modern Arduino-compatible sensor modules.
Popular Sensor Categories
Environmental Sensors
- Temperature and humidity sensors (AHT20, SHT30, DHT22)
- Pressure sensors (BMP280, BME280)
- Air quality sensors (BME680)
Motion Sensors
Distance and Presence Sensors
Electrical Sensors
Light and Optical Sensors
- Ambient light sensors (VEML3328)
- Color sensors (TCS34725, BH1745)
Accuracy vs Price
Not all sensors are equal. There are significant differences between low-cost hobby modules and industrial-grade sensors.
- Cheap sensors are good for trends and approximate values
- Mid-range sensors offer better stability and calibration
- Industrial sensors are designed for precision and reliability
For example:
- DHT11 is very cheap but not very accurate
- SHT30 or AHT20 provide much better results
- BME280 adds pressure measurement for more advanced applications
Power Requirements
Most modern sensor modules operate at 3.3V, even if the breakout board accepts 5V.
- Logic level is usually 3.3V
- I2C requires pull-up resistors
- Power consumption varies widely between sensors
Some sensors (especially gas sensors) can consume significant current and may require careful power design.
Choosing the Right Sensor
When selecting a sensor, consider:
- What physical parameter do you need to measure?
- Required accuracy and resolution
- Interface compatibility (I2C, SPI, analog)
- Operating voltage (3.3V vs 5V)
- Response time
- Environmental conditions (indoor, outdoor, industrial)
For most Arduino and ESP32 projects, I2C-based sensors are the easiest and most flexible option.
Practical Recommendation
If you are starting a new project, a small set of sensors already covers many use cases:
- AHT20 or SHT30 for temperature and humidity
- BME280 for environmental measurements
- INA219 for current monitoring
- VL53L0X for distance measurement
This combination allows you to build a wide range of projects with minimal hardware complexity.
Conclusion
Sensors transform microcontrollers from simple computing devices into systems that can interact with the real world.
Understanding the different sensor types, interfaces and limitations helps you choose the right component and avoid common design mistakes.
