nsuser
Posts: 25
Joined: Mon Sep 25, 2017 4:41 pm

Measuring strength of vibration from sensor in python. C Code provided!

Thu Dec 14, 2017 3:09 am

Measuring the strength of vibration (length of the pulse) and raw data from a sensor breakout is provided below in C:
http://www.theorycircuit.com/sw-420-vib ... interface/

How can the same be done in python?

nsuser
Posts: 25
Joined: Mon Sep 25, 2017 4:41 pm

Re: Measuring strength of vibration from sensor in python. C Code provided!

Thu Dec 14, 2017 2:19 pm

But, this would still just give the HIGH vs LOW. I have that already. I am looking f0r the strength of the pulse with the numbers.
Is that correct?
supra wrote:
Thu Dec 14, 2017 1:41 pm
I do not test this. Because I don't have vibration.

Code: Select all

import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)

vibr_pin = 8
LED_Pin = 10

GPIO.setup(channel, GPIO.IN)
GPIO.setup(channel, GPIO.OUT)

while True:
    val = 0
    val = input(vibr_pin)
    if(val==1):
        GPIO.output(LED_Pin, GPIO.HIGH)
        sleep(1000)
        GPIO.output(LED_Pin, GPIO.LOW)
        sleep(1000)
    else:
        GPIO.output(LED_Pin, GPIO.LOW)

GPIO.cleanup()        

pcmanbob
Posts: 9747
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring strength of vibration from sensor in python. C Code provided!

Thu Dec 14, 2017 3:33 pm

But if that is all you sensor outputs then that's all you can get from it, just because you found some code to do some thing else does not mean your sensor can do it.

if your sensor was capable of sending data over a serial interface then I would expect it to have a serial out pin at least and probably more likely TXD and RXD pins to allow serial communication.

if you are still using the SW-420 vibration sensor that you are asking about in your other posts then it just outputs high or low, there is no mention of serial data output.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

henmina53
Posts: 20
Joined: Thu Apr 05, 2018 4:49 am

Re: Measuring strength of vibration from sensor in python. C Code provided!

Wed Jul 04, 2018 5:04 am

Well as per your subject line, I am on working on something similar with wireless vibration sensor https://store.ncd.io/product/iot-long-r ... re-sensor/ which shares much precised values of vibration on machines,fans, washing machine and many other appliances,
You may have look on manual also they have given the code in arduino also, Have a look on it you might find it interesting and helpful.

Return to “Automation, sensing and robotics”