%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#ECF0F1'}}}%%
mindmap
root((Participatory<br/>Sensing<br/>Applications))
Environmental Monitoring
Air Quality
PM2.5 particles
Pollution hotspots
City-wide mapping
Noise Pollution
Decibel levels
Complaint verification
Urban noise maps
Weather Data
Temperature
Humidity
Crowdsourced forecasts
Transportation
Traffic Monitoring
Real-time congestion
Route optimization
Accident detection
Road Conditions
Pothole detection
Surface quality
Maintenance alerts
Parking Availability
Empty spots
Duration estimates
Smart parking apps
Public Safety
Emergency Response
Earthquake early warning
Flood detection
Crowd density monitoring
Crime Mapping
Incident reports
Safety ratings
Community alerts
Health and Wellness
Disease Tracking
COVID contact tracing
Symptom reporting
Outbreak prediction
Activity Monitoring
Step counting
Exercise patterns
Public health insights
Infrastructure
Wi-Fi Mapping
Coverage gaps
Signal strength
Network quality
Cell Tower Monitoring
Service quality
Dead zones
5G deployment
582 Mobile Phone Sensors: Participatory Sensing and Privacy
582.1 Participatory Sensing Applications
Participatory sensing (also called crowdsensing) leverages smartphones carried by users to collect data at scale.
582.1.1 Use Cases
{fig-alt=βMobile sensor architecture diagram showing key components and relationships illustrating smartphone sensor types (accelerometer, gyroscope, GPS, camera), sensor fusion algorithms, data collection methods, or mobile sensing applications in IoT ecosystems.β}
582.1.2 Sensor Fusion Pipeline
Mobile applications often combine data from multiple sensors to improve accuracy and enable sophisticated features. This sensor fusion workflow shows how raw sensor data is processed into actionable insights:
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#ECF0F1'}}}%%
flowchart TB
subgraph RAW[Raw Sensor Input]
GPS[GPS<br/>Lat/Lon<br/>5-10m accuracy]
ACCEL[Accelerometer<br/>3-axis motion<br/>50-200 Hz]
GYRO[Gyroscope<br/>Angular velocity<br/>Rotation]
MAG[Magnetometer<br/>Compass heading<br/>North direction]
BARO[Barometer<br/>Air pressure<br/>Altitude]
CAM[Camera<br/>Visual data<br/>QR, AR, ML]
end
subgraph PREPROCESS[Preprocessing]
CAL[Calibration<br/>Zero offset<br/>Scale adjustment]
FILTER[Filtering<br/>Noise reduction<br/>Smoothing]
TRANSFORM[Coordinate Transform<br/>Reference frames<br/>Unit conversion]
SYNC[Time Synchronization<br/>Align timestamps<br/>Match sampling rates]
end
subgraph FUSION[Sensor Fusion]
KALMAN[Kalman Filter<br/>Optimal state estimation<br/>Prediction + Update]
COMP[Complementary Filter<br/>High + Low freq merge<br/>Gyro + Accel]
PARTICLE[Particle Filter<br/>Non-linear fusion<br/>Multiple hypotheses]
ML[ML Models<br/>Neural networks<br/>Pattern learning]
end
subgraph OUTPUT[Fused Output]
LOC[Precise Location<br/>GPS + Wi-Fi + Beacons<br/>1-5m accuracy]
ACT[Activity Type<br/>Walking, Running<br/>Driving, Stationary]
ORIENT[3D Orientation<br/>Roll, Pitch, Yaw<br/>AR tracking]
CONTEXT[Context Awareness<br/>Indoor/Outdoor<br/>Floor level]
EVENT[Event Detection<br/>Fall detection<br/>Gesture recognition]
end
subgraph ACTION[Application Action]
ALERT[Alerts & Notifications<br/>Geofence entry<br/>Emergency call]
UPLOAD[Cloud Upload<br/>Data transmission<br/>Analytics backend]
VIZ[Real-time Visualization<br/>Maps, Graphs<br/>Dashboard]
STORE[Local Storage<br/>Offline caching<br/>History logging]
end
GPS --> CAL
ACCEL --> CAL
GYRO --> CAL
MAG --> CAL
BARO --> CAL
CAM --> CAL
CAL --> FILTER
FILTER --> TRANSFORM
TRANSFORM --> SYNC
SYNC --> KALMAN
SYNC --> COMP
SYNC --> PARTICLE
SYNC --> ML
KALMAN --> LOC
COMP --> ORIENT
PARTICLE --> ACT
ML --> CONTEXT
ML --> EVENT
LOC --> ALERT
ACT --> UPLOAD
ORIENT --> VIZ
CONTEXT --> STORE
EVENT --> ALERT
style RAW fill:#E67E22,stroke:#2C3E50,color:#fff
style PREPROCESS fill:#16A085,stroke:#2C3E50,color:#fff
style FUSION fill:#2C3E50,stroke:#16A085,color:#fff
style OUTPUT fill:#E67E22,stroke:#2C3E50,color:#fff
style ACTION fill:#16A085,stroke:#2C3E50,color:#fff
{fig-alt=βMobile sensor architecture diagram showing Raw Sensor Input, GPS Lat/Lon 5-10m accuracy, Accelerometer 3-axis motion 50-200 Hz illustrating smartphone sensor types (accelerometer, gyroscope, GPS, camera), sensor fusion algorithms, data collection methods, or mobile sensing applications in IoT ecosystems.β}
Sensor fusion workflow for mobile sensing applications showing the complete pipeline from raw sensor inputs to application actions. The Raw Sensor Input stage collects data from GPS (latitude/longitude with 5-10m accuracy), accelerometer (3-axis motion at 50-200 Hz), gyroscope (angular velocity and rotation), magnetometer (compass heading), barometer (air pressure for altitude), and camera (visual data for QR codes, AR, and machine learning). The Preprocessing stage applies calibration for zero offset and scale adjustment, filtering for noise reduction, coordinate transformations between reference frames, and time synchronization to align timestamps and match sampling rates. The Sensor Fusion stage employs four techniques: Kalman Filter for optimal state estimation with prediction and update steps, Complementary Filter for merging high and low frequency components, Particle Filter for non-linear fusion with multiple hypotheses, and ML Models using neural networks for pattern learning. The Fused Output stage produces precise location (combining GPS, Wi-Fi, and beacons for 1-5m accuracy), activity type classification (walking, running, driving, stationary), 3D orientation (roll, pitch, yaw for AR tracking), context awareness (indoor/outdoor, floor level detection), and event detection (fall detection, gesture recognition). The Application Action stage triggers alerts and notifications including emergency calls, cloud uploads for data transmission to analytics backends, real-time visualizations on dashboards, and local storage for offline caching and history logging.
This fusion pipeline demonstrates how smartphones transform multiple noisy, limited sensor streams into highly accurate, context-aware information for IoT applications like navigation, health monitoring, and participatory sensing campaigns.
582.1.3 Noise Pollution Monitoring App
// Web Audio API for noise level measurement
class NoiseLevelMonitor {
constructor() {
this.audioContext = null;
this.analyser = null;
this.microphone = null;
this.dataArray = null;
}
async start() {
try {
const stream = await navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: false,
noiseSuppression: false,
autoGainControl: false
}
});
this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
this.analyser = this.audioContext.createAnalyser();
this.microphone = this.audioContext.createMediaStreamSource(stream);
this.analyser.fftSize = 2048;
const bufferLength = this.analyser.frequencyBinCount;
this.dataArray = new Uint8Array(bufferLength);
this.microphone.connect(this.analyser);
console.log('Noise monitoring started');
this.measureNoise();
} catch (error) {
console.error('Error accessing microphone:', error);
}
}
measureNoise() {
this.analyser.getByteTimeDomainData(this.dataArray);
// Calculate RMS (Root Mean Square)
let sum = 0;
for (let i = 0; i < this.dataArray.length; i++) {
const normalized = (this.dataArray[i] - 128) / 128;
sum += normalized * normalized;
}
const rms = Math.sqrt(sum / this.dataArray.length);
// Convert to decibels (approximation)
const db = 20 * Math.log10(rms);
// Adjust to typical environmental scale (0-100 dB)
const adjustedDB = Math.max(0, Math.min(100, db + 100));
document.getElementById('noise-level').textContent =
`${adjustedDB.toFixed(1)} dB`;
// Classify noise level
let classification = '';
if (adjustedDB < 40) {
classification = 'Quiet (Library)';
} else if (adjustedDB < 60) {
classification = 'Moderate (Office)';
} else if (adjustedDB < 80) {
classification = 'Loud (Traffic)';
} else {
classification = 'Very Loud (Construction)';
}
document.getElementById('noise-classification').textContent = classification;
// Send to backend if noise exceeds threshold
if (adjustedDB > 70) {
this.reportNoiseViolation(adjustedDB);
}
// Continue measuring
requestAnimationFrame(() => this.measureNoise());
}
async reportNoiseViolation(noiseLevel) {
// Get current location
navigator.geolocation.getCurrentPosition(async (position) => {
const data = {
noiseLevel: noiseLevel,
latitude: position.coords.latitude,
longitude: position.coords.longitude,
timestamp: new Date().toISOString()
};
try {
await fetch('https://noise-monitoring.example.com/api/report', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
console.log('Noise violation reported');
} catch (error) {
console.error('Failed to report:', error);
}
});
}
stop() {
if (this.microphone) {
this.microphone.disconnect();
}
if (this.audioContext) {
this.audioContext.close();
}
}
}
// Usage
const monitor = new NoiseLevelMonitor();
monitor.start();582.2 Privacy and Ethical Considerations
- Informed Consent: Clearly explain what data is collected and how itβs used
- Data Minimization: Collect only necessary data
- Anonymization: Remove personally identifiable information
- Secure Transmission: Use HTTPS/TLS for all data transfers
- Local Processing: Process sensitive data on-device when possible
- User Control: Allow users to start/stop sensing and delete data
- Transparency: Provide access to collected data
- Compliance: Follow GDPR, CCPA, and local regulations
582.2.1 Privacy-Preserving Location Sharing
// Anonymize location before sending
function anonymizeLocation(lat, lon, precision = 3) {
// Round to reduce precision (3 decimal places β 111m accuracy)
return {
latitude: parseFloat(lat.toFixed(precision)),
longitude: parseFloat(lon.toFixed(precision))
};
}
// Differential privacy - add controlled noise
function addDifferentialPrivacy(value, epsilon = 0.1) {
// Laplace noise
const scale = 1 / epsilon;
const u = Math.random() - 0.5;
const noise = -scale * Math.sign(u) * Math.log(1 - 2 * Math.abs(u));
return value + noise;
}
// Privacy-aware data collection
async function collectPrivateLocationData() {
navigator.geolocation.getCurrentPosition(async (position) => {
// Original location
const lat = position.coords.latitude;
const lon = position.coords.longitude;
// Apply privacy protection
const anonLocation = anonymizeLocation(lat, lon, 2); // ~1km precision
const privateLat = addDifferentialPrivacy(anonLocation.latitude);
const privateLon = addDifferentialPrivacy(anonLocation.longitude);
// Remove timestamp precision (round to nearest hour)
const timestamp = new Date();
timestamp.setMinutes(0, 0, 0);
const data = {
latitude: privateLat,
longitude: privateLon,
timestamp: timestamp.toISOString(),
// No device ID or user information
};
await sendAnonymousData(data);
});
}582.3 Battery Optimization
- Adaptive Sampling: Reduce sensor frequency when stationary
- Batch Updates: Send data in batches, not continuously
- Wi-Fi Preferred: Use Wi-Fi over cellular when available
- Background Restrictions: Limit background sensing
- Sleep Mode: Use device sleep APIs
- Sensor Fusion: Use lower-power sensors when possible (accelerometer vs GPS)
// Adaptive GPS sampling based on motion
class AdaptiveGPSTracker {
constructor() {
this.isMoving = false;
this.highFrequency = 5000; // 5 seconds when moving
this.lowFrequency = 60000; // 60 seconds when stationary
this.currentInterval = this.lowFrequency;
this.accelerometer = null;
}
async start() {
// Monitor motion with accelerometer (low power)
if ('Accelerometer' in window) {
this.accelerometer = new Accelerometer({ frequency: 5 }); // 5 Hz
this.accelerometer.addEventListener('reading', () => {
const magnitude = Math.sqrt(
this.accelerometer.x ** 2 +
this.accelerometer.y ** 2 +
this.accelerometer.z ** 2
);
// Detect motion
const wasMoving = this.isMoving;
this.isMoving = Math.abs(magnitude - 9.8) > 1.0; // Threshold
// Adapt GPS sampling rate
if (this.isMoving && !wasMoving) {
console.log('Motion detected - increasing GPS frequency');
this.currentInterval = this.highFrequency;
this.restartGPSTracking();
} else if (!this.isMoving && wasMoving) {
console.log('Stationary - reducing GPS frequency');
this.currentInterval = this.lowFrequency;
this.restartGPSTracking();
}
});
this.accelerometer.start();
}
// Start GPS tracking
this.startGPSTracking();
}
startGPSTracking() {
this.gpsIntervalId = setInterval(() => {
navigator.geolocation.getCurrentPosition(
(position) => {
console.log('GPS update:', position.coords);
this.sendLocationToServer(position.coords);
},
(error) => console.error('GPS error:', error),
{
enableHighAccuracy: this.isMoving,
timeout: 10000,
maximumAge: this.currentInterval
}
);
}, this.currentInterval);
}
restartGPSTracking() {
clearInterval(this.gpsIntervalId);
this.startGPSTracking();
}
async sendLocationToServer(coords) {
// Batch data to reduce network usage
const batch = JSON.parse(localStorage.getItem('locationBatch') || '[]');
batch.push({
latitude: coords.latitude,
longitude: coords.longitude,
timestamp: new Date().toISOString()
});
// Send batch every 10 readings
if (batch.length >= 10) {
try {
await fetch('https://iot-backend.example.com/api/location-batch', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(batch)
});
localStorage.setItem('locationBatch', '[]');
} catch (error) {
console.error('Failed to send batch:', error);
localStorage.setItem('locationBatch', JSON.stringify(batch));
}
} else {
localStorage.setItem('locationBatch', JSON.stringify(batch));
}
}
stop() {
if (this.accelerometer) this.accelerometer.stop();
if (this.gpsIntervalId) clearInterval(this.gpsIntervalId);
}
}
// Usage
const tracker = new AdaptiveGPSTracker();
tracker.start();582.4 Whatβs Next
Now that you understand participatory sensing, privacy, and battery optimization, continue to:
- Mobile Phone Labs: Practice building mobile sensing applications with hands-on exercises and assessments
Previous: Mobile Phone APIs | Return to: Mobile Phone as a Sensor Overview