I am able to detect a vibration when I am using 801s vibration sensor module sensor

How to measure and print the amount of vibration level on the screen in C? I am checking now only state: HIGH and LOW. I am using a digital signal not analog signal so my question is, can I use this type of signal in this sensor to display the value of vibration or we can't. How to retrieve the data from this sensor in C, value not only states high or low.

I am playing with the code from this video project

#include <wiringPi.h>
#include <stdio.h>
#define VibratePin 0
#define Gpin 1
#define Rpin 2
int tmp = 0;
void LED(int color)
pinMode(Gpin, OUTPUT);
pinMode(Rpin, OUTPUT);
if (color == 0)
digitalWrite(Rpin, HIGH);
digitalWrite(Gpin, LOW);
else if (color == 1)
digitalWrite(Rpin, LOW);
digitalWrite(Gpin, HIGH);
printf("LED Error");
void Print(int x){
if (x != tmp){
if (x == 0)
printf("Vibration Detected:  .......Device1 On\n");
if (x == 1)
printf("Vibration Detected:  Device2 On........\n");
tmp = x;
int main(void)
int status = 0;
int tmp = 0;
int value = 1;
if(wiringPiSetup() == -1){ //when initialize wiring failed,print messageto screen
printf("setup wiringPi failed !");
return 1;
pinMode(VibratePin, INPUT);

value = digitalRead(VibratePin);

value = digitalRead(VibratePin);
if (tmp != value){
status ++;
if (status > 1){
status = 0;
return 0;

The Raspberry Pi does not have any analog input PINs. Thus you will not be able to interpret analog input signals without some additional hardware.

In order to be able to read not only HIGH or LOW levels from your sensor, you need to use an analog-to-digital converter (ADC), e.g. in the form of a ADC-HAT extension for the Rasperry Pi. Then you can connect the analog output pin of your sensor A0 to the ADC and read in the analog input level.

  • Which ADC converter will be the best solution for R Pi 4B?
    – tellarwind
    Oct 25 '19 at 21:13
  • If I connect ADC I will be able to interpret an amount of vibration with 801s vibration sensor.
    – tellarwind
    Oct 25 '19 at 21:23
  • Is not the better option to buy Arduino?
    – tellarwind
    Oct 25 '19 at 21:33
  • sure, arduino or e.g. nodemcu or any dev board with analog Input will work for you.
    – oh.dae.su
    Oct 25 '19 at 21:35
  • Note there does appear to be a D0 on the sensor from the question, so an ADC may not be necessary.
    – goldilocks
    Oct 27 '19 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.