We need to talk to a piece of hardware that only has an i2c interface, but from a desktop application. Has anyone had success doing so from Xojo using a USB->i2c adapter? Something like this? What’s required to make this work? I’ve done some stuff with serial before but i2c is new to me.
I know we could throw an arduino in the middle, communicate with it via serial and have it talk to the i2c device but I’d rather avoid that extra layer if I can help it.
It’s probably going to depend on what targets you plan on supporting. If you can find a I2C on each target platform you have a chance (maybe).
So it’ll probably be on Linux or Windows. Most likely Windows, since the same application needs to interface with some other hardware. The final decision will be made based on what drivers are available. It’s for in-house use, so we don’t really care but most likely, Windows.
The adapter I linked to claims that you can get mac, windows, linux, BSD drivers for it and that it shows up as a virtual COM port. That sounds fairly straightforward to me, but I’m sure it couldn’t possibly be that simple.
For $25 it’s worth seeing if Xojo recognizes it as a serial device. That would be my first step.
I dont have an easy example, and I have used a USB port on Windows with Xojo 2019 R1.1 to communicate with an Arduino microcontroller to run I2C with C code.
It can be done, and I find its specific to the I2C device to be read or written. Is this something that would work for your application?
since you’re starting from scratch, for $25 you can have an ethernet to i2c adapter. it would be easier to interface using tcpsockets.
it would work forever, ethernet will always work, usb is really dependant on platform and device driver (except HID)
Yeah, I was hoping to avoid having another device (beyond a simple adapter) in the mix. I’ve done plenty of stuff interfacing an Arduino with Xojo so that’s not really an issue, but it’s one more potential point of failure. I realize the adapter is a device, but it’d be less work on my part to have to build an interface.