I need a tiny usb host microcontroller that outputs i2c - Page 1
Forum section: electronics / general

author: VinnyViele
author_rank: Newbie
timestamp: January 16, 2023, 10:25:59 pm
content: I need a microcontroller that will allow me to plug in a keyboard via a usb port, (I have USB A Female to MicroUSB adapters if need be) and then transfer the keypresses over to my microcontroller that I have via i2c. Does anyone know of a board that can do this? I can’t add a USB host shield to my main microcontroller because I have a Gameduino on it. Thanks!Edit:I’m probably going to follow this tutorial:https://youtube.com/playlist?list=PLVfmdw6Y3COp4Via7KergjVs8i194ffJSIt’s for making a Bluetooth USB relay, but I can modify it and connect it to i2c to achieve what I want to do.It uses a Arduino Pro Mini and a Mini USB Host Shield 2.0

author: thm_w
author_rank: Super Contributor
timestamp: January 16, 2023, 10:30:37 pm
content: Almost every USB mcu dev board in existence is capable of this.Unless you are talking about specifically one that has PC side support software already ready to go.https://www.eevblog.com/forum/beginners/linuxwindows-compatible-usb-or-rs232-i2c-tool/https://ca.robotshop.com/products/usb-to-i2c-converterhttps://www.adafruit.com/product/2264

author: VinnyViele
author_rank: Newbie
timestamp: January 16, 2023, 10:42:30 pm
content: Sorry, I was referring to a microcontroller that supports plugging a USB keyboard into it and the key presses are sent over to my other microcontroller by i2c. I’ll update the post

author: thm_w
author_rank: Super Contributor
timestamp: January 16, 2023, 11:16:39 pm
content: Since you mentioned the shield:https://docs.arduino.cc/retired/shields/arduino-usb-host-shieldany arduino board that supports that shield is going to also have i2c as well, and would work.But this seems like a complicated solution, or at least, one that will be fairly complex to execute.https://microcontrollershop.com/default.php?cPath=154_170_273https://www.sparkfun.com/products/9947What is the base arduino board being used, is it a regular 8bit board?If you have something like Arduino Due it can be configured to run as a USB host, without needing any additional expansion board. Maybe other models exist as well.

author: VinnyViele
author_rank: Newbie
timestamp: January 16, 2023, 11:23:36 pm
content: I’m actually using an Adafruit Metro M4 running CircuitPython.I want to know where to get another board that can take a USB keyboard and communicate with my Metro over I2C, (I can’t attach a shield because I’m already using another shield for graphics)

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 16, 2023, 11:29:56 pm
content: Quote from: VinnyViele on January 16, 2023, 11:23:36 pmThe MCU on this board (ATSAMD51) has a USB OTG controller and can act as a USB host directly. Why use a separate chip and go through I2C? (My guess is that either you didn't know this MCU was capable of that, or you don't know how to program it to do that. Now to be checked is whether this Adafruit board itself does support USB host.)

author: VinnyViele
author_rank: Newbie
timestamp: January 16, 2023, 11:39:23 pm
content: Because I’m running CircuitPython and they haven’t added support for the port to act as a host

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 16, 2023, 11:51:33 pm
content: PIC24FJ64GB002 has USB OTG & I2C. QFN28 if you want it small, SOIC or even DIP28 if you don't.Doesn't even need a crystal to do USB.

author: thm_w
author_rank: Super Contributor
timestamp: January 17, 2023, 12:00:22 am
content: https://github.com/gdsports/USB_Host_Library_SAMDlibrary here but its not circuitpythonIt looks like the cpython USB host support is very recent, so many you can search through and see what it supports:https://www.hackster.io/news/circuitpython-7-3-0-release-candidate-brings-usb-host-support-raspberry-pi-rp2040-pio-improvements-c928e6c1ef92

author: VinnyViele
author_rank: Newbie
timestamp: January 17, 2023, 12:13:04 am
content: I have a Gameduino on my m4 and I can’t attach any other boards, and that library needs me to attach a usb shield. Which I can’t do. I am asking for a tiny microcontroller that I can plug a keyboard into that I can use i2c to talk to my m4.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 17, 2023, 06:09:18 am
content: It might be possible to use an Attiny85 and bit bang the USB host part. Or if possible bit bang it on your current board. Only has to do the slowest USB variant since keyboards are slow.But another option might be to use the PS/2 interface option. Not sure if modern USB keyboards still have this option. Could be worth to investigate this. Only takes two pins to interface with it.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 17, 2023, 09:04:08 am
content: Does it have to be USB? Many older keyboards support both USB and PS2, the latter being a simple SPI-like prototcol

author: VinnyViele
author_rank: Newbie
timestamp: January 17, 2023, 01:43:56 pm
content: PS/2 uses 8 bit words and i2c uses 7 but words

author: gamalot
author_rank: Super Contributor
timestamp: January 17, 2023, 01:53:12 pm
content: RP2040 (Raspberry Pi Pico) is one of the most available and cheap.

author: Skashkash
author_rank: Regular Contributor
timestamp: January 17, 2023, 02:01:52 pm
content: I think Mike's suggestion is to bit bang the PS2 keyboard protocol on the I2C or two other pins.You may already have PS2 support on your board with CP support.https://docs.circuitpython.org/en/latest/shared-bindings/ps2io/index.html#module-ps2ioAs another alternative, a raspi pico could act as a USB HID host.There are some examples out there, but you'd need to add the USB connectors.

author: spostma
author_rank: Regular Contributor
timestamp: January 18, 2023, 07:22:50 pm
content: I would suggest the very cheap CH554 or CH559 20-pin controllers with 8051 core that can be programmed using Keil or SDCC:https://hackaday.com/tag/ch554/https://github.com/HonghongLu/CH554https://github.com/Blinkinlabs/ch554_sdcchttps://github.com/ole00/ch554_sdcc_usb_blinkyA long German forum thread with lots of know-how info on this processor:https://www.mikrocontroller.net/topic/462538?page=single

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 18, 2023, 08:03:47 pm
content: Quote from: spostma on January 18, 2023, 07:22:50 pmInteresting devices with USB 2.0 full speed device and host support, but a quick look at the information on the wch website shows no I2C interfaceDid not look at the datasheet if one of the serial interfaces supports it, but it can of course easily be bit banged.http://www.wch-ic.com/products/CH559.htmlhttp://wch-ic.com/products/CH554.html

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 18, 2023, 08:31:48 pm
content: Hardware guys often want to rely on software to ease their pain, and software guys often want to rely on hardware to ease their pain. Always like that.This is how we end up requiring 32GB of RAM to run a word processor.If you used C instead of CircuitPython, you could use tinyusb for the USB host side and would not need any additional hardware.

author: VinnyViele
author_rank: Newbie
timestamp: January 18, 2023, 08:37:04 pm
content: I wish I could, but it’s not that simple.I’m making an OS with it and the way that Arduino works, it would be impossible to execute external binary files from an SD, but I found a way to do it on CircuitPython.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 19, 2023, 07:00:12 am
content: Quote from: SiliconWizard on January 18, 2023, 08:31:48 pmOr should he wait for IPL to be finished and all his problems will be solvedp.s. The I stands for Imperium until it changes again of course.

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 19, 2023, 07:33:12 pm
content: Quote from: pcprogrammer on January 19, 2023, 07:00:12 am