Interfacing Speed Measuring Sensor Module with Arduino

Interfacing Speed Measuring Sensor Module with Arduino

Speed Measuring Sensor Module

A Speed Measuring Sensor Module is used to detect and measure the rotational speed of an object, such as a motor shaft or a rotating wheel. It is widely applied in automation systems, robotics, and motor control.

Working Principle of Speed Measuring Sensor

The Speed Measuring Sensor typically works using an infrared beam that gets interrupted by slots on a rotating disc or encoder. Every interruption is counted to calculate the rotation speed.

Experiment of Code

A Speed Measuring Sensor detects the number of pulses generated by an encoder or magnetic element. Arduino measures the time between these pulses or counts them within a fixed time frame to determine rotational speed.

Wiring the Speed Measuring Sensor to Arduino

Connect the VCC and GND of the Speed Sensor to the Arduino’s +5V and GND. The OUT pin connects to any digital input pin. An interrupt or polling method can be used to detect pulses.

Types of Speed Measuring Sensors

Optical Encoder Sensor

  • Emits infrared light toward a rotating encoder wheel.
  • Light gets interrupted as slots pass through the beam.
  • Each interruption is counted as a pulse to calculate speed.

Hall Effect Speed Sensor

  • A magnet is attached to the rotating object.
  • The Hall sensor detects each magnetic pulse.
  • The pulses per second are used to measure speed.

Pin Configuration of Speed Measuring Sensor

Speed Sensor Module

  • VCC: Connect to +5V on Arduino.
  • GND: Connect to GND on Arduino.
  • OUT: Connect to a digital input pin on Arduino to read pulse signals.

Algorithm

  1. Initialize Components

    • Connect VCC, GND, and OUT pins of the Speed Sensor Module to the Arduino.
    • Define the input pin in the Arduino sketch.
  2. Write the Code

    • Set up an interrupt or polling system in the setup() function.
    • In loop(), calculate the time between pulses or count them in a time window.
    • Convert the pulse rate to speed (RPM or RPS).
  3. Display Values or Control Devices

    • Print the speed values to the serial monitor.
    • Use the speed value to control other components, like fans or motors.
  4. Test the Project

    • Upload the code to Arduino.
    • Rotate the attached object and observe the output values.

Arduino Code

1volatile int pulseCount = 0;  // Count the number of slots passed
2unsigned long previousMillis = 0;
3int rpm = 0;
4
5void setup() {
6  pinMode(2, INPUT);         // OUT pin from sensor
7  attachInterrupt(digitalPinToInterrupt(2), countPulse, FALLING); // Count pulse on falling edge
8  Serial.begin(9600);
9  Serial.println("Speed Sensor Initialized");
10}
11
12void loop() {
13  unsigned long currentMillis = millis();
14
15  // Calculate RPM every 1 second
16  if (currentMillis - previousMillis >= 1000) {
17    previousMillis = currentMillis;
18
19    // Assuming 20 slots in encoder disk
20    rpm = (pulseCount * 60) / 20;
21
22    Serial.print("Speed: ");
23    Serial.print(rpm);
24    Serial.println(" RPM");
25
26    pulseCount = 0; // Reset pulse count
27  }
28}
29
30void countPulse() {
31  pulseCount++; // Increment pulse count when beam is broken
32}
33

Applications

  • Motor speed monitoring
  • Wheel rotation tracking
  • Treadmill and exercise equipment
  • Industrial automation
  • RPM measurement tools
  • Robotics and mobility systems

Conclusion

Interfacing a Speed Measuring Sensor Module with Arduino is essential for building precise motion control systems. Whether you're monitoring a motor or tracking wheel speed, this setup offers accurate and real-time speed data.