Ugenz Academy/IoT Tutorial

Sensors

8 min read1,425 words

Reading progress

Keep learning

Sensors in Electronics

1. Introduction

A sensor is an electronic device that detects changes in its surroundings and converts them into a signal that can be measured or processed by an electronic system.

Sensors can detect physical conditions such as temperature, light, sound, pressure, humidity, distance, motion, and gas concentration.

Sensors are important components in electronics, robotics, automation, and the Internet of Things (IoT). They allow electronic devices to collect information from the real world and respond automatically.

For example, a temperature sensor can measure room temperature, while a distance sensor can detect an object in front of a robot.

Mini Sensor Kit With Pir Ultrasonic Sensor Ir Sensor Ldr | Desertcart INDIA

ESP32 IOT Dashboard. | ESP32

Esp32 Air Monitor : 6 Steps - Instructables

11

2. Definition of a Sensor

A sensor is a device that detects a physical, chemical, or biological quantity and converts it into a corresponding output signal.

The output may be:

  • Analog: A continuously varying voltage or current.
  • Digital: A signal representing discrete states or digital data.
  • Communication data: Measurements transmitted through protocols such as I²C, SPI, or UART.

Examples include an LDR that responds to light intensity, a DHT11 that measures temperature and humidity, and an ultrasonic sensor that estimates distance.

3. How Does a Sensor Work?

Most sensor systems follow a simple process.

1. Physical quantity

Heat, light, pressure, movement, or distance

2. Sensor element

Detects a change in the environment

3. Signal processing

Converts or processes the detected signal

4. Output or action

Display a reading or control another device

For example, in an automatic lighting system, a light sensor measures the brightness of a room. A microcontroller processes the measurement and switches on a lamp when the room becomes dark.

4. Types of Sensors

Sensors can be classified according to the quantity they detect, their output, and their operating principle.

4.1 Classification by Measured Quantity

DHT11 DHT22 Temperature and Humidity Moisture Sensor 3.3V 5V Module For Arduino, Robotics, Raspberry | Shopee Malaysia

Temperature and humidity sensors

Measure temperature and moisture in the air.

Examples: DHT11, DHT22, DS18B20

📝 Conocimientos teóricos. | EducaShield

Light sensors

Detect light intensity and changes in brightness.

Examples: LDR, BH1750, photodiode

HC-SR04 Ultrasonic Distance Sensor - Thingbits India

Distance sensors

Estimate the distance between a sensor and an object.

Examples: HC-SR04, VL53L0X

Sensor PIR de Movimento HC-SR501 100° 3 a 7m - Usinainfo

Motion sensors

Detect movement, often by sensing changes in infrared radiation.

Example: HC-SR501 PIR sensor

MQ-2 Gas Sensor Module

Gas and smoke sensors

Respond to certain gases or smoke-related conditions.

Example: MQ-2 sensor module

MPU 6050 3 Axis Digital Gyroscope Accelerometer Sensor Module - EPH

Motion and orientation sensors

Measure acceleration, rotation, tilt, or orientation.

Example: MPU6050

Other common types include pressure sensors, sound sensors, touch sensors, magnetic sensors, water-level sensors, rain sensors, soil-moisture sensors, and force sensors.

4.2 Classification by Output

TypeDescriptionExample
Analog sensorProduces a continuously varying signalLDR voltage-divider circuit
Digital sensorProduces digital states or digital dataDHT22
Smart sensorIncludes processing or communication capabilitiesBME280 module

A sensor module may provide both analog and digital outputs, depending on its design.

4.3 Classification by Power Requirement

  • Active sensors: Require an external power source to operate or generate their measurement signal. Many electronic sensor modules fall into this category.
  • Passive sensors: Can generate an electrical response from the measured quantity without requiring external excitation for the sensing element itself. A thermocouple is a common example.

Note that the terms active and passive can have different meanings in different sensor classifications.

5. Common Sensors and Their Applications

SensorWhat it detectsCommon application
LDRLight intensityAutomatic streetlights
DHT11Temperature and humidityBasic weather monitoring
DS18B20TemperatureLiquid and equipment temperature measurement
HC-SR04DistanceObstacle detection
PIRMovement of warm bodiesAutomatic security lighting
IR sensorInfrared reflection or interruptionLine-following robots
MQ-2Response to smoke and certain gasesExperimental gas-monitoring projects
Soil-moisture sensorSoil moisture levelAutomatic irrigation
Rain sensorWater droplets or wetnessRain-alert systems
Flame sensorCertain infrared radiation associated with flamesEducational fire-detection prototypes
Sound sensorSound level or acoustic activitySound-triggered systems
MPU6050Acceleration and angular velocityRobot balancing and motion tracking
BMP280Atmospheric pressure and temperatureWeather stations
RFID readerRFID tagsAccess-control systems
Hall-effect sensorMagnetic fieldsSpeed and position sensing

The actual performance of a sensor depends on its model, circuit design, calibration, and operating environment.

6. Analog and Digital Sensors

Analog sensors

Analog sensors provide a continuously varying electrical output. A microcontroller with an analog-to-digital converter (ADC) can convert this voltage into a digital number.

For example, an LDR's resistance changes with light intensity. When connected in a voltage divider, it produces a voltage that can be measured by a microcontroller.

The voltage-divider equation is:

V_out=V_inR2R1+R2V\_{\text{out}}=V\_{\text{in}}\frac{R_2}{R_1+R_2}

Here, R1R_1 and R2R_2 are the two resistances in the divider. The output depends on which resistor is connected to the supply and which is connected to ground.

Digital sensors

Digital sensors provide discrete signals or transmit measurement values digitally. Some produce a simple HIGH/LOW output, while others send numerical readings through a communication protocol.

Examples include a PIR module with a digital output and a DHT22 that sends temperature and humidity data through a digital interface.

7. Connecting Sensors to a Microcontroller

Sensors are frequently connected to Arduino, ESP32, and other microcontrollers.

Build an AI Smart Home Hub with ESP32 | WolfieWeb IoT Tutorial

wolfieweb.com

A typical connection uses:

  • VCC: Power supply for the sensor.
  • GND: Electrical ground.
  • Signal pin: Carries the measurement or output signal.

Some sensors need additional pins for interfaces such as I²C, SPI, or UART.

Before connecting a sensor, check its datasheet for supply voltage, pin configuration, current requirements, and signal levels. In particular, many ESP32 GPIO pins use 3.3 V logic and are not 5 V tolerant.

8. Applications of Sensors

Sensors are used across many fields of electronics and engineering.

  1. Home automation: Automatic lights, room-temperature monitoring, and security systems.
  2. IoT: Collecting and transmitting environmental data over a network.
  3. Robotics: Detecting obstacles, following lines, and balancing robots.
  4. Agriculture: Monitoring soil moisture and automating irrigation.
  5. Healthcare: Measuring physiological quantities using appropriate medical sensors.
  6. Automotive systems: Monitoring speed, temperature, pressure, and vehicle position.
  7. Industrial automation: Monitoring equipment conditions and controlling production processes.
  8. Weather monitoring: Measuring temperature, humidity, atmospheric pressure, and rainfall.

9. Advantages of Sensors

  • Enable automatic monitoring and control.
  • Reduce the need for continuous manual measurement.
  • Provide real-time information.
  • Improve system efficiency and responsiveness.
  • Support data collection for analysis and decision-making.
  • Make smart devices and IoT systems possible.

10. Limitations of Sensors

  • Readings may contain noise or measurement errors.
  • Some sensors require calibration.
  • Environmental conditions can affect accuracy.
  • Certain sensors have limited operating ranges.
  • Some modules consume significant power or require warm-up time.
  • Low-cost sensors may not be suitable for safety-critical applications.

11. Safety and Precautions

  • Check the operating voltage before powering a sensor.
  • Confirm the pinout before making connections.
  • Use suitable level shifting when a signal exceeds the microcontroller's allowed voltage.
  • Avoid short circuits and reverse-polarity connections.
  • Calibrate sensors when accurate measurements are required.
  • Do not rely on inexpensive hobby modules as certified fire, gas, or medical safety equipment.
  • Disconnect power before changing circuit wiring.

12. Summary

A sensor detects a physical or environmental quantity and converts it into a signal that an electronic system can use. Sensors may measure temperature, light, distance, motion, gas, pressure, humidity, and many other quantities.

Understanding sensor types, outputs, wiring, and limitations is essential for designing electronic circuits, robotics projects, automation systems, and IoT applications.

Key point: Sensors collect information from the real world, while a microcontroller can process that information and control other devices based on it.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy