Smartphone as a lab full of sensors
This page is a starting point for using the sensors of a smartphone as an external (wireless) device to the computer. Prototyping with the smartphone can be quick-and-dirty and does not involve fiddling with cables and electronic components.
This page will get you started with the Android/iPhone app ZIG SIM and a few example boilerplate files using processing, Unity, Max/MSP and TouchDesigner.
In these examples, ZIG SIM will send the data using OSC from the gravity sensor (orientation) to the computer.
- Install ZIG SIM on your phone.
- Make sure phone and computer are on the same network.
Some networks (like Eduroam) will not allow the UDP protocol and/or the opening of specific ports, so you have to create your own hotspot instead.
- Note down the computer's IP address.
- In ZIG SIM go to the Settings page and make sure the settings are as followed:
ZIG SIM Settings DATA DESTINATION OTHER APP PROTOCOL UDP IP ADDRESS your IP address PORT NUMBER 8000 MESSAGE FORMAT OSC MESSAGE RATE(PER SEC) 30 DEVICE UUID 1 COMPASS ANGLE PORTRAIT
Boilerplate: sending gravity data from your phone to your computer
Send gravity data
- In ZIG SIM, go to the sensor page and select GRAVITY
- Press Start
ZIG SIM is now sending the gravity data to the computer.
Receive gravity data
The following sketches will receive the gravity data, display the three numbers as bars and change the colour of a cube:
- Receiving data in processing
- Receiving data in Unity
- Receiving data in Max/MSP
- Receiving data in TouchDesigner
Receiving data in processing
- Download and open the processing sketch.
- Make sure the library oscP5 is installed. (Sketch -> Import Library -> Add Library -> oscP5)
- Run the sketch.
Receiving data in Unity
- Download and open the Unity project
- Open the "ZIGSIM_receive_gravity" scene
- Press play
If you select the OSC_communication object, you will also see your computer's IP address under IP_Finder and the currently received gravity data under OSC_Message parser.
Receiving data in Max/MSP
- Download and open the Max/MSP patch
Receiving data in TouchDesigner
- Download and open the TouchDesigner file
Down the rabbit hole
Other phone apps for sending / receiving OSC data:
Receiving OSC data is not only limited to these boilerplate examples. Most programming languages contain an implementation of OSC. Think of Arduino, node.js, python, etc..