SlideShare a Scribd company logo
ANDROID SENSOR SYSTEM
Outline
• Sensors in Android
• SW
• Android sensor framework and implementation

• HW
• 3-axis e-compass hardware introduction

2
Sensors in Android
• Example
• Hardware
• STMicro LSM303DLHC 3-axis e-compass module
• 3-axis G-sensor (m/s2) and 3-axis M-sensor (gauss)
• 3-axis e-compass
• Using G/M-sensor data to compute heading

• Software
• Android 4.0

3
Software Architecture
Java Program

Android Framework

Sensor Library

Linux Driver
4
Java App on Android
• Android support several sensor types and provide unified
interface to control them.
• In android 4.0, there are 13 data types.
• G-sensor, M-sensor, Gyro-sensor, Light sensor, …

• Android defines several rules for app programmer
• Data polling rate
• SENSOR_DELAY_FASTEST
• SENSOR_DELAY_GAME
• SENSOR_DELAY_UI
• SENSOR_DELAY_NORMAL
• 3-axis dimension
• etc.

( 0 ms)
( 20 ms)
( 60 ms)
( 200 ms)

5
Java Program
• Classes and interface of android sensor framework
• Sensor class
• Instance of a specific sensor
• Get sensor’s capabilities

• SensorEvent class
• Instance of sensor event
• Get raw data

• SensorManager class
• Instance of sensor service
• Register/unregister, access, acquire orientation, …

• SensorEventListener interface
• Monitor sensor value/accuracy changed event
6
Sensors in Android
Framework
• Sensors in android framework
• User registers/unregisters listener for accessing sensor service
• User proposes the need for data exporting
• which sensor and data rate

• User could only get
• Static
•

Features of sensors

• Dynamic
•
•

raw data
processed information by android (eg. orientation, …)

7
Sensor Library in Android
• Sensor library provides necessary callback functions for
android to control sensors.
• Sensor manager in android framework
• Manages sensor resource for java apps
• Passes control commands and dispatches data

• In sensor library, we could implement extra features in Linux
user-space.
• Eg 1. orientation fixing
• Eg 2. For cost-down, we may use cheap sensor module. However, we
could develop some algorithm to improve its performance.

8
Callback Functions in Sensor
Library
• Callback functions should be implemented
• Open data source
• Initial the sensor library

• Close data source

Enter/Exit Sensor Library

• Exit the sensor library

• Activate
• Start/Stop sensor

• Set delay

Sensor State Setting

• Set the time interval of sensing

• Poll
• Poll all the sensors to get data

• Wake
• Stop sensor polling compulsively

Run-time Data Retrieving

9
Sensor Data Packet
• sensors_event_t structure
•
•
•
•

sensor type
timestamp
reserved
union {

}

float data[16];
sensors_vec_t acceleration; /* (m/s^2) */
sensors_vec_t magnetic; /* micro-Tesla (uT) */
sensors_vec_t orientation; /* degrees */
sensors_vec_t gyro; /* rad/s */
float temperature; /* Celsius */
float distance; /* centimeters */
float light; /* lux */
float pressure; /* hPa */
float relative_humidity; /* percent */
sensors_vec_t : union of (x,y,z), (azimuth, roll, pitch)

10
LSM303DLHC 3-axis ECompass
• Control hardware module and get data with I2C bus.
• G-sensor
• Two interrupt line for special situation
• Output data rate
• Output data range

• M-sensor
• Output data rate
• Output data range
• Enable/disable temperature exporting

11
Heading Computation

Xb

Yb
Zb

G-sensor

M-sensor

12
3-axis E-Compass Calibration
3-axis e-compass may not get right azimuth data
◦ Misalignment
◦ Magnetometer
 Hard-iron distortion
 It is a constant additive value to the output of each of the
magnetometer axes.
 Soft-iron distortion
 Soft-iron distortion cannot be compensated with a simple constant;
instead, a more complicated procedure is required.

Calibration sequence is related to hardware
13
Calibration for LSM303DLHC
• Accelerometer
• All ST MEMS accelerometers are factory calibrated, allowing the
user to avoid any further calibration for most of the applications
now present in the market.
• Calibration Matrix :

cal data

raw data

14

More Related Content

PPTX
Android Sensor and Framework - AWARE
PPTX
Peno sensor
PDF
Sensors on android
PPTX
Android Sensor
PPTX
Android Training (Sensors)
PDF
Android Sensors
PDF
Sensors and location based services
PPSX
Sensor's inside
Android Sensor and Framework - AWARE
Peno sensor
Sensors on android
Android Sensor
Android Training (Sensors)
Android Sensors
Sensors and location based services
Sensor's inside

What's hot (10)

ODP
Android sensors
PPT
Smartphone sensor and gesture
PPTX
Mebin progress
PPT
Fire fighting robot using 8051 microcontroller
PPTX
Motion sensing and detection
PPT
Sensing Mobile Devices talk from QCon London 2013
DOCX
Syn ankit
PPTX
Missile detection and automatic destroy system
PPTX
Plant Conditioner - Humidity, Light intensity,& Temperature measurement tools
PPTX
Phys204 class project_final_b_cooper
Android sensors
Smartphone sensor and gesture
Mebin progress
Fire fighting robot using 8051 microcontroller
Motion sensing and detection
Sensing Mobile Devices talk from QCon London 2013
Syn ankit
Missile detection and automatic destroy system
Plant Conditioner - Humidity, Light intensity,& Temperature measurement tools
Phys204 class project_final_b_cooper
Ad

Viewers also liked (20)

PPTX
Android - Sensor Manager
PDF
Environmental Sensor Network Paper
PDF
Review Paper on Smart Sensor Network for Air Quality Monitoring
PPTX
湘南ミーティングChallenges for Real-time Activity Recognition報告
PPTX
Sensors 9
PDF
Sensor Cloud Infrastructure - Small Survey Report
PDF
Kernel Recipes 2015 - The Dronecode Project – A step in open source drones
PPTX
Android training (android style)
PPTX
Android Training (Broadcast Receiver)
PPTX
Android Training (android fundamental)
PPTX
Android Training (Touch)
PPTX
Android Training (Services)
PPTX
Android Training (ScrollView , Horizontal ScrollView WebView)
PPTX
Android Training (Notifications)
PPT
Spattern matching using biometric techniques
PPT
Chapter 5 ms access-1
PDF
Android internals 09 - Sensors, Power Management, Input subsystem, Data stora...
PDF
Seminar Report on RFID Based Trackin System
PDF
Android HAL Introduction: libhardware and its legacy
Android - Sensor Manager
Environmental Sensor Network Paper
Review Paper on Smart Sensor Network for Air Quality Monitoring
湘南ミーティングChallenges for Real-time Activity Recognition報告
Sensors 9
Sensor Cloud Infrastructure - Small Survey Report
Kernel Recipes 2015 - The Dronecode Project – A step in open source drones
Android training (android style)
Android Training (Broadcast Receiver)
Android Training (android fundamental)
Android Training (Touch)
Android Training (Services)
Android Training (ScrollView , Horizontal ScrollView WebView)
Android Training (Notifications)
Spattern matching using biometric techniques
Chapter 5 ms access-1
Android internals 09 - Sensors, Power Management, Input subsystem, Data stora...
Seminar Report on RFID Based Trackin System
Android HAL Introduction: libhardware and its legacy
Ad

Similar to Android Sensor System (20)

PDF
Week12.pdf
PPTX
Tk2323 lecture 10 sensor
PDF
Android sensor
PPT
iwatchjr | Mobile Handset Sensors Coordinate System
PDF
Introduction to Android G-sensor
DOC
FINISHED_CODE
PDF
MOBILE PHONE SENSORS META-MODEL
PDF
MOBILE PHONE SENSORS META-MODEL
PPTX
Android 1.8 sensor
PDF
Sensors in Android (old)
PPT
Ceng4480 a1
PPTX
Avi Itzkovitch- Designing with sensors
DOCX
Motorized pan tilt(Arduino based)
DOCX
Sensor android
PDF
Generic sensors for the Web
PPT
Ceng4480 a1
PDF
IoT support for .NET Core
PPTX
Base sensor
PPT
Multi Sensory Communication 2/2
PDF
Hello I hope you are doing well Would you be able to combi.pdf
Week12.pdf
Tk2323 lecture 10 sensor
Android sensor
iwatchjr | Mobile Handset Sensors Coordinate System
Introduction to Android G-sensor
FINISHED_CODE
MOBILE PHONE SENSORS META-MODEL
MOBILE PHONE SENSORS META-MODEL
Android 1.8 sensor
Sensors in Android (old)
Ceng4480 a1
Avi Itzkovitch- Designing with sensors
Motorized pan tilt(Arduino based)
Sensor android
Generic sensors for the Web
Ceng4480 a1
IoT support for .NET Core
Base sensor
Multi Sensory Communication 2/2
Hello I hope you are doing well Would you be able to combi.pdf

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Approach and Philosophy of On baking technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Network Security Unit 5.pdf for BCA BBA.
Understanding_Digital_Forensics_Presentation.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Big Data Technologies - Introduction.pptx
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
sap open course for s4hana steps from ECC to s4
Approach and Philosophy of On baking technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Network Security Unit 5.pdf for BCA BBA.

Android Sensor System

  • 2. Outline • Sensors in Android • SW • Android sensor framework and implementation • HW • 3-axis e-compass hardware introduction 2
  • 3. Sensors in Android • Example • Hardware • STMicro LSM303DLHC 3-axis e-compass module • 3-axis G-sensor (m/s2) and 3-axis M-sensor (gauss) • 3-axis e-compass • Using G/M-sensor data to compute heading • Software • Android 4.0 3
  • 4. Software Architecture Java Program Android Framework Sensor Library Linux Driver 4
  • 5. Java App on Android • Android support several sensor types and provide unified interface to control them. • In android 4.0, there are 13 data types. • G-sensor, M-sensor, Gyro-sensor, Light sensor, … • Android defines several rules for app programmer • Data polling rate • SENSOR_DELAY_FASTEST • SENSOR_DELAY_GAME • SENSOR_DELAY_UI • SENSOR_DELAY_NORMAL • 3-axis dimension • etc. ( 0 ms) ( 20 ms) ( 60 ms) ( 200 ms) 5
  • 6. Java Program • Classes and interface of android sensor framework • Sensor class • Instance of a specific sensor • Get sensor’s capabilities • SensorEvent class • Instance of sensor event • Get raw data • SensorManager class • Instance of sensor service • Register/unregister, access, acquire orientation, … • SensorEventListener interface • Monitor sensor value/accuracy changed event 6
  • 7. Sensors in Android Framework • Sensors in android framework • User registers/unregisters listener for accessing sensor service • User proposes the need for data exporting • which sensor and data rate • User could only get • Static • Features of sensors • Dynamic • • raw data processed information by android (eg. orientation, …) 7
  • 8. Sensor Library in Android • Sensor library provides necessary callback functions for android to control sensors. • Sensor manager in android framework • Manages sensor resource for java apps • Passes control commands and dispatches data • In sensor library, we could implement extra features in Linux user-space. • Eg 1. orientation fixing • Eg 2. For cost-down, we may use cheap sensor module. However, we could develop some algorithm to improve its performance. 8
  • 9. Callback Functions in Sensor Library • Callback functions should be implemented • Open data source • Initial the sensor library • Close data source Enter/Exit Sensor Library • Exit the sensor library • Activate • Start/Stop sensor • Set delay Sensor State Setting • Set the time interval of sensing • Poll • Poll all the sensors to get data • Wake • Stop sensor polling compulsively Run-time Data Retrieving 9
  • 10. Sensor Data Packet • sensors_event_t structure • • • • sensor type timestamp reserved union { } float data[16]; sensors_vec_t acceleration; /* (m/s^2) */ sensors_vec_t magnetic; /* micro-Tesla (uT) */ sensors_vec_t orientation; /* degrees */ sensors_vec_t gyro; /* rad/s */ float temperature; /* Celsius */ float distance; /* centimeters */ float light; /* lux */ float pressure; /* hPa */ float relative_humidity; /* percent */ sensors_vec_t : union of (x,y,z), (azimuth, roll, pitch) 10
  • 11. LSM303DLHC 3-axis ECompass • Control hardware module and get data with I2C bus. • G-sensor • Two interrupt line for special situation • Output data rate • Output data range • M-sensor • Output data rate • Output data range • Enable/disable temperature exporting 11
  • 13. 3-axis E-Compass Calibration 3-axis e-compass may not get right azimuth data ◦ Misalignment ◦ Magnetometer  Hard-iron distortion  It is a constant additive value to the output of each of the magnetometer axes.  Soft-iron distortion  Soft-iron distortion cannot be compensated with a simple constant; instead, a more complicated procedure is required. Calibration sequence is related to hardware 13
  • 14. Calibration for LSM303DLHC • Accelerometer • All ST MEMS accelerometers are factory calibrated, allowing the user to avoid any further calibration for most of the applications now present in the market. • Calibration Matrix : cal data raw data 14