Try OpenIntents SensorSimulator:
About the SensorSimulator. The OpenIntents SensorSimulator lets you
simulate sensor data with the mouse in real time. Moreover, you can
simulate your battery level and your gps position too, using a telnet
NEW! Now you can record a sequence with states from a real device.
Also you can use features like editing, saving, loading and playing
the scenario. It currently supports accelerometer, compass,
orientation, temperature, light, proximity, pressure, gravity, linear
acceleration, rotation vector and gyroscope sensors, where the
behavior can be customized through various settings. Here you can find
new features description.