Read power input from usb - android

Is there any way to read the power input from a USB connection in Android?
For example plug in a micro usb lead into the phone from either a computer USB output, a mains charger, or something similar and read the voltage and amp output?
I have no idea where to start looking for this information, and when searching I can only find battery widgets, or power consumption apps - this is not what I'm looking for, I want to be able to read how much power is being sent via the USB interface that is connected.
Many thanks.

Probably, You should start with BatteryManager , refer to this question for some examples of usage. I believe the data provided by BatteryManager should be enough to provide approximate calculation of what You want to (how much power is being sent via the USB). Having device id and table of devices default batteries capacities or/and users input about capacity and % difference with time interval and voltage probably would give enough info for approximate calculation of consumption
Another (dirty) way might be the following - dig android sources if ones have any info about total capacity / consumption You can obtain e.g. with java reflection. I think BatteryManager and BatteryStatsImpl could be appropriate places to start analysis from.

Related

Android: How to obtain individual data usage counters?

The challenge at hand is how to obtain accurate data counters for each Network Interface.
The class TrafficStats offer some help with:
TrafficStats.getMobileRxBytes() /* Similar for TX */
TrafficStats.getTotalRxBytes() /* Similar for TX */
From this one can calculate the traffic on the mobile interface.
However I see several posts claiming that:
WIFI usage = Total - Mobil;
That cannot be correct since Total includes -all- of the Network interfaces (i.e. Bluetooth and USB as well as WIFI and Mobile). Thus the WIFI result can be very off its actual correct value using the above calculation.
Can anyone assist or offer assistance on how to accurately analyse each of the NetworkInterfaces?
That cannot be correct since Total includes -all- of the Network interfaces (i.e. Bluetooth and USB as well as WIFI and Mobile).
I am not completely certain how you have determined that Bluetooth and USB are included in TrafficStats.
Can anyone assist or offer assistance on how to accurately analyse each of the NetworkInterfaces?
There is nothing in the Android SDK for anything but what you get from TrafficStats. You are welcome to play around with trying to get the information from Linux, bearing in mind that this may not work on all devices.

Listen for GSM traffic

is it possible to use an android phone to collect IMEIs or unique Phone IDs of phones within the same cell? Probably there is already some hack to use osmocom ... what I am looking for is an easy to work solution to scan traffic (by counting car drivers phones )
Theoretically yes but practically no.
In a normal GSM network you will expect Mobile identity IMEIsv data fields to be encoded in a message called Identity Response.
This message is sent in a encrypted channel called sdcch/8. You need to decrypt (and find) this exact message in that channel to detect the imei of a given uplink transaction.
To be able to catch an uplink data transaction you need to have a radio receiver that is listening on the uplink frequencies and you're android phone does not do that.
You were looking for an easy to work "solution to scan traffic".
What I suggest you do is try to find a phone that will give you information about the CCCH channel this is unencrypted and can contain Paging Requests with tmsi or imsi information. The tmsi is more anonymous and it gives you some kind of statistic for counting.
The "easiest" way to do this (today) is to use Nokia 3310 and the dct3 gsmtap project. Filter the pcap file using options in tshark.
There may be more accurate ways of counting cars.
Well theoretically yes, but the problem here is that you need to know how the radio interface of your android phone works and have a driver for it before you can do that.
As far as I know there are no such drivers for GNU Radio.
The other problem is that the CPU on your mobile phone is not strong enough to handle the amount of data processing needed to perform such task, it may come a day when you have quad core CPUs with lots of RAM and strong DSP support, but I don't think we are there right now.

Android Customize Wifi Scan

I am interested in scanning only a particular set of frequencies for a particular time interval (this is different from scanning interval in android api). Is there any high level api
or
user to kernel space communication interfaces, mechanisms (sysfs,iotctl,mmap etc.) (in a rooted device) that can allow me to specify the set of frequencies to be scanned for a particular interval of time. If I understand correctly the device supplicant carries this information?
Would very much appreciate if anyone can point me in right direction.
Thanks in advance!!
See my answer on android.sx. Basically, install iw on your device and then call:
iw dev wlan0 scan freq 2417
However, I do not know how this interacts with the supplicant/connection manager. We use it to measure RSSI only.

Bluetooth Signal Strength in Android

I wanted to get the RSSI value to measure how far a device is from a handset...the problem I am currently facing is whether the RSSI value keeps on changing even after the devices are paired and also if can the value be directly used as short?
The RSSI value will fluctuate significantly.
It is proportional with distance, but it is affected by interference, and also by the 2 connected devices' power table (they might reduce their tx power if they are close).
That being said, RSSI will still appreciate with devices getting closer.
I preferred logging the RSSI data I receive on my other(embedded) device and sending it back to Android, showing it there. My embedded device has clear access to the Bluetooth stack, and so can get more accurate and more intense readings of the RSSI.
Ofc, getting the RSSI of the other device from Android should also work, but probably not so good (you have too many layers on top of the actual Bluetooth stack - linux bluez, then Android...).
I have my own graphing application for Bluetooth RSSI monitoring in Android, here are 2 printscreens from my app:
You can also look at Link Quality...this is another useful parameter(it it susceptible to duplications of the signal).
Here is a scientific paper on the subject.

Android Hardware Battery temperature, where is the sensor?

I have a stupid idea. With android is simple to get battery state (volt, charge, temperature, ecc).
BatteryManager.EXTRA_TEMPERATURE
I think that the sensor is located inside lithium battery pack, in fact there are 3 pins over it connecting to the phone. Maybe that one of them is the battery sensor temperature. How it works? It's possible, but i know that damage may be relevant, isolate that pin and connect the phone pin to an external sensor?
So we can catch outside temperature using battery manager....without using Google IOIO or Arduino just for reading a temperature.
THAT'S ONLY FOR STUDY INFORMATION! PLEASE DON'T TALK ABOUT DANGER OF LITHIUM BATTERIES...
Thanx a lot!
In theory, yes, but the battery temperature is critical in the charge/discharge cycle of the phone. Phone batteries charge by applying a constant current to the battery. When the phone is charging the battery temp will rise (a byproduct of mixing electricity with chemicals). If it rises too far, the battery will fail (and could [in theory at least] explode).
Thus the phone's charging circuitry needs to monitor the battery temp so if it rises beyond a given threshold it backs the charging current off until the temperature stablises, ensuring the battery remains within safe limits.
In other words -- if you do override it, do so at your own risk.
Yes, the temperature sensor is located inside the battery pack. The standard setup is a 103 NTC (negative temperature coefficient) thermistor to ground. The 103 means that is has a 10K resistance at 25C.
Yes, you can measure ambient temperature using this. It may read higher if the battery is either charging or discharging (as the battery will get warm). It will respond fairly slowly to environmental changes due to the isolation and thermal mass of the battery.

Categories

Resources