简体   繁体   English

通过OTG线缆从USB设备向Android平板电脑提供电源

[英]Drawing power from USB device to android tablet through OTG cable

I am working on a project which involves communication between a android device and arduino. 我正在开发一个涉及Android设备和arduino之间通信的项目。 The final assembly of the project would be a box-like structure with only the android device's screen being visible (the remaining sides would be enclosed) . 项目的最终组装将是一个类似于盒子的结构,只有android设备的屏幕可见(其余的边将被封闭)。 Space is Important; 空间很重要; i'd like the apparatus to be as small as possible & using minimum cables. 我希望设备尽可能小并使用最少的电缆。 Communication with the arduino has been established using usb host apis. 使用usb host apis建立了与arduino的通信。 Now; 现在; the android tablet and arduino are connected through: Android平板电脑和arduino通过以下方式连接:

  • USB OTG cable on the Android tablet (micro-usb male & usb female) Android平板电脑上的USB OTG线(micro-usb male&usb female)
  • Mini-usb to usb on arduino (USB male & mini-usb male) 迷你usb到arduino(USB男性和mini-usb男性)

The problem: I want the android tablet to charge itself through the connection. 问题:我希望Android平板电脑通过连接充电。

Currently the arduino powers itself from the android tablet. 目前arduino自己从Android平板电脑。 However; 然而; finally the tablet and arduino will be connected for hours together; 最后平板电脑和arduino将连接几个小时; and that'll drain out the battery. 那将耗尽电池。 The arduino board will be getting power from an external source. arduino板将从外部电源获得电力。 I'd like the tablet to draw power from arduino. 我希望平板电脑能从arduino中获取能量。 This is working when the Tablet is switched off; 平板电脑关闭时,此功能正常; however the tablet stops charging itself and begins discharging as soon as it is turned on. 然而,平板电脑自动停止充电,并在打开电源后立即开始放电。

This is probably because the tablet goes in the Host mode (as USB HOST) and the arduino as the device/accessory. 这可能是因为平板电脑进入主机模式(作为USB HOST)而arduino作为设备/附件。 Usually in such connections, the host sends the power and the accessory charges itself. 通常在这种连接中,主机发送电源,附件自身充电。 Can this be the other way around?? 这可能是另一种方式?

My understanding is that in these kinds of connections Host Negotiation Protocol (HNP) is implemented first to determine the host. 我的理解是,在这些类型的连接中,首先实现主机协商协议(HNP)以确定主机。 Is it possible to forcibly make arduino host and the tablet an accessory? 有可能强行使arduino主机和平板电脑成为配件吗? and in such a case will proper communication be possible? 在这种情况下,可以进行适当的沟通吗?

Alternatively, is it possible to enable and disable host mode from within an android app? 或者,是否可以在Android应用程序中启用和禁用主机模式?

The main purpose is to be able to draw power from usb otg cable (I'm trying to avoid using additional cables) 主要目的是能够从usb otg电缆获取电力(我试图避免使用额外的电缆)

Please if anyone can provide assistance , it would be appreciated. 如果有人可以提供帮助,我们将不胜感激。

Thanx a lot in advance :) Thanx提前很多:)

Your device will not be able to draw power while connected as the Host. 连接为主机时,您的设备将无法获取电量。

You should look into the Android Open Accessory(AOA) Protocol , though you need the proper hardware to connect to. 您应该查看Android开放附件(AOA)协议 ,尽管您需要适当的硬件才能连接。

AOA allows the tablet to be connected as a USB accessory which will allow it to draw power and charge, but it also lets the Android device behave as if it were a host sending the commands to the connected hardware. AOA允许平板电脑作为USB配件连接,这将允许它获取电力和充电,但它也让Android设备的行为就像是主机将命令发送到连接的硬件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM