Linux - MobileThis forum is for the discussion of all topics relating to Mobile Linux. This includes Android, Tizen, Sailfish OS, Replicant, Ubuntu Touch, webOS, and other similar projects and products.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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...
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.