We have not tried any ourselves so I can't give any specific recommendations. A typical vibration sensor should only need the gpio pins so you'll need to find one that can be powered by 3V.
There are no specifications listed on the store page so I can't say one way or another. Is there a specific reason as to why you aren't using the accelerometer to detect vibrations?
I want to use vibration sensor for knock or impact, which i suppose difficult with accelerometer at 50hz. https://www.sparkfun.com/products/10293 I have hooked the piezo element as Analog input at pin number 9 and grounded at pin number 4, have i hooked in proper pins? which gpio method should be used to get input value? not getting result with this; gpio.readAnalogIn(GPIO_PIN,Gpio.AnalogReadMode.ADC);
also now the website is updated and documentation support is for version 3, can we have support of previous version, such as project.mbientlabs page is not available etc.
Can you clarify what you mean by saying "not getting result"? Are you receiving invalid values or not receiving any values? What value is the GPIO_PIN variable set to?
Thanks Eric, The problem is solved, was using wrong value in GPIO_PIN variable. GPIO_PIN=1 solved the problem. If you could help me with another issue, since connection of vibration sensor to the board, the board gets disconnected rapidly within 2-3 minutes. below is the code:
final RouteManager.MessageHandler dataHandler = new RouteManager.MessageHandler() { @Override public void process(Message message) { short rawValue = message.getData(Short.class); Log.i("gpio", String.valueOf(rawValue));
} }; AsyncOperation.CompletionHandler<RouteManager> gpioHandler = new AsyncOperation.CompletionHandler<RouteManager>() { @Override public void success(RouteManager result) { result.subscribe(VIBRATION, dataHandler); try { AsyncOperation<Timer.Controller> taskResult = mwBoard.getModule(Timer.class).scheduleTask( new Timer.Task() { @Override public void commands() { gpio.readAnalogIn(GPIO_PIN, Gpio.AnalogReadMode.ADC); } }, SCAN_INTERVAL, false); taskResult.onComplete( new AsyncOperation.CompletionHandler<Timer.Controller>() { @Override public void success(Timer.Controller result) { result.start(); } } ); } catch (UnsupportedModuleException e) { Log.e("Error", e.toString()); } }
I would start by adding a 1M ohm resistance across the piezo, as they suggest in the arduino tutorial linked by sparkfun. Piezo elements are capacitive in nature, and may be accumulating significant charge over time. Before taking this step, you might consider turning on the GPIO pin "pull down" on the sensor input. This will apply a resistance in the 10k ohm range, this may or may not be too much of a load and squelch the output.
Ideally, the sensor should have some output filtering applied to reduce the peak voltage it may output -- Piezo elements are capable of generating high voltages that could damage the MetaWear. Here is an example of such a filter: https://en.wikipedia.org/wiki/Low-pass_filter#RC_filter.
If I had to guess as to the reset, the piezo accumulating charge, or generating a high voltage with a particularly hard knock is causing a voltage spike or noise event resulting in a reset.
The value of START_INTERVAL= 20 initially,after your reply I changed START_INTERVAL= 50, now getting data from piezo element and the board is also not resetting at even hard knock.
yes it is essential to add a 1M ohm resistance as suggested in the Arduino tutorial. so I used "pull down" on the sensor input, as you suggest without "pull down" it may damage the board, please check if I have put it correctly as there is no change in the values received form piezo:
private final byte GPIO_PIN = 1; private final int SCAN_INTERVAL = 50;
gpio.setPinPullMode(GPIO_PIN, Gpio.PullMode.PULL_DOWN); final RouteManager.MessageHandler dataHandler = new RouteManager.MessageHandler() { @Override public void process(Message message) { short rawValue = message.getData(Short.class); Log.i("gpio", String.valueOf(rawValue));
} }; AsyncOperation.CompletionHandler<RouteManager> gpioHandler = new AsyncOperation.CompletionHandler<RouteManager>() { @Override public void success(RouteManager result) { result.subscribe(VIBRATION, dataHandler); try { AsyncOperation<Timer.Controller> taskResult = mwBoard.getModule(Timer.class).scheduleTask( new Timer.Task() { @Override public void commands() { gpio.readAnalogIn(GPIO_PIN, Gpio.AnalogReadMode.ADC); } }, SCAN_INTERVAL, false); taskResult.onComplete( new AsyncOperation.CompletionHandler<Timer.Controller>() { @Override public void success(Timer.Controller result) { result.start(); } } ); } catch (UnsupportedModuleException e) { Log.e("Error", e.toString()); } }
Matt's primary suggestion is to follow the Arduino tutorial and add the 1Mohm resistor.
You should ensure that no more resets are occurring after enabling the pull down pin and if the circuit is stable, start collecting data with your sensor.
I have attached 1 M ohm resistor, instead of my app i used to Metawear app to stream data. I am able to get data from gpio pin continuously but after few impacts the board keep getting reset. I don't understand what could be the issue, it seems circuit is stable as board only resets after impacts, checked with other metawear boards as well but problem remains the same.
As matt said, its piezo could be accumulating charge or generating voltage spikes. Can you try measuring the current/voltage produced by your test vibrations using a multimeter?
The MetaWear app reads analog data at 33ms. You should try with your previous value of 50ms which you earlier said was not causing resets.
Comments
if you could suggest this one will work fine?
http://www.amazon.in/Seeedstudio-Piezo-Sensor-MiniSense-100/dp/B017KCLCSE
https://www.sparkfun.com/products/10293
I have hooked the piezo element as Analog input at pin number 9 and grounded at pin number 4, have i hooked in proper pins?
which gpio method should be used to get input value?
not getting result with this;
gpio.readAnalogIn(GPIO_PIN,Gpio.AnalogReadMode.ADC);
also now the website is updated and documentation support is for version 3, can we have support of previous version, such as project.mbientlabs page is not available etc.
GPIO_PIN
variable set to?The problem is solved, was using wrong value in GPIO_PIN variable. GPIO_PIN=1 solved the problem.
If you could help me with another issue, since connection of vibration sensor to the board, the board gets disconnected rapidly within 2-3 minutes.
below is the code: Have i made the connection right as i am getting results?
also what is the natural frequency of the metawear board?
@Eric
The value of START_INTERVAL= 20 initially,after your reply I changed START_INTERVAL= 50, now getting data from piezo element and the board is also not resetting at even hard knock.
@Matt
yes it is essential to add a 1M ohm resistance as suggested in the Arduino tutorial. so I used "pull down" on the sensor input, as you suggest without "pull down" it may damage the board, please check if I have put it correctly as there is no change in the values received form piezo:
I have attached 1 M ohm resistor, instead of my app i used to Metawear app to stream data. I am able to get data from gpio pin continuously but after few impacts the board keep getting reset.
I don't understand what could be the issue, it seems circuit is stable as board only resets after impacts, checked with other metawear boards as well but problem remains the same.