# How can I charge an Android phone while it's controlling my 3D printer?

I am writing a G-code sender for Android, but I have hit a snag. How can I prevent the phone from discharging while it sending G-code to the printer?

I have several Android phones and tablets and they have a micro USB OTG connector, which I can connect to my 3D printer using an adapter. But it looks like OTG has this limitation - it can either accept power when in Device mode, or it can provide power in Host mode. So, while in Host mode the phone can't be charged, so I can't do long prints, which seems like an unreasonable limitation.

Any ideas on how to solve this?

• This question isn't really about 3D printing. The 3D printer isn't relevant to the question, it's just a question of whether a smartphone can charge while in USB OTG mode. Moreover, the specific phone in question is probably quite important to the answer. – Tom van der Zanden Jun 13 '17 at 19:33
• I think this problem is specific to 3D printing, because it's a very unique use case. 3D printer must be connected to the phone for several hours. In other use cases a person can transfer a file to a USB flash drive in just a few minutes, so a battery charging is not an issue. Also it's not specific to the phone. Every phone and tablet I have behaves the same for this matter. – Sergey Jun 13 '17 at 21:22
• The answer might be specific to the phone/tablet. Maybe some support it, maybe some don't,... – Tom van der Zanden Jun 13 '17 at 21:47
• Ah, I see. But even if there is only one phone that "support it" - that would be a solution. I'll just buy that exact phone. Thanks. – Sergey Jun 13 '17 at 23:45
• This can be Android device specific. Can you edit your question to list the devices you have tried this on? – markshancock Jun 14 '17 at 21:10

See elsewhere on StackExchange:

You certainly can charge whilst in host mode, but some re-wiring will be required.

Apparently it is possible to charge the Host-Device! --> http://en.wikipedia.org/wiki/USB_On-The-Go

Under "OTG Micro Plugs" it says that a USB OTG cable with a 36.5 kΩ resistor between Pin 4 (I suppose its pin 4) and Pin 5 allows you to connect a B-Device (Slave) and (!) a Charger to the Smartphone/Tablet. The Phone and the B-Device can be supplied by the external power source.

USB-Power Specifications: http://www.usb.org/developers/devclass_docs/batt_charging_1_1.zip

and

I just sifted through the docs because I didn't trust Wikipedia's implicit data on which of the three resistances I should use. Here you can find the official Battery Charging v1.2 Spec and Adopters Agreement: usb.org/developers/docs/devclass_docs In this case you want 124kΩ, because you want the OTG device (=tablet) to be the A device (=host).

Here are the schematics:

• @Sergey - Welcome. Your app sounds interesting, btw. – Greenonline Jun 14 '17 at 4:52
• Note that this can be device specific. Not all android devices implement USB OTG and charging the same way. – markshancock Jun 14 '17 at 21:09