Introduction: Studying Orientation With Raspberry Pi and MXC6226XU Using Python

About: We are a group of makers. We work in IoT, IOS app, android app, embedded design, sensor design, raspberry pi, arduino, beaglebone, particle electron, particle photon, Bluetooth.

Noises are simply a portion of working a vehicle.

The hum of a very much tuned vehicle motor is a magnificent sound. Tire treads murmur against the road, the wind shrieks as it goes around mirrors, plastic bits, and pieces in the dashboard produce little squeaks as they rub together. The vast majority of us don't see these innocuous notes before long. Yet, a few commotions aren't so harmless. An unusual noise can be seen as an early attempt by your vehicle to let you know that something isn't right. What if we use instrumentation and techniques to identify Noise, vibration, and harshness (NVH) including rig squeak and rattle tests, etc. That's worth looking into.

Innovation is one of the important force of the future without bounds; it is changing our lives and molding our future at rates remarkable ever, with significant ramifications which we can't start to see or get it. Raspberry Pi, the micro, single board Linux computer, gives a cheap and moderately simple base for hardware ventures. As computer and electronics enthusiasts, we've been learning a lot with the Raspberry Pi and decided to blend our interests. So what are the conceivable results that what we can do on the off chance that we have a Raspberry Pi and a 2-axis Accelerometer close by ? In this task, we will check the acceleration on 2 perpendicular axes, X and Y, Raspberry Pi and MXC6226XU, a 2-axis accelerometer. So we should see on this, to make a framework analyze the 2-dimensional acceleration.

Step 1: Equipment We Require

The issues were less for us since we have a tremendous measure of stuff lying around to work from. Regardless, we know how it's troublesome for others to store up the right part in impeccable time from the supportive spot and that is shielded paying little notice to each penny. So we would help you. Follow the accompanying to get a complete parts list.

1. Raspberry Pi

The initial step was getting a Raspberry Pi board. The Raspberry Pi is a single-board Linux based PC. This little PC packs a punch in computing power, utilized as a part of gadgets activities, and straightforward operations like spreadsheets, word preparing, web scanning and email, and games. You can purchase one at almost 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. 2-Axis accelerometer, MXC6226XU

The MEMSIC MXC6226XU Digital Thermal Orientation Sensor (DTOS) is (was ;) the world's first fully-integrated orientation sensor. We acquired this sensor from DCUBE Store

4. Connecting Cable

We acquired the I2C Connecting cable from DCUBE Store

5. Micro USB cable

The littlest dazed, yet most stringent to the degree power need is the Raspberry Pi! The simplest approach to arrangement is by the utilization of the Micro USB cable. GPIO pins or USB ports can likewise be utilized to give abundant power supply.

6. Web Access is a Need

INTERNET kids NEVER sleep!

Get your Raspberry Pi connected with an Ethernet (LAN) cable and interface it to your system network. Elective, scan for a WiFi connector and use one of the USB ports to get to the remote network. It's a sharp choice, basic, little and easy!

7. HDMI Cable/Remote Access

The Raspberry Pi has an HDMI port which you can interface particularly to a screen or TV with an HDMI cable. Elective, you can use SSH to take up with your Raspberry Pi from a Linux PC or Mac from the terminal. Moreover, PuTTY, a free and open-source terminal emulator sounds like a not too bad option.

Step 2: Connecting the Hardware

Make the circuit according to the schematic appeared. In the diagram, you will see the diverse parts, power segments and I2C sensors taking after I2C communication protocol.
Imagination is more important than Knowledge.

Connection of the Raspberry Pi and I2C Shield

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).

Connection of the Raspberry Pi and Sensor

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 support the utilization of the I2C cable as it refutes the need for analyzing pin outs, securing, and inconvenience achieved by even the humblest botch. With this crucial connection and play cable, you can introduce, swap out contraptions, or add more devices to an application viable. This encourages the work weight up to a huge 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

The Python Code for the Raspberry Pi and MXC6226XU Sensor is accessible 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 accompanying is the python code and you can clone and change the code in any capacity you slant 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. # MXC6226XU # This code is designed to work with the MXC6226XU_I2CS I2C Mini Module available from #

import smbus import time

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

# MXC6226XU address, 0x16(22) # Select detection register, 0x04(04) # 0x00(00) Power up bus.write_byte_data(0x16, 0x04, 0x00)


# MXC6226XU address, 0x16(22) # Read data back from 0x00(00), 2 bytes # X-Axis, Y-Axis data = bus.read_i2c_block_data(0x16, 0x00, 2)

# Convert the data xAccl = data[0] if xAccl > 127 : xAccl -= 256 yAccl = data[1] if yAccl > 127 : yAccl -= 256

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

Step 4: The Portability 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 after a couple of minutes, it will demonstrate each one of the parameters. In the wake of ensuring that everything works easily, you can utilize this venture each day or make this venture a little part of a much bigger task. Whatever your needs you now have one more gadget in your collection.

Step 5: Applications and Features

Manufactured by MEMSIC Digital Thermal Orientation Sensor (DTOS), the MXC6226XU is a fully Integrated Thermal Accelerometer. The MXC6226XU is appropriate for Consumer applications like Cell Phones, Digital Still Cameras (DSC), Digital Video Cameras (DVC), LCD TV, Toys, MP3 and MP4 Players. With patented MEMS-thermal technology, it’s useful in Household safety applications like Fan Heaters, Halogen Lamps, Iron Cooling and Fans.

Step 6: Conclusion

On the off chance that you've been pondering to investigate the universe of the Raspberry Pi & I2C sensors, then you can astound yourself by making utilized of the electronics fundamentals, coding, planning, binding and so forth. In this procedure, there may be a few tasks that might be simple, while some may test you, challenge you. Be that as it may, you can make a way and immaculate it by altering and making a creation of yours.

For example, You can start with the idea of a prototype to Measure Noise and Vibration (N & V) characteristics of vehicles, particularly cars and trucks using the MXC6226XU and Raspberry Pi along with microphone and force gauges. In the above task, we have utilized fundamental computations. The ideas are to look for tonal noises i.e. engine noise, road noise or wind noise, normally. The resonant systems respond at characteristic frequencies looking like on any one spectrum, their amplitude varies considerably. We can check that for varying amplitudes and create a noise spectrum for that. For e.g. the x-axis can be in terms of multiples of engine speed while the y-axis is logarithmic. Fast Fourier transforms and Statistical Energy Analysis (SEA) can be approached to create a pattern. So you could utilize this sensor in various ways you can consider. We will attempt to make a working rendition of this prototype sooner rather than later, the configuration, the code, and modeling works for structure borne noise and vibration analysis. 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 Trust this venture motivates further exploration. Start where you are. Use what you have done. Do what you can.