Accelerometer (Raspberry Pi)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] let's go a lot of guys in today's tutorial I'm going to be covering how to set up an accelerometer with the Raspberry Pi in this case we're using the ad excel 3-4-5 sensor so this is essentially a I squared C device and my short experience using it it performs pretty well and it's also relatively low costs at around I would say like five dollars on Amazon or Ebay and as always all the links affiliate links so for these parts will be listed down below with all that said let's go ahead and get started the things that you're in need for this tutorial include the sensor and for female a female jumper cables so the first thing that we need to do is wire the jumper cables to the sensor you can see there's a lot of pins on the sensor but we're going to be using four we're going to be using the 3.3 volt and the ground as well as the SCL and SDA pins so the first thing we're to do is hook up power so I'm going to be using the this red and brown jumper cable so the red jumper cable will hook up to 3.3 volts here and then the brown will be hooked up to the ground pin okay that's done so we have this orange pin here and I'm just gonna hook it up to the SCL pin and then finally this green jumper cable I'm gonna hook up to the SDA in and then there you go we're all wired up on the sensor side so now we're gonna hook it up to the PI so the red power cable needs to be hooked up to the 3.3 volts so that's the first pin on the bottom row here sorry I'm sort of obscuring your vision and then we have ground so that's the third pin on the top row and then finally we just need to hook up the I squared C pin so need reference this real quick so I don't why that's wrong so SCL is the third pin at sales knowledge SEL is the third pin on the bottom rail so one two three and then that leaves SDA which is the second pin on the bottom row and there you go so that sort of completes the physical setup for the Raspberry Pi on this accelerometer sensor so we're gonna move on to the computer walk through the Python script watch it in action and also talk about some possibly use cases for the sensor so let's head on over get project created by TDI Cola so this is the software that we're going to run to interact with the accelerometer and it uses I squared C so let's go ahead and pull down the project so the way that we do that is just we just clone this link here so copy I've already fired up a SSH session with my PI so I'm just going to type get clone the project essentially before we go ahead and set up set it up we need to do one thing and we need to enable the I squared C interface so we're gonna type sudo raspy config and then we're gonna go to interfacing aughh options select I squared C ice and in this case I already have it enabled but I'm just gonna walk you through it so now that we know for sure I squared C is enabled and we can just go to finish and to physically check that our device is hooked up to the Raspberry Pi we're just gonna run this command which is sudo I squared C - tech - y1 and as you can see here there's this integer 53 so we know that's good if you don't see anything that means either your sensor is bad or you have it wired and properly so now that we've gone through the checks let's go ahead and install that get project so if we scroll down here he's actually provided the instructions so if we type LS we can see the project that we've pulled down I'm gonna go ahead and CD into it so CD 8 a tab over to have complete type else again we can see this set up Python script so I'm just gonna copy the command he's outlined here sudo python set up install i've already installed this so you'll probably see some different output so that's done okay so now we can navigate to the examples subfolder so CD examples and I'm just going to display the contents of simple tests so sudo an old simple test py this is the script that you would edit in order to change the functionality with your accelerometer so just walking through his script he's imported some libraries here and this is essentially where he's reading the values and printing them to the screen so this time dot sleep value essentially defines the refresh rate so if you want to refresh a little bit faster you would reduce it to for example 0.25 but let's go ahead and run this and see how how it functions so I'm just going to hit control X and get out of there so now we can just do sudo or actually don't need sudo python simple test py and as you can see here it's reading the values you values if I were to move the sensor which I'll go ahead and do right now you can see that you get the different positional data for the three different planes so XY and Z let's go ahead and stop this script I'm going to go ahead and try and increase the refresh rate a little bit so sudo nano simple scroll down let's change this at 0.25 I think if you want to get really close to real-time you do point one but I think you're gonna run to a performance ball neck if you go any lower than this but your mileage may vary it's just what I've come to experience just do that rerun the script you can see it's outputting a lot faster so yeah that's essentially the tutorial for today I just want to show you how to get this sensor up and running I think I touched on possible use cases at the beginning of this video so there's a number of use cases you could use a sensor for one thing I could think of is sort of a trigger of some sort so you could set a threshold for one of the planes you'd have to fine-tune it to your application so let's say you know the X plane exceeds 300 it triggers some sort of action or you can graph this data so I don't know if you are in some sort of vehicle or something you could like 3d model the position and rotation but those are that's a little bit advanced so yeah I hope you enjoyed today today's tutorial I know it's a little bit all over the place I apologize about that stay tuned for upcoming videos it's always appreciated you know if you like home and subscribe yeah and happy hacking peace you
Info
Channel: PiddlerInTheRoot
Views: 36,094
Rating: undefined out of 5
Keywords: Raspberry, Pi, ADXL345, Accelerometer
Id: NPTK0inTldw
Channel Id: undefined
Length: 10min 19sec (619 seconds)
Published: Sun Dec 10 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.