LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Mobile (https://www.linuxquestions.org/questions/linux-mobile-81/)
-   -   I2C through USB port on an Android phone? (https://www.linuxquestions.org/questions/linux-mobile-81/i2c-through-usb-port-on-an-android-phone-4175702658/)

sidtupper 10-26-2021 08:39 PM

I2C through USB port on an Android phone?
 
How can I get data from an I2C sensor through an android phone USB port? I see that mobile Linuxes have I2C support and USB to I2C adapters exist but I haven’t found a method described for putting those together.

ondoho 10-27-2021 12:28 AM

Quote:

Originally Posted by sid@sidtupper.ca (Post 6296018)
I haven’t found a method described for putting those together.

What exactly did you search for, what did you find, have you tried anything?
What is installed on the Android phone? Which version? Which device?
FWIW - and without further information - my guess is that it's largely up to Android to allow this sort of access through a USB port.
Have you looked into & dissected existing projects that achieve something similar?

BTW, if this is your email address, you might not want to make it public in this way. The whole internet can see this. Ask a mod to change your username.

sidtupper 10-27-2021 01:31 AM

Thanks for the suggestion to ask to have my name changed. Done.

I’m thinking about displaying CO2 sensor data and I’m looking into connecting a i2c sensor to a smartphone which would read it and write the data in large font on the screen. I haven’t got the phone yet. Since I posted my question, I’ve been doing more reading. Android Studio seems like a path to explore. It has a device emulator which includes a Samsung Galaxy Nexus image, and I can find that phone cheaply. It’s max Android 4.3.0. The Nexus USB port supports host mode so I’m looking for an Android package to write to and read the data port, connected to a usb to i2c adapter. This is my first foray into phones.

I’ve put a few hours into looking for a similar project but haven’t made the right search query yet I guess. It seems like a not uncommon application. Thanks for your response, and for any further ideas you might have.

enigma9o7 10-27-2021 10:43 AM

Depending on how tech savy you are, you might be able to get something like https://www.mcc-us.com/ (iport) to work. I'm imagining connecting a usb hub (or some other adapter) to get a "USB A" port, then yer physically connected. Supposedly driver is in linux 2.6 kernel. But their software is closed source so I guess you can't easily just recompile in termux or something.

If all you're doing is polling i2c and reporting a value on a screen, I think you'd be better off using raspberry pi than a mobile phone. I'm not experienced with this but pretty sure it has some gpio's or something you can use for i2c without an adapter and people already written working open source software... and im sure theres some kinda like LCD screens if you dont wanan use a whole monitor...

ondoho 10-28-2021 12:04 AM

Oh, I assumed you want to read one of the phone's i2c sensors from your main computer.

Do you need the phone's GUI & touchscreen to see the values & give input? If not, you might be able to install some sort of simple CLI-only Linux distribution on it.

Older Android devices and older Android versions are less locked down and more hackable.

But even so, it sounds like a daunting task to hack around the Android OS to get this working; on an R-pi running a proper GNU/Linux distro you would not have this problem at all.

sidtupper 10-28-2021 12:42 AM

Yes, that’s what first occurred to me, RPi + sensor + LCD, but I’ve done that a few times already. I have a $10 Nexus tablet + usb-i2c adapter + sensor and a sense of adventure. The plan is to learn how to make an android app and have it write to and read the USB port, and write to the screen.


All times are GMT -5. The time now is 09:43 PM.