Chapter 10 — Your Phone as a Sensor: PhyPhox and Python
Before buying a single sensor, you have a sensor array in your pocket.
A modern smartphone contains an accelerometer, gyroscope, barometer, magnetometer, GPS, microphone, and light sensor. PhyPhox (Physical Phone Experiments) is an Android and iOS app that exposes all of these sensors over a local HTTP API.
The PhyPhox API
PhyPhox runs a local web server on your phone. When connected to the same WiFi network as your computer or Raspberry Pi, you can query sensor data programmatically:
import requests
import time
PHYPHOX_IP = "192.168.1.50" # your phone's IP
while True:
resp = requests.get(f"http://{PHYPHOX_IP}/get?accX&accY&accZ")
data = resp.json()
ax = data["buffer"]["accX"]["buffer"][0]
ay = data["buffer"]["accY"]["buffer"][0]
az = data["buffer"]["accZ"]["buffer"][0]
print(f"Acceleration: x={ax:.3f} y={ay:.3f} z={az:.3f} m/s²")
time.sleep(0.1)
This gives you 10Hz accelerometer data over WiFi with 10 lines of Python.

Real Applications
Vibration monitoring: mount the phone on a machine (washing machine, HVAC unit, pump). A sharp increase in vibration amplitude indicates a developing fault. A Raspberry Pi logging PhyPhox data every hour can detect the early signs of bearing failure weeks before the machine stops working.
Vehicle dynamics: OBD2 scanners give you engine data, but PhyPhox adds the inertial data — lateral acceleration in corners, braking G-force, ride quality over different road surfaces. Combine the two data streams in Python for a complete picture of what the car and driver are doing.
Pressure altitude logging: the barometer in most smartphones is accurate enough to log altitude changes during a hike or a bike ride, without the battery drain of GPS.

The Limitation
PhyPhox requires the phone to be running and the app to be open. For long-term monitoring, this drains the battery unless the phone is plugged in. For projects where you want continuous unattended logging, a dedicated sensor on a microcontroller is the right tool. PhyPhox is the fastest way to prototype a measurement concept before committing to hardware.
Takeaway: PhyPhox turns your phone into a multi-sensor instrument accessible via HTTP. Use it to prototype measurement ideas before buying dedicated sensors.