Smartphone as a lab full of sensors

From MDD wiki
Jump to navigation Jump to search

About

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.

Prerequisites

  1. Install ZIG SIM on your phone.
  2. 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.
  3. Note down the computer's IP address.
  4. 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

  1. In ZIG SIM, go to the sensor page and select GRAVITY
  2. 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

  1. Download and open the processing sketch.
  2. Make sure the library oscP5 is installed. (Sketch -> Import Library -> Add Library -> oscP5)
  3. Run the sketch.

Receiving data in Unity

  1. Download and open the Unity project
  2. Open the "ZIGSIM_receive_gravity" scene
  3. 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

  1. Download and open the Max/MSP patch

Receiving data in TouchDesigner

  1. 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..