The code shown below is part sample code to demonstrate reading the registers via I2C and displaying the data with node.js. The alteration that has been made is to specify a timeout period for the server, as well as an additional function that will execute the terminal commands required to poll the gyroscopic sensor in return its register values. The code will also zero out the gyro to account for the internal bias the gyro might have just being stationary and level.

The code shown below is part sample code to demonstrate reading the registers via I2C and displaying the data with node.js. The alteration that has been made is to specify a timeout period for the server, as well as an additional function that will execute the terminal commands required to poll the gyroscopic sensor in return its register values. The code will also zero out the gyro to account for the internal bias the gyro might have just being stationary and level.

+

+

One alteration you'll need to make is to change the path the exec function with in the pushMessage function calls the custom c program to read the I2C buss. Just change the path to point to the excusable you compile with gcc using available MiniProject02.c file within the same directory as the HTML and node.js files, all the necessary header files are included as well.

Contents

Overview

This project show how the ITG-3200, a three-axis gyro sensor, can read and displayed using the beagle bone, a web browser and node.js. This project expands upon what was documented in SparkFun:_ITG-3200,Triple-Axis_Gyro.

ITG-3200 breakout board pin-out

Here's the first display screen you will see after entering the bones web address, go ahead and click on the Button Dox Demo link

Once the script is up and running you will begin to see the sensor data rendered across the time axis plots with regards to each rotational direction of the gyroscope as well as its internal temperature

Introduction

The goal here is to add a web-based graphical display to the gyroscopic sensor. Using examples of node.js servers that display realtime data from the beagle, I have altered the example code to display specifically the three axes of rotation for the gyroscope as well as in addition the internal temperature of the sensor itself.

buttonBox.js, buttonBox.html

This is a bone-based example that reads a gpio port, analog in and an i2c device and displays the output in a web browser.These will be there two main files that will contain many of my alterations.

Running the code

First off, you'll need to download the code through the get hub repository onto a local directory within your Beagle bone. You will then need to navigate to:

Connecting to the Bone

Then point a browser to beaglebone.local:8081. The default port is 8081. You can change it if you like.

How it works

The prior examples included the script within the HTML file that polled the server continuously for data updates. However I have altered the code within the HTML file as well as the .js file to allow the server to be so fully responsible for pushing the data to the client.

Another alteration I have made is to alter the I2C function that is called to acquisition the sensor data. Using the source code within mini project two, I have made a stripped-down version that simply returns all the relevant registers within the sensor. This is interpreted as a string within the server's .js file and is streamed to the client browser where the script parses the relevant information to each specific axis and temperature variable. This is then plotted on the grass and rendered on-screen over time.

This setup is accurate for the Sample Code up to the point about the brackeout board pinout. Just adjust the pin to the ITG-3200 accordingly to by description below. See EBC Exercise 12 I2C for more detail

Code

Node.js Code

The code shown below is part sample code to demonstrate reading the registers via I2C and displaying the data with node.js. The alteration that has been made is to specify a timeout period for the server, as well as an additional function that will execute the terminal commands required to poll the gyroscopic sensor in return its register values. The code will also zero out the gyro to account for the internal bias the gyro might have just being stationary and level.

One alteration you'll need to make is to change the path the exec function with in the pushMessage function calls the custom c program to read the I2C buss. Just change the path to point to the excusable you compile with gcc using available MiniProject02.c file within the same directory as the HTML and node.js files, all the necessary header files are included as well.

HTML Code

This file is altered from example code and contains all the necessary formatting for the user interface and data representation. A also contains the script necessary to parse the string containing the sensor data sent by the server.