Introduction: Monitoring Acceleration Using Raspberry Pi and AIS328DQTR Using Python

Acceleration is finite, I think according to some laws of Physics.- Terry Riley

A cheetah utilizes amazing acceleration and quick changes in speed when chasing. The speediest creature ashore once in a while utilizes its top pace to catch prey. The creatures get this speeding up by applying almost five times more power than that of Usain Bolt amid his record-breaking 100m run.

In the present time, individuals can't envision their existence without innovation. Surrounding us different innovations are assisting people to carry on with their existence with more extravagance. Raspberry Pi, the mini, single board Linux PC, gives a cheap and respectable base for electronics endeavors and cutting-edge advancements like IoT, Smart Cities, and School Education. As computer and gadgets fans , we've been taking in a considerable measure with the Raspberry Pi and chose to mix our interests. So what are the possible results that what we can do if we have a Raspberry Pi and a 3-axis Accelerometer close by ? In this task, we will incorporate AIS328DQTR, a digital 3-axis MEMS linear accelerometer sensor, to measure acceleration in 3 directions, X, Y, and Z, with the Raspberry Pi using Python. That's worth looking into.

Step 1: Hardware We Require

The issues were less for us since we have a huge measure of stuff lying around to work from. In any case, we know how it's troublesome for others to put away the right part in perfect time from the strong spot and that is protected paying little notice to every penny. So we would help you.


1. Raspberry Pi

The initial step was getting a Raspberry Pi board. The Raspberry Pi is a solitary board Linux based PC. This little PC packs a punch in registering power, used as a piece of electronics exercises, and PC operations like spreadsheets, word processing, web surfing and email, and games. You can buy one at any electronics or hobbyist store.

2. I2C Shield for Raspberry Pi

The primary concern the Raspberry Pi is truly absent is an I2C port. So for that, the TOUTPI2 I2C connector gives you the sense to use Raspberry Pi with ANY of I2C devices. It's available on DCUBE Store

3. 3-Axis accelerometer, AIS328DQTR

Belonging to the STMicroelectronics motion sensors, the AIS328DQTR is an ultra low-power high-performance 3-axis linear accelerometer with a digital serial interface SPI standard output. We acquired this sensor from DCUBE Store

4. Connecting Cable

We acquired the I2C Connecting cable from DCUBE Store

5. Micro USB cable

The humblest bewildered, yet most stringent to the degree power need is the Raspberry Pi! The most straightforward way to deal with the game plan is by the use of the Micro USB cable.GPIO pins or USB ports can in like manner be used to give ample power supply.

6. Web Access is a Need

Get your Raspberry Pi associated with an Ethernet (LAN) cable and interface it to your network. On the other hand, scan for a WiFi connector and utilize one of the USB ports to get to the remote network. It's a sharp decision, fundamental, little and simple!

7. HDMI Cable/Remote Access

The Raspberry Pi has an HDMI port which you can interface especially to a Monitor or TV with an HDMI cable. Elective, you can utilize SSH to bring up with your Raspberry Pi from a Linux PC or Macintosh from the terminal. Also,PuTTY, a free and open-source terminal emulator sounds like a not all that bad choice.

Step 2: Connecting the Hardware

Make the circuit as indicated by the schematic showed up. In the graph, you will see the various parts, power fragments, and I2C sensor.

Raspberry Pi and I2C Shield Connection

Most importantly else, take the Raspberry Pi and spot the I2C Shield on it. Press the Shield carefully over the GPIO pins of Pi and we are done with this step as straightforward as pie (see the snap).

Raspberry Pi and Sensor Connection

Take the sensor and Interface the I2C cable with it. For the suitable operation of this cable, please review I2C Output ALWAYS takes up with the I2C Input. The same must be taken after for the Raspberry Pi with the I2C shield mounted over the GPIO pins.

We encourage the use of the I2C cable as it negates the requirement for dissecting pinouts, securing, and bother accomplished by even the humblest mess up. With this significant association and play cable, you can present, swap out contraptions, or add more gadgets to an application suitable. This supports the work weight up to an immense level.

Note: The brown wire ought to dependably follow the Ground (GND) connection between the output of one device and the input of another device.

Web Network is Key

To make our attempt a win, we require a Web connection for our Raspberry Pi. For this, you have options like interfacing an Ethernet (LAN) join with the home network. Moreover, as an option, a pleasing course is to utilize a WiFi USB connector. Generally speaking for this, you require a driver to make it work. So lean toward the one with Linux in the depiction.

Power Supply

Plug in the Micro USB cable into the power jack of the Raspberry Pi. Punch up and we are ready.

Connection to Screen

We can have the HDMI cable connected to another Monitor. Sometimes, you need to get to a Raspberry Pi without interfacing it to a screen or you may need to view information from it from elsewhere. Possibly, there are creative and fiscally clever ways to deal with doing all things considered. One of them is using - SSH(remote command-line login). You can likewise use the PuTTY software for that.

Step 3: Python Coding for Raspberry Pi

You can view the Python Code for the Raspberry Pi and AIS328DQTR Sensor in our Github Repository.

Before proceeding to the code, ensure you read the rules given in the Readme archive and Set up your Raspberry Pi according to it. It will just respite for a moment to do all things considered.

An accelerometer is an electromechanical gadget that will gauge acceleration forces. These powers might be static, similar to the constant force of gravity pulling at your feet, or they could be alterable - brought on by moving or vibrating the accelerometer.

The going with is the python code and you can clone and change the code in any way you incline toward.

# Distributed with a free-will license.
# Use it any way you want, profit or free, provided it fits in the licenses of its associated works. # AIS328DQTR # This code is designed to work with the AIS328DQTR_I2CS I2C Mini Module available from dcubestore.com # http://dcubestore.com/product/ais328dqtr-high-performance-ultra-low-power-3-axis-accelerometer-with-digital-output-for-automotive-applications-i%C2%B2c-mini-module/

import smbus import time

# Get I2C bus bus = smbus.SMBus(1)

# AIS328DQTR address, 0x18(24) # Select control register1, 0x20(32) # 0x27(39) Power ON mode, Data rate selection = 50Hz # X, Y, Z-Axis enabled bus.write_byte_data(0x18, 0x20, 0x27) # AIS328DQTR address, 0x18(24) # Select control register4, 0x23(35) # 0x30(48) Continuous update, Full-scale selection = +/-8G bus.write_byte_data(0x18, 0x23, 0x30)

time.sleep(0.5)

# AIS328DQTR address, 0x18(24) # Read data back from 0x28(40), 2 bytes # X-Axis LSB, X-Axis MSB data0 = bus.read_byte_data(0x18, 0x28) data1 = bus.read_byte_data(0x18, 0x29)

# Convert the data xAccl = data1 * 256 + data0 if xAccl > 32767 : xAccl -= 65536

# AIS328DQTR address, 0x18(24) # Read data back from 0x2A(42), 2 bytes # Y-Axis LSB, Y-Axis MSB data0 = bus.read_byte_data(0x18, 0x2A) data1 = bus.read_byte_data(0x18, 0x2B)

# Convert the data yAccl = data1 * 256 + data0 if yAccl > 32767 : yAccl -= 65536

# AIS328DQTR address, 0x18(24) # Read data back from 0x2C(44), 2 bytes # Z-Axis LSB, Z-Axis MSB data0 = bus.read_byte_data(0x18, 0x2C) data1 = bus.read_byte_data(0x18, 0x2D)

# Convert the data zAccl = data1 * 256 + data0 if zAccl > 32767 : zAccl -= 65536

# Output data to screen print "Acceleration in X-Axis : %d" %xAccl print "Acceleration in Y-Axis : %d" %yAccl print "Acceleration in Z-Axis : %d" %zAccl

Step 4: The Practicality of the Code

Download (or git pull) the code from Github and open it in the Raspberry Pi.

Run the commands to Compile and Upload the code in the terminal and see the yield on Screen. Taking following several minutes, it will exhibit every one of the parameters. In the wake of guaranteeing that everything works effortlessly, you can use this venture every day or make this venture a little part of a much greater assignment. Whatever your needs you now have one more contraption in your accumulation.

Step 5: Applications and Features

Manufactured by STMicroelectronics, ultra compact low-power high performance 3 axes linear accelerometer belonging to the motion sensors. The AIS328DQTR is appropriate for application such as Telematics and Black Boxes, In-Dash Car Navigation, Tilt / Inclination Measurement, Anti-Theft Device, Intelligent Power Saving, Impact Recognition and Logging, Vibration Monitoring and Compensation and Motion-Activated Functions.

Step 6: Conclusion

If you've been contemplating to explore the universe of the Raspberry Pi and I2C sensors, then you can shock yourself by making used of the hardware basics, coding, arranging, authoritative, etc. In this method, there might be a couple errands that may be straightforward, while some may test you, move you. In any case, you can make a way and flawless it by changing and making a formation of yours.

For example, You can begin with the thought of a Behavior Tracker Prototype to monitor and depict the physical movements and body stances of animals with AIS328DQTR and Raspberry Pi using Python. In the above task, we have utilized fundamental computations of an accelerometer. The protocol is to create a system of accelerometer along with any Gyrometer and a GPS, and a supervised(machine) learning algorithm(support vector machine (SVM)) for automated behavior identification of animals. This to be followed by the collection of parallel sensor measurements and evaluation of the measurements by using support vector machine (SVM) classification. Use different combinations of independent measurements(sitting, walking or running) for training and validation to determine of robustness of the prototype. We will attempt to make a working rendition of this prototype sooner rather than later, the configuration, the code, and modeling works for more behavioral modes. We believe all of you like it!

For your comfort, we have a charming video on YouTube which may help your examination. Trust this endeavor motivates further exploration. Start where you are. Use what you have. Do what you can.

Comments