Skip to content

Specifications and usage of speed sensors compatible with Arduino

Jincheol Park edited this page Jul 23, 2024 · 1 revision

Specifications and Usage of Speed Sensors Compatible with Arduino

Speed sensors are crucial components for measuring the speed of vehicles or robots. In projects involving Arduino, various types of speed sensors can be used, each with specific characteristics and usage. Below are some of the commonly used speed sensors compatible with Arduino, along with their specifications and usage.

Types of Compatible Speed Sensors

  1. Hall Effect Sensor
    • Operating Principle: Detects magnetic fields generated by a passing magnet to measure speed.
    • Advantages: High reliability, long lifespan, digital signal output.
    • Specifications:
      • Power Supply: 3.3V or 5V
      • Output Signal: Digital signal (High/Low)
      • Response Time: Fast
    • Usage:
      1. Attach a magnet to the rotating part of the system.
      2. Position the Hall effect sensor where the magnet will pass by.
      3. Connect the sensor's output pin to a digital input pin on the Arduino.
      4. Use code to process the signal changes for speed calculation.
// Example code for connecting a Hall effect sensor to Arduino
const int sensorPin = 2; // Pin where the Hall effect sensor is connected
volatile int pulseCount = 0;

void setup() {
    Serial.begin(9600);
    pinMode(sensorPin, INPUT);
    attachInterrupt(digitalPinToInterrupt(sensorPin), countPulse, RISING);
}

void loop() {
    // Calculate and print speed every second
    delay(1000);
    float speed = (pulseCount / 20.0) * 60; // Example: Revolutions per minute (RPM)
    Serial.print("Speed: ");
    Serial.print(speed);
    Serial.println(" RPM");
    pulseCount = 0; // Reset count
}

void countPulse() {
    pulseCount++;
}
  1. Optical Speed Sensor
    • Operating Principle: Measures speed by detecting the rotation of a reflective tape or disk.
    • Advantages: High accuracy, non-contact measurement.
    • Specifications:
      • Power Supply: 3.3V or 5V
      • Output Signal: Digital signal (High/Low)
      • Sensing Distance: Varies by sensor
    • Usage:
      1. Attach a reflective tape or disk to the rotating part of the system.
      2. Position the optical sensor where it can detect the reflection.
      3. Connect the sensor's output pin to a digital input pin on the Arduino.
      4. Use code to detect changes in the digital signal for speed calculation.
// Example code for connecting an optical speed sensor to Arduino
const int sensorPin = 2; // Pin where the optical speed sensor is connected
volatile int pulseCount = 0;

void setup() {
    Serial.begin(9600);
    pinMode(sensorPin, INPUT);
    attachInterrupt(digitalPinToInterrupt(sensorPin), countPulse, RISING);
}

void loop() {
    // Calculate and print speed every second
    delay(1000);
    float speed = (pulseCount / 20.0) * 60; // Example: Revolutions per minute (RPM)
    Serial.print("Speed: ");
    Serial.print(speed);
    Serial.println(" RPM");
    pulseCount = 0; // Reset count
}

void countPulse() {
    pulseCount++;
}
  1. Magnetic Inductive Speed Sensor
    • Operating Principle: Detects electromagnetic induction generated by a passing metal object to measure speed.
    • Advantages: Robust, high durability.
    • Specifications:
      • Power Supply: 5V
      • Output Signal: Analog or digital signal (varies by sensor)
      • Sensing Distance: Varies by sensor
    • Usage:
      1. Attach a metal object to the rotating part of the system.
      2. Position the inductive sensor where it can detect the metal object passing by.
      3. Connect the sensor's output pin to an input pin on the Arduino (analog for analog signal).
      4. Use code to read and process the signal for speed calculation.
// Example code for connecting a magnetic inductive speed sensor to Arduino
const int sensorPin = A0; // Pin where the inductive speed sensor is connected
int sensorValue = 0;

void setup() {
    Serial.begin(9600);
    pinMode(sensorPin, INPUT);
}

void loop() {
    sensorValue = analogRead(sensorPin);
    float speed = sensorValue / 10.0; // Example: Calculating speed from sensor value
    Serial.print("Speed: ");
    Serial.print(speed);
    Serial.println(" units");
    delay(1000);
}