Reference for using G248 accelerometer

Where can I find a code reference for G248 accelerometer (ACCEL-GM-442).

I’m right-clicking GTM.GHIElectronics.Accel_G248… to see what my options are but that’s not getting me far!

Trying to get my Cerbot to balance following Taylorza’s fine example but he uses the Seeed module.

Thank you, N

Just include it on the designer and it’ll include the driver… the code behind it is in codeplex, G248/Software/

Thanks a lot Brett! :clap:

I just couldn’t find this codeplex page for some reason.


I seem to have hit the same problem. The codeplex page is no longer available. I have several G248 modules but can’t find any references on how to access them. All of the code examples are apparently for the seeed module and I can’t figure out the method stubs for the older g248 module. Any help would be very much appreciated.


@ slrbatman - The G248 is the newer module, the Seeed module is the older module, below is code used to test the module.

using System.Threading;
using GT = Gadgeteer;

namespace AccelG248_Tester
    public partial class Program
        private static int GRAPH_HEIGHT = 80;
        private static int GRAPH_SPACING = 8;
        private static int TEXT_HEIGHT = 15;

        private int xCoord;
        private GT.Timer timer;
        private GT.Color[] colors;
        private double[] last;

        void ProgramStarted()
            this.displayT43.SimpleGraphics.DisplayText("AccelG248 Tester", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, 0, 0);

            this.xCoord = int.MaxValue;
            this.last = new double[] { 0, 0, 0 };
            this.colors = new GT.Color[] { GT.Color.Red, GT.Color.Green, GT.Color.Blue };

            this.timer = new GT.Timer(25);
            this.timer.Tick += (a) =>
                var acc = this.accelG248.GetAcceleration();

                this.displayT43.SimpleGraphics.DisplayRectangle(GT.Color.Black, 1, GT.Color.Black, 0, this.displayT43.Height - Program.TEXT_HEIGHT, this.displayT43.Width, Program.TEXT_HEIGHT);
                this.displayT43.SimpleGraphics.DisplayText(acc.ToString(), Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, 0, this.displayT43.Height - Program.TEXT_HEIGHT);

                this.Draw(0, acc.X);
                this.Draw(1, acc.Y);
                this.Draw(2, acc.Z);

        private void DrawAxes()
            for (int i = 0; i < 3; i++)
                this.displayT43.SimpleGraphics.DisplayLine(GT.Color.White, 1, 0, i * (Program.GRAPH_HEIGHT + Program.GRAPH_SPACING), 0, i * (Program.GRAPH_HEIGHT + Program.GRAPH_SPACING) + Program.GRAPH_HEIGHT);
                this.displayT43.SimpleGraphics.DisplayLine(GT.Color.White, 1, 0, i * (Program.GRAPH_HEIGHT + Program.GRAPH_SPACING) + Program.GRAPH_HEIGHT / 2, this.displayT43.Width, i * (Program.GRAPH_HEIGHT + Program.GRAPH_SPACING) + Program.GRAPH_HEIGHT / 2);

        private void Draw(int axis, double value)
            if (value < -1.0)
                value = -1.0;

            if (value > 1.0)
                value = 1.0;

            value += 1;
            value /= 2;
            value = 1 - value;
            value *= Program.GRAPH_HEIGHT;

            this.displayT43.SimpleGraphics.DisplayLine(this.colors[axis], 1, this.xCoord, axis * (Program.GRAPH_HEIGHT + Program.GRAPH_SPACING) + (int)this.last[axis], this.xCoord + 1, axis * (Program.GRAPH_HEIGHT + Program.GRAPH_SPACING) + (int)value);

            this.last[axis] = value;

        private void CheckReset()
            if (this.xCoord > this.displayT43.Width)
                this.xCoord = 1;


Thank you much for the quick reply. I truly appreciate it. I will work on this tonight. I plan on building a sensor array with 2 accelerometers, 2 gyroscopes, and 2 compasses all connected via xbee. I am using the G248 modules, and the seeed gyroscope moduels connected with 2 xbees on an exbee adapter connected to spider mainboards and then one connected to a cerbuino. Any advise or example code would be very much appreciated.


Here is more info from a missing Dev Guide:

G248 Accel Module

(Insert photo)
The Developer Guides require the user to be familiar with using the Visual Studio designer to add and connect modules to mainboards, create event handlers, call methods, and set properties on objects. If you are new to Gadgeteer development, please start by working through the Tutorials: First Gadgeteer Project
The G248 Accel Module measures acceleration: it can be used to sense the orientation (or tilt) of a device in 3 dimensions. It can also be used to detect “bump” actions of the device.
Most cellular smart-phones include an accelerometer sensor - this is what makes it possible for the phone to determine if the display should be oriented as portrait or landscape. Phones which support transferring files or contact info when bumped against another phone detect the bump action using the accelerometer.
A common use of the accelerometer is in balancing robots. When the robot is “balanced”, two of the dimensions will read as 0 and the third will read as 1 because the x and y (for instance) will be lying flat and the Z axis will be perpendicular to the earth’s gravitational pull.
The module has functions to return the X, Y, and Z values either one at a time or as a group. The values returned are the number of “counts” read by the sensor. For the G248, one G of force = 256 counts.
Example 1: Doing the Math
By doing a little bit of math, you can determine the G force or the angle of tilt.
The G force = Count / 256

To get the angle of deflection, we need to use some simple trigonometry.
The Angle = ArcSine(G Force)
The trig functions in NetMF return the values in Radians and need to be multiplied by 18 / pi to determine the degrees. 

```cs]double xAsin = System.Math.Asin(xGs) * 180 / System.Math.PI;[/code

Example 2: Sample code

// get the counts for each dimension.  1 G force = 256 counts
int x, y, z;
accel_G248.GetXYZ(out x, out y, out z);
Debug.Print(x + "/" + y + "/" + z);

// convert the counts to G Forces
double xGs = (double) x / 256;
double yGs = (double) y / 256;
double zGs = (double) z / 256;

// convert the G forces to angles.  Asin returns radians and must be converted to degrees
double xAsin = System.Math.Asin(xGs) * 180 / System.Math.PI;
double yAsin = System.Math.Asin(yGs) * 180 / System.Math.PI;
double zAsin = System.Math.Asin(zGs) * 180 / System.Math.PI;
Debug.Print("Asin:" + xAsin + "/" + yAsin + "/" + zAsin);

External Drivers, Documentation, and/or Software
The G248 Accel Module uses the Freescale MMA8453Q chip. The following datasheets and application notes may be helpful for understanding the operation of the device.
MMA845Q Product Page: NXP® Semiconductors Official Site | NXP Semiconductors
Data Sheet: NXP® Semiconductors Official Site | NXP Semiconductors
Basic Operations: NXP® Semiconductors Official Site | NXP Semiconductors
Detecting Freefall: NXP® Semiconductors Official Site | NXP Semiconductors
Single/Double Tap Detection: NXP® Semiconductors Official Site | NXP Semiconductors

1 Like


I am trying to now wire up my G248 module to a Cerbuino Bee with an XBee S1 module inserted into the onboard xbee socket. I am running NetMF 4.3 and everything seems to be fine with the MCU. The XBee’s configured fine in XCTU and I was able to see clean messages passing between them. I wrote a small bit of code to transmit a message from the Cerbuino to the XBee connected to my computer on COM3. I have a listener that will listen to COM3 and process the message when an event is fired.

It appears that my assemblies are hosed in some way because I cant see a reference to SerialPort. I am referencing System.IO.Ports. Is there another assembly that needs to be referenced as well?

Many Thank,