I have just posted a small "node.js" project on GitHub using a mobile phone as a Compass / Pitch / Roll sensor to my Raspberry Pi.
Communication scenario:
- Phone: Home wifi network,
- Pi: Home network,
- Internet accessability: yes
It uses an easy "node.js" implementation of a 1-page webserver on the Raspberry Pi.
The Pi can then very easily accept a stream of "orientation" data from the phone.
This includes figures for yaw (compass), pitch (front up), and roll (side up).
The phone becomes a hand-held movement controller, like a modern game controller.
SETUP:
1. Make yourself a working directory and make your project in there. Eg /home/pi/gyro/
2. NODE.JS: If you install from the Raspbian repository, you get an old version of node.js. Instead get it from
http://node-arm.herokuapp.com/
This installed node 0.12.1 for me.
3. MODULES: Use Node Package Manager (which installed as part of node):
npm install socket.io node-static ip
It doesn't seem to matter whether you load the modules locally or global.
4. THE TWO WEBSERVER FILES: server.js and index.html. Get them from github.
https://github.com/BLavery/PiGyro
The zip file lower right is easiest. unzip into your folder.
5. START WEBSERVER: On the Pi, start webserver. Run in a terminal:
- node server.js
It will tell you the Pi's IP address.
6. PHONE: Start browser. Set address to the Raspberry Pi address on your network, at "port 8080". Eg:
http://192.168.1.14:8080
Press OK to start.
That's it!
Move the phone. Changing sensor figures should print on the Pi.
Concept credit:
https://github.com/shaunuk/picar
Other ref:
http://www.w3.org/TR/orientation-event/