Sensors allow microcontroller projects to measure and react to the real world. With the right sensor, an Arduino, ESP32, Raspberry Pi, or PIC microcontroller can detect temperature, distance, light, motion, pressure, current, water flow, sound, gas levels, weight, and many other physical conditions.
This page collects the sensor tutorials published on Teach Me Microcontrollers. Each guide is written for practical use, with wiring diagrams, sample code, explanations, and project ideas you can build on. Whether you are a beginner learning how to connect your first sensor or an engineer looking for a quick reference, these tutorials will help you understand both the hardware connection and the program behind it.
Browse All Sensor Tutorials
Use the tutorials below to learn how different sensors work and how to connect them to microcontroller boards.

How to Use the MQ-7 Carbon Monoxide Sensor
The MQ-7 carbon monoxide gas sensor is especially designed to be sensitive to carbon monoxide (CO) gas which is emitted by vehicles, factories, etc.…

Creating a Simple Arduino Fire Detector
A fire or flame sensor is simply an infrared LED with an amplifier circuit. Flame radiates an infrared signal, which triggers the LED to…

Using a Water Level Sensor with Microcontrollers
A water level sensor is a simple device used to measure the level and volume of water inside a container. This tutorial shows you…

How to Use a Flex Sensor with Arduino
A flex sensor can be used with an Arduino to detect bending, measure finger movement, control servos, or build gesture-based projects. In this tutorial,…

LPG Sensor with MQ-6 and Arduino
The MQ-6 is a semiconductor gas sensor device for detecting the levels of propane and butane in the air. Since liquefied petroleum gas (LPG)…

PIR Motion Sensor
You can in fact build your own motion sensor without spending too much. Motion sensors can be set up using ultrasonic transceivers, video cameras,…

How to Use the MAX30100 as Arduino Heart Rate Sensor
The moment I got my hands on the MAX30100 breakout board, I was ready to create my own Arduino heart rate sensor. But building…

How to Use the MQ-3 Alcohol Sensor
The MQ-3 alcohol sensor is useful for projects that tests levels of alcohol, benzine, hexane or LPG in the air but it is most…

Arduino Sensor Interfacing Tutorial
A sensor is a device that transforms physical quantities like temperature, humidity, pressure, etc., to an electrical signal. Moreover, this signal is often fed…

Display Sensor Data to NodeMCU Web Server
We set up a simple NodeMCU web server in our previous tutorial. There we controlled an LED from a web page hosted by the…
Start Learning Sensor Modules
Most sensor modules are designed to make electronic measurements easier. Instead of building the full signal-conditioning circuit yourself, the module usually includes the sensor element, resistors, amplifiers, filters, voltage dividers, or interface circuits needed to connect it to a microcontroller.
Some sensors provide a simple digital output. These are useful when you only need to know if a condition is true or false, such as whether motion is detected, water is present, or a magnetic field is nearby.
Other sensors provide an analog output. These are useful when you need to measure a changing value, such as light level, voltage, pressure, flex, sound level, or current.
Many modern sensors use digital communication protocols such as I2C, SPI, UART, or 1-Wire. These sensors can send calibrated data directly to the microcontroller, which makes them useful for more advanced projects.
Arduino Sensor Tutorials
Arduino is often the easiest starting point for sensor projects. Many sensor modules work directly with Arduino Uno, Nano, and Mega boards, especially if they operate at 5 V or include voltage-compatible outputs.
In these tutorials, you will learn how to wire common sensors to Arduino boards, read their output, display the result, and use the sensor value to control LEDs, buzzers, motors, relays, LCDs, and other output devices.
ESP32 Sensor Tutorials
The ESP32 is a good choice for sensor projects that need Wi-Fi, Bluetooth, web servers, dashboards, data logging, or IoT features. However, ESP32 boards use 3.3 V logic, so sensor voltage compatibility is important.
For ESP32 sensor projects, always check whether the sensor output is safe for 3.3 V GPIO pins. Some 5 V sensor modules may need a voltage divider, level shifter, or a different wiring approach before connecting them to an ESP32 board.
Raspberry Pi Sensor Projects
Raspberry Pi boards are useful when a sensor project needs Linux, Python, networking, image processing, databases, or a web interface. Since Raspberry Pi GPIO pins are also 3.3 V only, you should avoid connecting 5 V sensor outputs directly to the GPIO header.
Raspberry Pi sensor tutorials usually focus on practical applications such as monitoring, automation, logging, and interactive projects.
Common Sensor Types
Teach Me Microcontrollers covers different types of sensors used in electronics and embedded systems projects, including:
- Temperature and humidity sensors
- Distance and proximity sensors
- Light and color sensors
- Motion and vibration sensors
- Water level and water flow sensors
- Current and voltage sensors
- Gas and air-quality sensors
- Load cell and force sensors
- Sound and microphone modules
- Magnetic and Hall-effect sensors
- Soil moisture and environmental sensors
Choosing the Right Sensor
Before choosing a sensor, check the supply voltage, output type, communication interface, accuracy, measurement range, and whether the sensor needs calibration. Also check whether your microcontroller has the required pins, such as analog inputs, I2C pins, SPI pins, UART pins, or interrupt-capable GPIO pins.
For simple beginner projects, digital and analog sensor modules are usually easier to use. For more accurate measurements, sensors with I2C or SPI interfaces are often better because they can provide processed data instead of raw analog values.
Sensor Tutorial FAQs
What is the easiest sensor to use with Arduino?
Simple digital sensors are usually the easiest to use with Arduino because they only require reading a HIGH or LOW signal. Examples include basic motion sensors, magnetic reed switches, tilt sensors, and some water detection modules. Analog sensors are also beginner-friendly if you understand how to use analogRead().
Can I use 5 V sensors with ESP32?
Not always. The ESP32 uses 3.3 V GPIO pins, so a 5 V output signal can damage the board. Some sensor modules can be powered by 5 V but still output 3.3 V-compatible signals, while others need a voltage divider or level shifter. Always check the module output before connecting it to an ESP32 pin.
Are sensor modules accurate?
Sensor modules are useful for learning and prototyping, but accuracy depends on the sensor type, module quality, calibration, power supply, wiring, and environment. For serious measurements, always check the datasheet and calibrate the sensor when needed.