801S Wide Range Vibration Detection Sensor Review and code examples

This post reviews the 801S wide range vibration detection sensor. Here I review and test the sensor and provide code to use it.

Overview of the Vibration sensor

This sensor detects small movements and reports this back as either an analogue or digital signal.

This doesn’t provide any numerically measurable values but provides a relative signal of the current vibration level. A sensor at this price range wouldn’t be expected to do this so it does not detract from the sensor.

As noted above this sensor provides two possible outputs. The first is an analogue signal that varies between 0 and 5 volts. This represents the relative level of motion where 0  represents no motion detected. The second is a digital output that goes high when a specific level is reached. This can be configured by the blue potentiometer on the sensor.

The digital output can be useful if no processing of the analogue sensor is performed and you just need to toggle something. If you are able to process the analogue sensor you can get a lot more information and dynamically change the threshold that you act on which can be an advantage.

Wiring it up to an Arduino

For my experiments I will be using the analogue output to log the level of vibration that the sensor detects over a period of time. I will use this data to form the basis of my review.

As shown on the left I have wired up the + on the sensor to the 5 volts on the Arduino. The - has been connected to the GND wire.

I have also attached the Aout output to the first analogue port on the Arduino to log the data received from the sensor.

Programming the Arduino

To log the data from the Arduino you need to read from the analogue sensor. The below code reads and logs the output to the serial connection.

#define VIBRATION_ANALOGUE_PORT 0

int motionSensorval = 0;

void setup() {
    Serial.begin(115200);
}

void loop() {
    motionSensorval = analogRead(VIBRATION_ANALOGUE_PORT);
    Serial.print("Motion sensor value :");
    Serial.println(motionSensorval);
    delay(200);
}

I define VIBRATION_ANALOGUE_PORT as a const as this value will never change. This has speed improvements over defining it as an int (although very minor). These speed improvements come from the fact the compiler can inline the variable (essentially performs find and replace) before runtime. This then removes a section of memory that would be needed to store the int. When your programs become larger and space becomes an issue on the Arduino these optimisations can become important.

In addition to this in the main scope of the program I define motionSensorval to hold the value obtained from the analogue read.

Taking some data measurements

I changed my recording code to run over a very short period and log the data. Once I uploaded the code I moved the sensor for a period of time to create some data.

From looking at the graph on the left I can see that the sensor returns to 0 easily with no issues.

In addition to this when I move the sensor a large amount it reports the highest value (1023).

Since the sensor easily returns to 0 and can reach the maximum value of 1023 this suggests it is configured correctly.

This was logging an analogue value every millisecond and you can see that it sometimes takes a couple millseconds to return to a base value.

Since this sensor is very fast to return to a base value to ensure it detects very fast movements you may want to consider polling the sensor frequently. Depending on the speed of the motion even with a relatively low poll time (once every second) you might miss fast motion.

Final Review

This sensor works well to detect small motions that would be ideal to check if something has been moved. The addition of both a digital and analogue output is helpful in cases where you only care when it has reached a specific value.

The only downside of this sensor is that because the movement period can be very small to ensure all movement is tracked the polling time may need to be small (< 1 second). However this does not detract from the sensor since it is only important in the event you must detect all movement however short their period. Even in this case the solution is to poll as fast as your requirements are which isn’t too problematic.

All in all this is a very nice and cheap movement sensor that I would definitely buy again.

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.