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.

Using the Grove Gesture Sensor
Wouldn’t it be cool if you could control something by just waving your hands? Well, this is what the grove gesture sensor does. In…

A Better Arduino Color Sensor using TCS230
Last time, I showed how easy it is to detect colors using the Pixy2 camera. However, the camera’s price might be too expensive for…

Use LM393 IR Module as Motor Speed Sensor
Unlike stepper and servo motors, precision control for DC motors is impossible unless a sort of feedback mechanism is employed. If your application requires…

Water Flow Sensor Arduino Tutorial: Build a Water Flow Meter
A water flow sensor Arduino project lets you measure how much liquid passes through a tube or pipe. Instead of estimating the water level…

How to Use PIR Sensor with NodeMCU ESP8266
A Passive Infrared (PIR) sensor is a popular sensor for detecting the presence of a person. This is a type of proximity sensor although…

How the DHT22 Sensor Works
The DHT22 temperature and humidity sensor is a common sensor; in fact, there are tons of tutorials out there teaching you how to use…

Using the 3D Gesture Sensor
I recently got my hands on a 3D gesture sensor from DFRobot and honestly, my brain is ringing with the possible projects I can…

How to Use a Digital Motion Sensor with Arduino
I’ve already covered the basics of how a PIR motion sensor work on my previous tutorial. DFRobot was kind enough to send me a…

Using an Arduino Turbidity Sensor
Turbidity refers to the haziness of a fluid caused by the increased number of very tiny particles which, individually, is invisible to us. Moreover,…

Arduino Microphone Tutorial: Read Sound with a Sensor
How can an Arduino detect sound? The simplest way is to use a microphone module, often sold as an Arduino sound sensor. These small…

Vibration Sensor Tutorial
Vibrations can be an indicator that trouble is coming. It can be your machine going haywire, a gear on a robot missing teeth, or…

Arduino Temperature Sensor
Project Overview I was recently commissioned to create a simple project for a coffee roasting machine. Basically, I need to measure the temperature of…
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.