Technical Support

Emulating Accelerometer Data on the Windows Phone 7 Emulator

July 17, 2010, 11:13 p.m.

Developing applications for the Windows Phone 7 emulator is nice, but it doesn't allow us to emulate GPS or accelerometer sensor data. However, a Windows Mobile phone does include an accelerometer that we can programmatically access (via the Windows Mobile Unified Sensor API for Samsung and HTC devices).

Our workaround is simple. At the center of everything is a simple Django app with an SQLite database backend. Because socket programming isn't supported yet on Windows Phone 7, we chose to implement it by using a simple HTTP message passing approach.

On the Windows Mobile device (an HTC Fuze), a simple app queries the accelerometer a few times per second and navigates to a webpage "http://MY.IP.ADDRESS.HERE/set/x/y/z/" to send the data. Here, for instance, x represents the acceleration along the x-axis. Our Django web service parses incoming requests and saves the accelerometer data (on the X, Y, and Z axis) in the database.

In the Windows Phone 7 emulator, we query "http://MY.IP.ADDRESS.HERE/get/", which returns the accelerometer data in a string in the format "x y z". This is parsed and returned to whatever code requested the accelerometer data.

This same approach can be used to pipe real GPS data over to the WP7 emulator. This should work for us until we can get our hands on a real Windows Phone 7 developer preview device.


At Jan. 15, 2013, 5:33 p.m., JazlynTI said:
just dropping by to say hello