|
Post by papa on Oct 23, 2018 20:55:00 GMT
A vibration sensor could help monitor a variety of things, various motors & machines & other objects that ... create vibrations.
VibrationSensor_Joshua.ino (347 B) << I began testing my vibration sensor board using this sketch excerpted from Joshua's RFM69 contributions. I connected sensor DO to Arduino A0 (Joshua used A4), sensor VCC to Arduino 3.3v, sensor GND to Arduino GND. (My vibration sensor board has only 3 pins & no AO pin.) I did not use the board's potentiometer to change the sensitivity. While running the sketch & watching the Arduino IDE Serial Monitor (SM), I rested the Arduino-connected sensor breakout board on a Dremel type tool. When the Dremel was off, SM showed "Vibration : 30" or "Vibration : 29" When the Dremmel was on & making vibrations, SM showed "Vibration : 1023"
|
|
|
Post by papa on Oct 23, 2018 21:01:45 GMT
<< Forum members (free registration), click on pic for larger view. This ^^ illustrates & labels the vibration sensor board that I'm using. When the Dremmel tool (see the last post) was on & making vibrations, the board's signal indicator LED flashed (a way to see vibration detected without using the Arduino IDE's Serial Monitor). The board can lay flat on a strong vibration source & vibration will be detected. On one end of the sensor board, note the cylinder that is the vibration sensor element. Not-so-strong vibration seems to be detected better when the vibration sensor cylinder & the board are perpendicular to the vibration source.
Next, Connect Vibration Sensor to Arduino Compatible
|
|
|
Post by papa on Oct 24, 2018 19:26:08 GMT
Connect Vibration Sensor to Arduino Compatible
<< Forum members (free registration), click on pic for larger view.
Above is a diagram of connecting a Vibration Sensor to an Arduino compatible. We are using a compatible that can send 3.3 volts through its digital pins (D2, etc) because 5 volts will damage an RFM69 radio that we want to add later.
Schematic change on Oct. 26, 2018: To power the Vibration Sensor, we now will use Arduino D4 which the sketch will power with 3.3 volts. An Arduino compatible has only one dedicated 3.3 volt socket & later we will need that to power an RFM69 radio.
Make the connections according to the labels of the pins. The pins' locations in the diagram do NOT match their actual locations.
We will use these connections in this thread's sketches. We will later build on these connections to create a node that communicates vibration data wirelessly to OpenHAB.
Next, Preparing for An RFM69 Vibration Sensor Node
|
|
|
Post by papa on Oct 25, 2018 21:34:02 GMT
Preparing for An RFM69 Vibration Sensor Node
In order to communicate with OpenHAB, this node needs you to have built & programmed a separate RFM69 Gateway. You also need experience achieving an RFM69 network. The Building an RFM69 Home Automation Network thread & the linked Gateway thread will lead you step by step (with troubleshooting hints) to achieve your first network. In that RFM69 Network thread, work your way through making the RFM69 Bare Bones End Node & getting it communicating with the RFM69 Gateway. That is, you can follow the thread & stop after achieving this post. Then you can add the vibration sensor breakout board to the Bare Bones End Node (schematic below) with a high likelihood of success.
Skip this step if you already have a working Gateway & node. If you do NOT have a working Gateway & node yet, do NOT skip this step because it is probably the most challenging aspect of the project.
Next, Schematic for An RFM69 Vibration Sensor Node
|
|
|
Post by papa on Oct 27, 2018 20:00:15 GMT
Schematic for An RFM69 Vibration Sensor Node
Be kind to yourself & do NOT build this node until you have created your RFM69 Gateway & a least one previous node (See previous post).
<< Forum members, click on pic for larger view
added parts: 3 (color-coded ?) dupont male to female cables to connect the Arduino sockets to the sensors' pins.
Note 1: In this schematic, its important to use an Arduino compatible (like a Buono Uno) that sends 3.3 volts through its digital pins (like D2). A 5 volt Arduino would damage the RFM69 radio. The Building an RFM69 Home Automation Network thread & the linked Gateway thread gives more about this.
Note 2: The Vibration Sensor's VCC is powered by 3.3 volts from Arduino D4, not from Arduino's 3.3 volt socket. The sketch below will set Arduino D4 HIGH so it can power the sensor.
Note 3: Make the connections according to the labels of the pins. The pins' locations in the schematic diagram do NOT match their actual locations.
Next, Program an RFM69 Vibration Sensor Node
|
|
|
Post by papa on Oct 29, 2018 19:53:12 GMT
Program an RFM69 Vibration Sensor Node Updated Nov. 26, 2018
GO HERE to download the latest node choices sketch (new version Dec. 7, 2018) & achieve initial customization. Open the with the Arduino IDE. This coding now uses the tsai sampling that works well for the MIC Sound Sensor & works much better for the vibration sensor. To see how the vibration sensor code works, look at the sketch sections that start with #ifdef VIBR_tsai. This vibration sensor programming is different from what Joshua provided in his Adding More Sensors to RFM69 Nodes thread. However, I made I also changed Joshua's wiring: Joshua used Arduino A 4 to receive vibration data from the sensor, but I use A 0. Joshua used an Arduino power socket, but I used Arduino D4 (set to output HIGH) to power the sensor. Next, Customizing the Node Choices Sketch for a Vibration Sensor Node
|
|
|
Post by papa on Oct 29, 2018 19:57:59 GMT
Customizing the Node Choices Sketch for a Vibration Sensing & Timing Node Updated Dec. 16, 2018
To the initial customization obtained above, add:
#define NODEID 05 << change 05 to a unique number in your RFM69 network (For this sound sensor node, I suggest you use NODEID 90 as I will below.)
Find these THREE lines & UNcomment the first two lines : // #define sample_tsai < Uncomment this line (no // at its start) // #define VIBR_tsai < Uncomment this line // #define MIC_tsai < leave this line commented
(Caution: VIBR_tsai & MIC_tsai cannot be used on the same node)
Optional, for more Serial Monitor detail, UNcomment this line: // #define sampleReport
Connect the node to your computer's USB. Using the Arduino IDE, upload the customized sketch to the Vibration Sensor End Node. Next, Vibration Sensor End Node, Serial Monitor Results
|
|
|
Post by papa on Oct 29, 2018 20:05:02 GMT
Vibration Sensing & Timing Node, Serial Monitor Results Updated Nov. 26, 2018
Open the Arduino IDE's Serial Monitor & at the lower right, set it to 115200 baud & here are some sample results you could expect (my comments in colored text):
(If // #define sampleReport is UNcommented, more sampling detail will show) Node 90 Version MhF9p VIBtsai GW2.5.1 [ NODEID, sketch version, function, Gateway version [startup messages]Transmitting at 915 Mhz... < RFM69 radio frequency, successful transmission to Gateway Node: 90 dev: 99 cmd: 0 Ival: 0 Fval: 0.00 RSSI: -48 < device 99, wake upNode: 90 dev: 2 cmd: 0 Ival: 0 Fval: 0.00 RSSI: -49 < device 2, Radio Signal Strength (RSSI=-49)Node: 90 dev: 4 cmd: 0 Ival: 0 Fval: 3.26 RSSI: -48 < device 4, node voltage (3.22)Node: 90 dev: 9 cmd: 0 Ival: 1 Fval: 3.26 RSSI: -48 < device 9, transmission attempts needed for success (only 1)Node: 90 dev: 71 cmd: 0 Ival: 0 Fval: 3.26 RSSI: -48 quiet !! < periods of quiet quiet !! signal running, secs: 0 < started sensing vibrationNode: 90 dev: 71 cmd: 0 Ival: 0 Fval: 0.00 RSSI: -49 signal running, secs: 2 signal running, secs: 4 < vibration secs, updates on Serial Monitor signal running, secs: 6 but not sent to OpenHAB signal running, secs: 8 until vibration ends total seconds of signal: 10 quiet !! < ^ detect quiet, ending duration of vibration
Node: 90 dev: 71 cmd: 0 Ival: -10 Fval: 0.00 RSSI: -54 quiet !! ^ -10 negative means vibration ended ^ device 71 sent to OpenHAB via Gateway
Next, Vibration Sensing/Timing Node, Configuring for OpenHAB 2 Results
|
|
|
Post by papa on Oct 30, 2018 21:17:41 GMT
Vibration Sensor Node, Configuring for OpenHAB 2 Results Updated Nov. 26, 2018
(Note: the following assumes NODEID 90 (see customizing above) & installation of OpenHAB 2, MQTT binding, & Mosquitto.) Vib_Sense90.items (573 B) << Download & save to OpenHAB 2's \conf\ items folder This file contains items for Node 90 radio signal strength, voltage, vibration state, & vibration value (vibration seconds), & vibration change timestamp. Vib_Sense90.rules (979 B) << Download & save to OpenHAB 2's \conf\ rules folder This file contains a "Vibr90_Timer_Status" rule that converts negative vibration values (secs) to quiet & positive values to VIBRATE in the item Node90VibState. That rule also timestamps changes in vibration state. The rule "When_Vibr90_State_changes" triggers a OpenHAB log entry when vibration state happens. Add these lines to your xxx. sitemap file in OpenHAB 2's \conf\ sitemaps folder: Switch item=Node90VibState Text item=vibr90_time Text item=Node90VibVal
On the OpenHAB User Interface in a browser or mobile app, this will display the Node 90 vibration state (as a switch), & vibration value (vibrations seconds), & vibration change timestamp.
Next, Vibration Sensing / Timing Node, Getting OpenHAB 2 Results
|
|
|
Post by papa on Oct 30, 2018 21:38:04 GMT
Vibration Sensing / Timing Node, Getting OpenHAB 2 Results on the User Interface Updated Nov. 26, 2018
click on pics for larger view User Interface as Vibration is happening
User Interface when quiet ends Vibration after 2 seconds
Using the Tsai sampling code, the updated Node Choices sketch should time vibration duration, accurate within 2 seconds.
Hint: If the User Interface does not display changes without refreshing the browser, stop the OpenHAB 2 service & restart it.
Next, Toward a Vibration Timing Node, Improving the Vibration Sensor Node
|
|
|
Post by papa on Nov 1, 2018 21:28:20 GMT
Vibration Timing Node A Better Approach Was used
I removed early November 2018 documentation & sketch about a Vibration Timing node. The code was messy & timing accuracy not very close.
As written in this post above, the sketch now adapts sensor sampling code from Eric Tsai which works much better & timing is accurate within 1 or 2 seconds.
Next, More Thoughts on Using a Vibration Sensing / Timing Node
|
|
|
Post by papa on Nov 1, 2018 21:33:23 GMT
Thoughts on Using a Vibration Timing NodeAs I said on starting this thread, "A vibration sensor could help monitor a variety of things, various motors & machines & other objects that ... create vibrations.
I want to enhance my sump hole monitoring node, so I plan to add the Vibration Sensor & the Vibration Timing code to the node in the Water Level Monitor Node, Type 2 thread. If successful, I will update that thread.
We should be able to add the Vibration Timing feature to another node as long as we avoid using Arduino pins already being claimed (if needed, we can change the sketch to use available pins) AND as long as we don't require more current than the Arduino Compatible can provide.
I hope others find the above beneficial. Enjoy.
|
|
|
Post by papa on Nov 5, 2018 22:09:43 GMT
More on Using the Vibration Timing Feature of a Node Updated Nov. 27, 2018
When the sample_tsai & VIBR_tsai options are defined for a node, that feature sends to an OpenHAB item an integer that represents seconds of vibration (accurate within 1 or 2 seconds). The integer is positive for current vibration & negative for past vibration. From the integer's sign, an OpenHAB rule can determine if vibration is on or off & set a User Interface switch accordingly.
An OpenHAB rule can also timestamp the last time the vibration was on or off. As I have updated at adding a vibration sensor to a water level node, one can have an OpenHAB rule take different actions based on combining the vibration state with other information (like water level). Other OpenHAB rules could use the vibration timing data for other purposes.
|
|
|
Post by papa on Nov 28, 2018 3:53:19 GMT
Vibration Sensing / Timing Node &
Water Level Monitor Node with Vibration Sensor
Were Updated Nov. 26 & 27, 2018Starting with this post above, the programming & documentation for the Vibration Sensing / Timing node was updated with a much better approach. It parallels work on the Sound Sensing / Timing Node. I also used this improved programming to add a vibration sensor to a water level monitoring node as documented here.
|
|