Labs / Bipes + MicroPython / 7 Sensors: Enable Programs to "Perceive the World"

7.8 Reacts to the slightest touch? Build a highly sensitive vibration detection device! β€”β€” Spring-type vibration sensor module based on SW-18010P

Author: Li Zisheng Β· Source: FreakStudio open documentation Β· License: CC BY 4.0

Contents

Young makers, let's unlock a "more sensitive vibration catcher" 🚨 now!

We've played with ball-type vibration sensors before, which can detect obvious shaking. But today, this spring-type vibration sensor based on the SW-18010P can catch even the tiniest vibrations without missing a thing β€” it's like fitting a "vibration stethoscope" to the development board ✨, letting the board know that even the slightest wobble or bump can be accurately picked up!

1. Module Introduction

Sometimes, when we need to detect extremely subtle vibrations β€” for example, a light nudge to a table β€” ball-type sensors may not be sensitive enough to pick them up, and that’s when spring-type vibration sensors come into play!

It is a high-sensitivity switch-type vibration sensor: there is a tiny spring inside the module. When the module perceives vibration, the spring will bend due to the vibration and come into contact with the electrode, and the module will output a trigger signal; when stationary, the spring returns to its original position and the signal is cut off. Compared with the ball type, it is more sensitive to slight vibrations.

Compared with ball-type vibration sensors, it has the following characteristics:

In graphical programming, these blocks are commonly used with spring vibration sensors:

In practical projects, it is often used for the following purposes:

Quick Science: Spring Type vs Ball Type

  • Ball type: Triggered by the rolling of metal balls, suitable for detecting obvious shaking and collisions;
  • Spring type: Triggered by spring bending contact, suitable for detecting slight vibrations and touches; it’s like listening to sounds with different "ears" β€” one picks up "loud noises" and the other catches "faint sounds"!

2. Wiring Instructions

To make the development board "detect" slight vibrations, the first step is still β€”β€” connect the module correctly!

7.8 Reacts to the slightest touch? Build a highly sensitive vibration detection device! β€”β€” Spring-type vibration sensor module based on SW-18010P

We will connect the spring-type vibration sensor module based on SW-18010P to the digital interface DIO0 of the development board, and the corresponding relationship is as follows:

Development Board Pins

Module Pins

Description

Pin 6

DIN

Sensor level signal input pin

Pin 7

NC

-

πŸ“Œ Note

3. Example: Detect vibration and print a prompt

Experimental Objective: Detect vibrations in the environment in real time. Even a slight touch will trigger the terminal to print "Spring Triggered", allowing you to intuitively experience the high sensitivity of the spring-type sensor.

Everyday Life Insight: The burglar alarm in your home relies on a highly sensitive sensor similar to this to detect even minor vibrations β€” now let’s build our very own "mini vibration detector"!

The graphical program is as follows:

7.8 Reacts to the slightest touch? Build a highly sensitive vibration detection device! β€”β€” Spring-type vibration sensor module based on SW-18010P

Building Block Assembly Steps:

  1. infinite loop
    • Use the repeat while true block to make the program continuously detect vibration;
  2. Read vibration status
    • Use the read digital input block;
    • Select the pin connected to the sensor: Pin 9 / GPIO6;
    • Set the Pull-up to false (to match the module's level output);
  3. conditional judgment
    • Use the if not read digital input block (since it outputs a low level when vibrating, and not is used to identify the trigger state);
  4. Trigger Feedback
    • Add the print "Trigger spring" block when the condition is satisfied;
    • Add the delay 20 milliseconds block to filter high-frequency jitter and avoid duplicate printing.

Experimental Effect:

πŸ“Œ Give it a try: Tap the module with different levels of force to experience its high sensitivity!

Graphical blocks will be automatically converted into MicroPython code, and the running result will be output:

7.8 Reacts to the slightest touch? Build a highly sensitive vibration detection device! β€”β€” Spring-type vibration sensor module based on SW-18010P

Directly importable building blocks:

Spring.xml 2 KB

Tips

  1. If no vibration is detected:
  • Check whether the correct pins are selected (Pin 9 / GPIO6) and whether the wiring is secure;
  • Try tapping the module or the desktop gently, as it is more sensitive to slight vibrations;
  1. Avoid frequent triggering:
  • You can increase the delay time (e. g., 50 milliseconds) to reduce repeated printing;
  1. Advanced Gameplay:
  • Pair it with LED building blocks, and the LED will light up when shaken, making a "high-sensitivity vibration alarm light".

✨ Interactive Mini Quiz

  1. Think about it: Why do we need to add time.sleep_ms (20) in the code? What will happen in the terminal if we remove this delay?
  2. Try this: Place the spring-loaded sensor and the ball-type sensor together, tap the tabletop gently with the same force, and see which sensor triggers first!

Summary

  1. The spring-type vibration sensor based on SW-18010P is a high-sensitivity switch-type module;
  2. It detects slight vibrations through the bending contact of its internal spring, which is more sensitive than the ball type.
  3. Outputs a low level when vibrating, and a high level when stationary;
  4. Through conditional judgment, functions such as highly sensitive vibration alarm and minor collision detection can be realized.