Sensors and Actuators Guide: Hardware Meets Software

Key Takeaways

  • Sensors convert physical quantities (temperature, pressure, distance) into electrical signals a microcontroller can read
  • The three main serial interfaces: I2C (multi-device on two wires), SPI (high-speed, four wires), UART (point-to-point serial)
  • Analog sensors output variable voltage read by an ADC; digital sensors output discrete signals or use serial protocols
  • Actuators (motors, servos, relays) usually need a driver circuit between the microcontroller and the load
  • PWM duty cycle controls motor speed and servo position

Sensors Convert the Physical World to Data

A sensor is a transducer — it converts one form of energy into another. Temperature sensors convert thermal energy to voltage. Accelerometers convert acceleration forces to capacitance changes. Microphones convert sound pressure to voltage. All sensors ultimately produce an electrical signal that a microcontroller can read.

Two broad categories:

Interface Protocols: How Sensors Talk to Microcontrollers

ProtocolWiresSpeedDevicesCommon Uses
I2CSDA + SCL (+ power)100kHz–1MHzUp to 127 on one busIMUs, displays, EEPROMs, temp sensors
SPIMOSI+MISO+CLK+CS (+ power)Up to 50MHz+One CS pin per deviceSD cards, displays, DACs, ADCs
UARTTX + RX (+ power)9600–921600 baudPoint-to-pointGPS, Bluetooth, debug, ESP modules
1-WireSingle data wireSlowMultiple on one pinDS18B20 temperature sensors
Analog (ADC)Single wire to ADC pinN/AOne per ADC pinPotentiometers, LDRs, simple sensors

I2C example with Arduino:

#include <Wire.h>
#include <Adafruit_BME280.h>  // I2C temperature/humidity/pressure

Adafruit_BME280 bme;

void setup() {
  Serial.begin(9600);
  if (!bme.begin(0x76)) {  // 0x76 is the I2C address
    Serial.println("Could not find BME280 sensor!");
    while(1);
  }
}

void loop() {
  Serial.print("Temperature: ");
  Serial.print(bme.readTemperature());
  Serial.println(" °C");
  delay(2000);
}

Common Sensor Types and When to Use Them

Temperature & Humidity:

Distance & Proximity:

Motion & Orientation:

Actuators: Converting Electrical Signals to Physical Action

Actuators do the opposite of sensors — they take electrical input and produce physical output: movement, light, sound, heat.

Motor Types and Control

Motor TypeControlDriverBest For
DC MotorVoltage + PWM speed + H-bridge directionL298N, DRV8833Wheels, fans, continuous rotation
Servo MotorPWM pulse width (500μs-2500μs)Direct from MCUPrecise angle positioning (0-180°)
Stepper MotorStep pulses, direction, enableA4988, DRV8825CNC, 3D printers, precise rotation
BLDC MotorThree-phase, ESC for speedESC (Electronic Speed Controller)Drones, high-speed applications

Servo control example:

#include <Servo.h>

Servo myServo;

void setup() {
  myServo.attach(9);  // Servo on pin 9
}

void loop() {
  myServo.write(0);    // 0 degrees
  delay(1000);
  myServo.write(90);   // 90 degrees (center)
  delay(1000);
  myServo.write(180);  // 180 degrees
  delay(1000);
}

Integrating Sensors with Cloud and AI

The real power of sensor data comes from processing it at scale. Common integration patterns:

Learn Hardware Integration at Precision AI Academy

Our bootcamp covers sensors, microcontrollers, IoT protocols, and edge AI — giving you the skills to build smart hardware systems. Five cities, October 2026.

$1,490 · October 2026 · Denver, LA, NYC, Chicago, Dallas
Reserve Your Seat

Frequently Asked Questions

What is the difference between I2C, SPI, and UART?

I2C: two wires, up to 127 devices, 100kHz-1MHz, good for slow sensors. SPI: four wires, one CS per device, very fast, for displays/SD cards. UART: two wires, point-to-point, for GPS, Bluetooth serial, debug.

How do you control motor speed with PWM?

PWM duty cycle (0-100% on-time) controls average power to the motor. Higher duty cycle = faster speed. You need an H-bridge driver for DC motors to also control direction. Arduino's analogWrite() outputs PWM on supported pins.

What is ADC resolution and why does it matter for sensors?

ADC resolution is the number of bits used to represent the analog range. 10-bit = 1024 steps over the voltage range (~4.9mV steps for 5V range). 12-bit = 4096 steps (~1.2mV). Higher resolution enables finer measurement. Most Arduino boards are 10-bit; ESP32 is 12-bit.

BP
Bo Peng

Founder of Precision AI Academy. Software engineer and embedded systems developer. Teaches hardware integration, IoT, and edge AI to working professionals.