1
\$\begingroup\$

I have an ATtiny13a running code at 9.6 MHz (internal oscillator) for single pin Tx Rx half-duplex serial port at 115200 baud rate using a lib which I found online

Using FTDI 232RL or BT HC-06 in between I am able to send & receive arbitrary data between the MCU circuit and Putty/Android.

What would be the cheapest and smallest (in terms of PCB size and ATTiny memory) way to achieve the same arbitrary data communication to an Android device (non-rooted) instead of BT.

Also is there a way to achieve it keeping the MCU circuit in accessory mode for Android and NOT using Android's host mode since the MCU circuit will be powered externally and not from Android. The MCU's power source will also be delivering power to Android on the USB's Power buses.

How can I achieve arbitrary data communication between ATTiny in accessory mode and Android over USB?

Will VUSB work in this case? or do I have to buy a converter chip (CHG340?) but will that chip work in accessory mode? Also will there be any changes to support USB Type C port?

Thanks

\$\endgroup\$

closed as too broad by Passerby, Chris Stratton, Voltage Spike, uint128_t, Daniel Grillo Jan 4 '17 at 10:39

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ It's not clear to me what you want to achieve. Do you want your stuff behave as an USB device or as an USB host? \$\endgroup\$ – Janka Dec 30 '16 at 13:58
  • \$\begingroup\$ @Janka well, Android device certainly wont be the host since it is powered/charged externally from the MCU's power source but I do want to have arbitrary data communication with the MCU. Similar to the scenario when we transfer data over USB between Android and a PC: Android phone gets charged but we have 2-way data communication as well. Well for that we do use complex protocols such as MTP etc. But I want to do the same except between Android and ATTiny. So its like the MCU circuit would be an accessory to Android. Is that achievable? \$\endgroup\$ – ritesht93 Dec 30 '16 at 14:11
  • \$\begingroup\$ So you want to create an USB device. Sure, that's what VUSB is for. I successfully created a keyboard emulator with it: vusb.wikidot.com/project:vusb. Was about 2 days of work. Certainly worth it. Speed is limited though. If you want to create anything but a token, a keyboard simulator or other low-speed device, you better use a MCU which has an USB device controller on board. \$\endgroup\$ – Janka Dec 30 '16 at 14:15
  • \$\begingroup\$ @Janka I mainly come from a software background in degree and profession. AVR is just a hobby for me. so wanted to know if VUSB needs any support on the Android side? Have you tried using MCU's with Android before with VUSB communication? does it work normally like an ATTiny VUSB communication with a PC? Also not using Android in host mode? \$\endgroup\$ – ritesht93 Dec 30 '16 at 14:54
  • 1
    \$\begingroup\$ You can't do Android Accessory with VUSB, you need to use something that can be a USB host. I don't think there are any ATmega or ATtiny parts that can, and the outboard USB hosts are not cost effective compared to using an host-capable MCU to start with. \$\endgroup\$ – Chris Stratton Dec 31 '16 at 0:32
1
\$\begingroup\$

There is no easy way to do usb host and charging at the same time. Most phones do not support this.

But you can bypass the need for usb communication by using a bluetooth to serial module. Nothing really changes on your ATtiny aside from some minor configuration. Same serial port as the FTDI. Then provide power as a normal usb connection.

V-USB acts like a FTDI or other usb serial IC, so Android Host Mode is still required.

\$\endgroup\$
  • \$\begingroup\$ Thanks.. And yes Bluetooth does work in this case.. I've tested it out and works nicely with ATtiny13a but a Bluetooth chip increases my pcb size.. I wanted something smaller than currently available HC 05/6 or SPP-C SMT chips. Thanks anyways.. I'll have to resort to Bluetooth if nothing else works. \$\endgroup\$ – ritesht93 Jan 1 '17 at 4:57
  • \$\begingroup\$ @ritesht93 I'm sure there are smaller modules. Or skip the modules with back boards and wire to the ICs directly. The base boards add too much. \$\endgroup\$ – Passerby Jan 4 '17 at 3:14
  • \$\begingroup\$ @ritesht93 like m.gearbest.com/other-accessories/pp_341243.html (I haven't personally used these.) \$\endgroup\$ – Passerby Jan 4 '17 at 3:17
0
\$\begingroup\$

What would be the cheapest and smallest (in terms of PCB size and ATTiny memory) way to achieve the same arbitrary data

Either use a different and USB Host/OTG capable MCU or use some analogue trick on the headphone port. The latter requires some passives and an ADC pin on the Tiny.

\$\endgroup\$
  • \$\begingroup\$ There are a fair number of ARM Cortex-M MCUs with embedded USB host from Freescale, ST, etc though the poster may want to approach the project from the sense of what they can find android USB Accessory mode already supported on, rather than what is the smallest/cheapest hardware as the latter may require more original work. \$\endgroup\$ – Chris Stratton Dec 30 '16 at 16:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.