Automatic Ipad Charger

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
u01pei

Automatic Ipad Charger

Post by u01pei »

Since a few years I have an Ipad mini mounted on living room wall in order to control domoticz.
The Ipad charger is connected to a zwave switch, controlled by a timer. This timer would switch on the charger every night. Since the Ipad is dedicated for domoticz, it doesn’t use much power, which made the charging every night pretty obsolete. And thus the wish for Ipad battery level depended switching was born.
I searched the internet several times for a way to export the Ipad battery level to the raspberry pi several times, but without any knowledge of iOS apps there only appeared to be a way trough jailbreaking the Ipad. Unfortunately I could not do this, because my version of iOS was not able to be jailbroken. So I decided to wait until my version (iOS 8.3) could be jailbroken.
Last week I checked again and installed a jailbreak for the Ipad.
Below are the steps I performed to achieve automatic charging:

- This is the jailbreak I used. http://www.taig.com/en/tutorial.html
- UNCHECK the “3K assistance” checkbox
- My Ipad restarted several times, without any progress showing. Please be patient.
- Once jailbroken, use the search option in Cydia to find and install:
- iOS terminal
- bash server
- APT 0.6 Transitional
- APT 0.7 Strict

iOS terminal ensures you can make a SSH connection between your Pi and Ipad. The standard username is root, password alpine.

- create a trusted SSH key, so the script below can use SSH without a password. I used these instructions: http://sshmenu.sourceforge.net/articles/key-setup.html
- create a .txt file on your pi. this will be used to temporarily store data from the Ipad.
- Make sure the file has the correct user access level (chmod 777)
- Note the path and name of this file.
- create a dummy switch in domoticz. Select “percentage” for type.
- Note the IDX
- create a script with the following code:

Code: Select all

#!/bin/bash

SERVER="IP:PORT"        # Your Domoticz IP and Port
IPAD="IP"               # Your Ipad IP
BATIDX="IDX"            # Your IDX-number for the dummy switch you created
correction="0"          # Correction value IF needed. negative value for substraction is allowed
TMPFILE="FILE"          # Your Temp file location (e.g. /home/pi/filename.txt
ssh root@$IPAD "pmset -g ps" > $TMPFILE 
batlevel=$(cat $TMPFILE |awk 'NR==2{print $2}' |tr -d '%' |tr -d ';')
echo "Retrieved Value = $batlevel %"
correctedlevel=$(awk "BEGIN {print $batlevel+$correction; exit}")
echo "Corrected Value = $correctedlevel %"
curl -s "http://$SERVER/json.htm?type=command&param=udevice&idx=$BATIDX&nvalue=0&svalue=$correctedlevel"
- make sure the script is executable (chmod +x) and accessible (chmod 777)
- create a rule for execution of the script with the interval of your choice (crontab -e)
- Test the script (./scriptname from your script folder)

If everything is ok, the domoticz dummy switch is now updated. if the level is not the same is shown on your Ipad screen, you can enter a correction value for it in the script.

I chose not to use a script for linking the battery level to the charger switch. I used the domoticz event system for the time being.
Feel free to create a script for this or adjust mine to your needs.

Also, for Mac users:
The command used in the script to retrieve battery status (pmset -g ps) also works from the terminal window on your mac. I think you could use the same script to charge your mac.

If you run into trouble, leave a comment, me or somebody else might be able to help.
I know there are millions of ways of achieving the same result. this option works fine for me, so please don't comment on things I messed up, create your own solution ;)

Thanks to JacquesMulders. Without him the script would have taken much longer to make. ;)
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Automatic Ipad Charger

Post by ThinkPad »

I'm sorry, not meant to be rude: but you know that you can just leave the iPad connected to the charger 24/7 ? If the battery is full it will stop charging...

The iPads in the Apple Stores are also connected to power 24/7, no problem. By leaving it running on battery and then charging it again you are wearnig out the battery quickly. Leaving it connected to the charger is much better for the battery, as it isn't even used, all the needed power is grabbed directly from the charger, the battery is bypassed.

So it seems to me you made a solution for a problem that doesn't exist :oops:
I am not active on this forum anymore.
u01pei

Re: Automatic Ipad Charger

Post by u01pei »

Hello Thinkpad,

I was not aware of this, but my motivation is more of the kind that every charger uses a slight amount of power, even if it is not charging anything (just plugged in). And besides that: I think it is fun to create things like this... Just because it can be done!
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Automatic Ipad Charger

Post by ThinkPad »

I think the amount of power needed to feed the iPad 24/7 is much less than when it is charging, it needs more power then.
So it sounds a little useless to me to use such an expensive Z-Wave plug for :mrgreen: . Especially because in this case it also has negative impact on the device (battery will wear out sooner).

You're free to create what you want, but in this case i wouldn't do it, to save the battery of the iPad.
I am not active on this forum anymore.
lrybak
Posts: 40
Joined: Thursday 18 December 2014 20:12
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Poland
Contact:

Re: Automatic Ipad Charger

Post by lrybak »

Hi,

I fully agree with ThinkPad. My wall-mounted Samsung Tab is powered 24/7. And as far as I know once battery is fully charged device bypass batery and use power from charger itself.

You can proof it by measure power usage but as I suppose costs will be similar in both scenarios.

So, keep things as simple as possible :-)
HW: HP dc7900 USD running ESXi, RaspberryPi (few of it), AEON S2 USB stick, Fibaro modules (Dimmers, switches), 1-wire (DS18B20, DS2423), DSC Alarm with Envisalink ethernet module, MySensors, RFLink
User avatar
Sine
Posts: 17
Joined: Monday 02 February 2015 15:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Automatic Ipad Charger

Post by Sine »

Yep,

Im with think here, Lion batteries don't like frequent charge/discharge cycles, And in the act of charging you actually lose some energy.

Leaving it plugged in is probbably the best option, the charge controller in the ipad does the rest.
dijkdj
Posts: 63
Joined: Saturday 07 March 2015 22:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Automatic Ipad Charger

Post by dijkdj »

Why is my samsung phone telling me: battery full, please remove charger. That must mean that constantly charging is not ok
Eximos
Posts: 3
Joined: Monday 30 June 2014 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: Automatic Ipad Charger

Post by Eximos »

Of course the phones adjust the charging after the batteries, if not the battery will take damage and the phone will probably catch fire.

A modern phone and tables with a LiPo battery, very few have Lion anymore, have much less wear from discharges and charges. But it does not like to be fully charged for long periods so a script like this is not a bad idea if you plan to keep the tabled plugged in for long periods. Fully charged LiPo's can create gas in its cells, maybe you read about phones that cracks.

From apples site
Store it half-charged when you store it long term
http://www.apple.com/batteries/maximizing-performance/
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest