Composite Android sensor not present despite what documentation says - android

I am using a old phone running android 4.0.4 that has the following sensors (printed by using TYPE_ALL in android studio):
Accelerometer Sensor
Magnetic Field Sensor
Proximity Sensor
Orientation Sensor
According to the android documentation on composite sensors this phone should be able to output linear acceleration, however when i ask for it, only null is returned. Other simple sensors such as accelerometer or magnetometer work fine (the basic sensors that are fused to obtain linear acceleration).
The code so far is pretty basic, it's just printing values.
Any idea why this happen? is this standard behavior? Are not all available sensors to a smartphone supposed to be implemented?

The sensors that are specified as hardware/software behave differently according to the sensors available. If https://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-identify says software, it is the developer responsibility to use the android API to fuse the right basic signals into the composite signal you are looking for.

Related

Can I use TYPE_LINEAR_ACCELERATION on all phones?

I'm developing an app that measures car's accelerations.
Instead of using the accelerometer, I have read about linear accelerometer and implemented it.
I have two devices to test, It's working fine on a Sony Xperia Z1 but I don't get any value on a old Alcatel onetouch.
Is it because of its android version (5.1 vs 4.2), because my code is wrong or is it a hardware limitation?
Taken from Android's documentation:
TYPE_LINEAR_ACCELERATION
Added in API level 9
int TYPE_LINEAR_ACCELERATION
A constant describing a linear acceleration sensor type.
See SensorEvent.values for more details.
Constant Value: 10 (0x0000000a)
This means it should work on any device post API 9
Please take in consideration Lork's response in this post. It states which type of sensor you should use in order to measure certain types of movements.
Update: I'll add the information of Lork's response as it might help future readers:
TYPE_ACCELEROMETER uses the accelerometer and only the accelerometer. It returns raw accelerometer events, with minimal or no processing at all.
TYPE_GYROSCOPE (if present) uses the gyroscope and only the gyroscope. Like above, it returns raw events (angular speed un rad/s) with no processing at all (no offset / scale compensation).
TYPE_ORIENTATION is deprecated. It returns the orientation as yaw/ pitch/roll in degres. It's not very well defined and can only be relied upon when the device has no "roll". This sensor uses a combination of the accelerometer and the magnetometer. Marginally better results can be obtained using SensorManager's helpers. This sensor is heavily "processed".
TYPE_LINEAR_ACCELERATION, TYPE_GRAVITY, TYPE_ROTATION_VECTOR are "fused" sensors which return respectively the linear acceleration, gravity and rotation vector (a quaternion). It is not defined how these are implemented. On some devices they are implemented in h/w, on some devices they use the accelerometer + the magnetometer, on some other devices they use the gyro.
On Nexus S and Xoom, the gyroscope is currently NOT used. They behave as if there was no gyro available, like on Nexus One or Droid. We are planing to improve this situation in a future release.
Currently, the only way to take advantage of the gyro is to use TYPE_GYROSCOPE and integrate the output by hand.
I hope this helps,
Mathias

Galaxy s3 has Temperature sensor?

I am creating a thermometer app in android when I test on Galaxy S3 it shows that
TYPE_AMBIENT_TEMPERATURE NOT Available
TYPE_TEMPERATURE NOT Available
I want to know that Galaxy S3 has above sensors or not? or How I can solve this issue to get temperature ?
As Yohannes said in the comment you can only calculate standard atmospheric temperature which is not useful to for daily use mostly used in aviation.
Here is the temperature estimation vs barometric height. http://home.anadolu.edu.tr/~mcavcar/common/ISAweb.pdf (page 2).
It seems only way to use an external temperature sensor with bluetooth or similar stuff and require this sensor in your app promotion.
This is really cool one:
http://www.bee-wi.com/bbw200,us,4,BBW200-A1.cfm
An easy way to check if a sensor exists on a specific target phone is to install an app like AndroSensor. This will list all the available sensors.
I doubt if the underlying sensor is missing you'll be able to do much. You can use a weather service to get the current temperature of the device's location but that won't help with a thermometer.
Not sure if this also applies to the Galaxy S3, but you can try to look for sensors with a type value above TYPE_DEVICE_PRIVATE_BASE. Many phones (for example Nexus 5x and Pixel 3) have one or even multiple sensors that exhibit a temperature reading through this and you usually can tell by the name of the sensor (for example "BMI160 Temperature" or "BMP380 Temperature", both on a Pixel 3).
These "vendor defined sensors" are usually from sensors that require a temperature reading for compensation/calibration (BMI160 is the IMU and BMP380 the barometer of the Pixel 3). Especially barometers are very likely to have a temperature channel.
However, there is a good reason that the manufacturer does not offer these temperature readings through the official TYPE_AMBIENT_TEMPERATURE type:
Placing a thermometer inside an enclosed device that heats itself from the inside is not a good method to measure the ambient temperature. Especially if the temperature reading is only meant to compensate temperature drift of the sensor, you will not get anything useful as you mostly measure the temperature of the inside of your phone. Even if a phone officially measures ambient temperature, the results will not be very precise for the same reasons.

Sensor.TYPE_ROTATION_VECTOR returns null

When I call SensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR)on my device it returns null. I know this is a virtual sensor (doing some clever maths to take values from real sensors). I it returns null because my device does not have one of the hardware sensors needed for the ROTATION_VECTOR to work.
So my questions are:
what hardware sensors are required to make the ROTATION_VECTOR work
what physical devices do this (i.e. if I was buying a tablet today and wanted rotation vector sensor to work, what deveice would I need to buy)?
what options do I have to work out the devices orientation without the ROTATION_VECTOR sensor?
Edit: We spoke to Samsung about this and decided that the gyro sensor in the tablet was broken and that was why we were getting null back as the rotation_vector sensor.
If you read documentation about how coordinates are defined for this sensor (find section Sensor.TYPE_ROTATION_VECTOR:), then required hardware is obvious: accelerometer and magnetometer. Gyroscope also may be used to get more stable result (I've got somewhere link with description how this sensor work but can't find it).

Accelerometer Sensor

I am a newbie in android.
Just wondered how gyroscope works in android . Is it any hardware that is mounted inside or what exactly it is ?
Also, would like to know if gyroscope and accelerometer sensor are in anyway related ??
Thanks in advance !!
As for your first question, Google "gyro MEMS". For example, you will find An Overview of MEMS Inertial Sensing Technology.
Your second question is answered here.
Gyroscopes is the device which measures the rate(angular speed) change and Accelerometer measure the change in speed in x,y and z directions.
These devices has internal mechanism(made up of capacitors,filters, ADC components and an interface(I2c, spi)) to carry these analog outputs to digital world where they are interpreted by the software(sensor fusion libraries).
In the device (phone or tablet) they may or may not be present as a separate module(chip) but sure they are connected to the MCU of the Phone either directly or Via some target MCU(to which they are connected via interface like I2C or SPI).
No Gyroscopes and Accelerometers are not related in any way but their data when combined together on the basis of certain algorithms(of what sensor fusion libraries are made up of) gives the orientation of the the device and may help to flip the screen owing to their output.
-Rp

Android get Sensor values from sensor

is there a way to root my Android phone and get sensorinformation direct from the sensor or system?
LG marcel
I don't really know what you mean by getting the information in a "direct" way.
There are two types of sensors in the android sdk: sensors representing an actual hardware sensor (e.g Sensor.TYPE_ACCELEROMETER) and virtual sensors like Sensor.TYPE_LINEAR_ACCELERATION which values are calculated based on the data of one or more sensors. Using the sensor types which represent real hardware allows you to read the data delivered from the sensor The problem with all kind of sensors in smartphones today is that there might be some kind of preprocessing (e.g lowpass filtering) involved and there is little documentation on where and how this is done as there is often no information on which sensor is used the device. I recommend reading this article on android sensors.
Hope this helps...
In android, you have the SensorManager class which give you the possibility to work with your sensors on the device (except the GPS and the camera sensor).
To understand how it works, see this:
http://developer.android.com/reference/android/hardware/SensorManager.html
If you have questions abaut this, feel fre to post them.

Categories

Resources