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.
Related
I have an Android application to detect Eddystone beacons using the Android Beacon Library. I would like to test the battery consumption caused by the application to find the optimal background and foreground scan rates. In Settings > Apps > MyBeaconDetectorApp, it shows 0% battery usage after having the bluetooth On for more than an hour. I think the application is in background and hence it is 0%. However, how do I check the battery consumption caused by Bluetooth scans. I have set my BackgroundBetweenScanPeriod as 1 minute.
Thanks
While it is difficult to measure the battery consumption directly, here is the technique I use:
Use a test device with a limited number of apps installed that will be running in the background. A stock Nexus device after factory reset is ideal.
Charge the battery to 100%
Put the device into airplane mode and put bluetooth on.
Install your app start it running in the background. Turn off the screen, and disconnect the device's USB connector.
Note the start time.
Let the app run in the background for at least 8 hours, ideally in the presence of at least one beacon.
Measure the battery level. The delta from 100% is the percentage drain. Note this number and the end time.
Look up how many mAH your battery has for your phone model. Multiply the percentage drain by the mAH and divide by the time of the test in hours. This tells you how many mA the phone uses when running your app.
Next, uninstall your app, and repeat the procedure above. This will give you a baseline battery drain for your device without your app running.
Finally, subtract the mAH baseline from the mAH with your app running to measure the additional mAH used by your app.
One final note: if you are really scanning every minute in the background (the default is every five minutes to save battery), I would expect this may cause a significant additional battery drain. Testing using the procedure above will tell you for sure. I'd love to hear your results!
Android 4.3 added new 'software' feature that keeps Wifi get scan results even if Wifi is off. It says that this mode consumes very low power.
My question is how this technically done, and how much power saved compared to just enabling Wifi?
The logic is simple: driver and wpa_supplicant is never unloaded from the memory, unless scan-only mode is disabled in WiFi advanced menu via Scanning always available option.
In terms of power consumption - the numbers will differ for every WiFi solution, but according to my experience (being an WiFi engineer for one of the Android OEM's for last 4 years), the difference is minor. Below is an example of some average consumption numbers:
Phone is awake, WiFi disabled: ~220mA (depends on many factors, just an example)
Phone sleeps, WiFi disabled: ~5mA
Phone sleeps, WiFi enabled (sure, applies to Scan-Only mode as well): +5mA
So, if you are an active user, turning Scan-Only off will not give you huge power savings. On the other hand, if the phone usage is somewhat passive, turning this option off could give some extra battery life.
Personally, I keep this option on, since I prefer immediate WiFi availability when I enable it over that minor battery win.
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.
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.
I would like create a service to do something when some "hot situation" occurs, and by "hot situation" I mean the following:
the GPS/cell coordinates are in a known zone
a known Bluetooth device is detected
a known Wi-Fi network is detected
weather info has changed
considerable change in acceleration of device detected: eg. from walking to travel by car.
As one can see, these tasks are "heavy" and will be run frequently – say, 15 minutes, but sometimes even more – when I have to detect the acceleration of the device.
The question I have is this: will this service drain the battery heavily?
If so, what recommendations do you have to minimize battery drain from the tasks described above?
This might be of interest to you:
Coding for battery life
GPS is the top battery drainer - by having it on all the time, the battery duration will probably be cut down to half. Wireless connection is also quite a big drainer. If your app is working via the cell network, then if the phone is connecting to 3G then that probably drains as quickly as wireless connection anyway (maybe even more)...
I would suggest rethinking the usage of your service. Maybe make it into an app and have the user explicitly turning it on when he thinks to be in a "hot situation". Leave it as a service and the user might start thinking of your app as some sort of malfunctioning program and that will hurt severely your downloads/sales.
Also, to keep track of your apps battery usage, you can visit the "Battery usage panel" that lives inside Android preferences.