Can ATTiny85 work as usb adaptor (i2c master)?

Hi,

I want to receive data from TCP (http) and send it to a device that is an I2C slave. I am a CompSci person, very new to electronics.

Under worst case scenario I need to send 24 bytes per second over I2C, normally it`d be lesser.

To bridge the gap between http and I2C I know I need some thingy that can "listen" for data when attached to USB port and forward the bytes to the I2C slave.

Fortunately, I have an ATTiny85 lying around. and I am looking at GitHub - harbaum/I2C-Tiny-USB: Cheap and simple I²C to USB interface

Does this mean using harbaum's firmware I'll be able to use ATTiny85 to do this. Am I understanding correctly? Because as per https://forum.arduino.cc/index.php?topic=231279.msg1667673#msg1667673 , there's no straightforward way to read bytes from USB on ATTiny85.

BTW, the project is latency-crucial. I am open to learning about other chips/methods which wouldn't add to latency.


Another related project: USB to I2C Adapter using Arduino · GitHub

The ATtiny85 does not have a USB interface, the ATmega8U2 is often used for this purpose as it does have a native USB interface, but interestingly no I2C. For that you have to go a step further up in line to the ATmega16U4, that one has both native USB and I2C available.

Note that you will have to run from a 12 MHz crystal (I also saw that in a quick skim of the documents linked to for the ATtiny85).

24 bytes per second is no more than about 300-400 bits per second including overhead, that’s nothing on a standard 100 kHz I2C bus.

EVERYTHING will have latency, for the simple fact that there is protocol overhead. The question is: how much latency is acceptable for you? Is 10 ms acceptable? Or do you have to bring it down to say <100 µs?

wvmarle:
24 bytes per second is no more than about 300-400 bits per second including overhead, that’s nothing on a standard 100 kHz I2C bus.

@wvmarle Good to know.

I found FTDI’s FT232H (works as I2C master), but can’t get it in stores near me. Can you suggest how…

To bridge the gap between http and I2C … some thingy that can “listen” for data when attached to USB port and forward the bytes to the I2C slave.

Thanks.

A regular Arduino board can listen to USB, and communicate over I2C…

Microchip manufactures a USB to I2C/serial device that can be bought in DIP packages. It's 5V tolerant when USB powered but can also be powered by 3,3V. Only a few external caps and a pull up resistor needed. And a USB connector of course. There's an easy to use native and managed library available for Windows. There's also a kernel module for Linux but it's a bit more involved setting up. Configuration tools are Windows only.

I have quite a few lying around since they're very useful.

https://www.microchip.com/wwwproducts/en/MCP2221A

A regular Arduino board can listen to USB, and communicate over I2C...

I have a Nano (v3), can you point me to code samples that show how to read (and optionally, how to write to, using C, Go, node, etc.) the data stream over USB port?

I am confused because I am reading Serial - Arduino Reference and from what I understand only Zero & Due support Serial.* functions over USB.

MCP2221A - USB - USB Bridge

Thanks, looks great. Hopefully I'll be able to buy it.

ggnum:
I have a Nano (v3), can you point me to code samples that show how to read (and optionally, how to write to, using C, Go, node, etc.) the data stream over USB port?

From the Arduino's pov, it's just Serial communication.

got it

How can I mimic arduino IDE's "serial monitor"'s Send button functionality?

ggnum:
How can I mimic arduino IDE’s “serial monitor”'s Send button functionality?

Hi,
any help to install driver i2c-tiny-usb from

I already upload *.hex file to digispark attiny85 but after that in device manager i see i2c-tiny-usb in other devices and need a driver to work
in the github link found folder usbdriver but i don’t understand how to install the driver from it