Vibration Sensor / train sensor

Attempting to rig up a few vibration sensors to do a couple things - see what if any vibration the tools get and see if we can correlate data with NetworkRail data feeds which are confusing so correlations should highlight what data is relevent. We can then show some kind of warning (flashing light or similar) before a train goes overhead, so we know we’re about to be interrupted.

I scrounged a RPi and Sense Hat so prototyped using that. May shift over to an ESP and accelerometer breakout in the future although that will mean porting all my code :confused:

Not really played with accelerometers before but they are supersensitive, quickly had it dumping samples to a csv file and a quick graph shows promising results:

From picking it up and shaking it around:

From knocking on the table next to it:

This shows that we can pick up vibrations through solids quite well (each spike was one of my knocks) so we should be able to pick up a train.

So refreshed my rusty python and made it so the accelerometer data is displayed on the RGB matrix (no video not allowed :frowning: ):

github repo:

Next steps is to strap it to one of the threaded bars coming out of the ceiling as these are going to vibrate the most when a train is overhead and be mostly isolated form what is going on in the space, and then filter / analyse our data suitably and hopefully get a Train: True/False output reading… Help on that front is welcome :slight_smile:

I’m also using a makerspace PEG DHCP for this project while I prototype, so thanks @jonathanjo for setting that up super useful!

9 Likes

Awesome!

I think I’ve worked out the berths we need to look at (see the other thread ), let me know if you need a hand with the network rail data feeds :smiley:

Hi Neil,

I’m Tom, new member here. Just paid up my direct debit and looking forward to getting involved in some projects, learn some new skills and sharing some of what I know.

I’m a computer scientist, have a fair amount of AVR/ARM development knowledge, and dabbled in machine learning/computer vision theory and open source tools. It seems a convolutional neural network might be a sensible approach to this classification problem. I have used a similar approach in my cloud-based cat detection system which pings my phone when my cat wants to come inside.

Anyway, I’d be keen to help out. I’ll be popping down to the open day tomorrow so maybe catch you then or in the makerspace at some other point.

4 Likes

This. Sounds. Awesome. That is all.

2 Likes

My thoughts exactly.

Great to talk yesterday, will get you some data soon!

Yes, good to meet you and the others at the space. Ping me over some data when you get a chance and we can catch up when I’ve processed it.

I’ve worked with Network Rails APIs before if you need a hand. Done in Python with a library I can’t quite remember right now.

I’m looking at what can be pulled from the Darwin API - may be complementary to your vibration data.

Train Describes probably a better bet for something raw like where a train is on the tracks. Darwin is… only as good as the TD/TRUST data it gets fed, and you don’t get the raw step data (even on the push port feed)

See more of what I’ve worked out so far here

@pip Am I able to ssh into the rPi and grab data from it? I might be in the space tomorrow

Not yet sadly, between holidays and work I’ve not yet set up csv recording though I’m a few lines away. Another reason for the delay is that I wanted to minimise the noise from the sensor, so the signal is clearer and massively reduce the dataset size.

After some googling I came across some tutorials in PyWavelets and I don’t understand the maths behind it, but it works pretty well (see graph below) original in blue, denoised in red. Going for a square-ish output for minimal data size. This is with the knocking example, so threshold may need to be changed, but we can play with that. What time are you around tomorrow, we can maybe look at best options tomorrow?

I’ve written functions to take 100 samples, denoise it, then save it a csv, I just need to plumb it together - half finished code on the pi in the space so I wouldn’t run anything on there. I could also FTP that data to someplace, if you have place I can send it?

What frequency does the accelerometer sample at? 1000Hz? Depending on what method we use, we might get better results with raw data. The problem with de-noising things is you are throwing data away…
Let’s say we look at 5 seconds of data per sample, which is 5000 data points (at 5Hz) per channel, so 15000 points. It’s not by any means an unreasonable amount of data to push through a classifier.

Anyway, should be around all day tomorrow. I have a very small amount of work to do in the morning, then I’m going to be making stuff!!

I mean 1000Hz, not 5Hz!

Do you think it might be possible to work with @systems to install the networking and maybe power a bit better, there are cables stretched over the social area making it difficult to use the ports for other uses, I had to disconnect the printer the other day as I didn’t want to interrupt this project, there must surely be a switch on top of the toilet that could be used?

Thanks for not unplugging it. I put a 8 port switch in I found in the snug, it’s behind the printer. If it becomes a permanent install I’ll do something more tidy.

I’ll get you raw data then. It’s sample rate is much much slower than that also, more like 100-200hz

I can hopefully get it recording tonight and then you can grab what they’re is before you leave gives you a 24 hour data set. Will you be using a machine learning type thing that you ’ train ’ with sample data?

Great! I’m not sure, to be honest. It would be interesting to try this type of approach… It might work very well, but also might need quite a bit of training data to get robust results.
As a first step, let’s do some more basic signal processing and see how the data changes when a train is approaching.

Sounds good to me, it’s saving 10000 rows of xyz data plus timestamps into each csv file, filename is timestamp also in ~/trainpi_savedata on the Pi, 10.0.4.45, stock jessie username and password.

There’s uncommitted changes in the slms_vibrationsensor report, also in home folder, so don’t do anything drastic in there

When you ssh in it’ll be running Byobu ssh manager so you’ll need a cheat sheet of commands if you’re not familiar with that. Great tool if you’ve not used it before, if you’re on Mac it’s F2, F3, F4, F6 to create new shell, go ‘left’, go ‘right’, and detach, respectively. Never figured out the ctl key based shortcuts.

Any problems let me know

1 Like

You get any data Tom?

Anyone else is free to download and analyse the data, @frasco and @peter_hellyer were threatening to come up with approaches…

Here’s a tiny sample of 1000 data points, but for the first 2/3rds or so there was a train thurdunking overhead, so gives an indication of what train / no train is like - https://docs.google.com/spreadsheets/d/1cKOqdhBzu6c617GZqjiRomedgEntFZoqQNHxkxnReAI/edit?usp=sharing