Notifications
Clear all

I2C on Raspberry Pi Desktop for laptop (Mars rover robot)

23 Posts
6 Users
2 Likes
2,509 Views
WhitneyDesignLabs
(@whitneydesignlabs)
Member
Joined: 3 years ago
Posts: 99
Topic starter  
Posted by: @madmisha
Posted by: @whitneydesignlabs

I thought maybe the USB-I2C adapter would basically "emulate" physical pins. But the Raspberry Pi Desktop OS doesn't seem to have a way to send I2C data over USB.

If you have the adapter, PI desktop OS will still run I2C over USB. Any Linux distro will. As in, if you plug in the adapter over USB you will be able to control it and output/input the I2C. But even with a Pi, you couldn't really emulate it. You would be actually sending out those signals through those pins.

 

Ah, so if I understand correctly I WILL be able to turn on I2C, I just need the physical adapter installed to even see that option? That is exactly what I attempted to ask in the original post, but I guess my wording was unclear. If this might actually work, I will buy and adapter and give it a try.

This may not be a dead topic, after all...

BTW, I will look into other Linux distros. I just thought it would be a clean interface to have all SBCs and main control computer all running the same version of OS.

Imagine by thought, create, don't wait, Scott.


   
ReplyQuote
WhitneyDesignLabs
(@whitneydesignlabs)
Member
Joined: 3 years ago
Posts: 99
Topic starter  

I dug around and found an old USB FTDI adapter I had from the days of tinkering with the pesky 8266 modules. Raspberry Pi Desktop still does not give the option of turning on I2C. But when I do a lsusb command, I see I now have a Future Technology Devices International, LTD FT232 Serial (Uart) IC adapter installed. So maybe there is hope yet.

BTW, the adapter is red and only says "HW-417" on the back. I have another very similar one that says "FTD232" on the back.

Additionally, I found a 3rd old adapter in my stuff. Still no I2C option, but lsusb now reports "QinHeng Electronics HL-340 USB-Serial adapter".

EDIT: My next step on this laptop idea is with the adapters plugged in, but using a different USB-bootable Linux distro. scratch the above. My post with MadMisha crossed over in time. So I will first work on MadMisha's suggestions.

Imagine by thought, create, don't wait, Scott.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 
Posted by: @whitneydesignlabs

Ah, so if I understand correctly I WILL be able to turn on I2C, I just need the physical adapter installed to even see that option?

You will have to install it but yes. Just like you would have to install the driver for anything you plug into your computer. I2C would be handled on the USB adapter. You will probably have to enable access to the USB but that's normal. That's just part of the Linux security.

 

Posted by: @whitneydesignlabs

BTW, I will look into other Linux distros. I just thought it would be a clean interface to have all SBCs and main control computer all running the same version of OS.

It is actually an older kernel than the one on the Pi. When installing things, it might have to have different versions because of this.

 

If it is direct I2C then you need to add I2C permissions to the non root user. Here is how to do that:

sudo groupadd i2c

sudo chown :i2c /dev/i2c-1

sudo chmod g+rw /dev/i2c-1

sudo usermod -aG i2c xander

Log out and back in(not reboot)

You should be able to run the i2cdetect

then login as root and add new rule

# echo 'KERNEL=="i2c-[0-9]*", GROUP="i2c"' >> /etc/udev/rules.d/10-local_i2c_group.rules


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 
Posted by: @whitneydesignlabs

Raspberry Pi Desktop still does not give the option of turning on I2C. But when I do a lsusb command, I see I now have a Future Technology Devices International, LTD FT232 Serial (Uart) IC adapter installed. So maybe there is hope yet.

BTW, the adapter is red and only says "HW-417" on the back. I have another very similar one that says "FTD232" on the back.

Additionally, I found a 3rd old adapter in my stuff. Still no I2C option, but lsusb now reports "QinHeng Electronics HL-340 USB-Serial adapter".

If you are going into raspi-config, that's pointless. it will not appear in there.

 

You also need to make sure you have the right permissions on the USB port. Teh easiest way to check would be to try and upload a sketch through the FTDI and see what error you get.

 

For an ACM error:

ls -l /dev/ttyACM*

For a USB error:

ls -l /dev/ttyUSB*

You will probably get a response for dialout. If it is:

sudo usermod -a -G dialout <username>

Obviously replace the username with what you are using. If not dialout, replace with what group it gave you(the word after root).


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@whitneydesignlabs

I should point out before any further confusion, that getting I2C permission wouldn't matter if you are using the USB device. All the I2C stuff should be handled on the device and you would be interacting with it over serial communication. That might depend a little on the particular device you use. If you have some in mind, I would look up the instructions for interfacing with them.

Giving permission for I2C really wouldn't matter if the I2C is all contained in the USB device. It would be like having to enable I2C on your computer so that the Arduino you have connected to it can run it's I2C. The Arduino is running the I2C and your computer does not care. I hope that makes sense.

 

Also, to be clear, the FTDI adapters are not I2C, at least not from your computers standpoint. But you can use them to see if you have permission to access the USB.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

@whitneydesignlabs

Have you considered pairing your laptop with a rpi or rpi pico to remotely control the rpi gpio pins to do i2c and whatever else one can do with gpio's?

You could then run Python on your laptop and get the rpi to do all the communications with other boards etc. 

Maybe the following library on using the rpi pico gpio pins remotely would be of interest

http://abyz.me.uk/picod/


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 
Posted by: @whitneydesignlabs

I have tried Preferences/Raspberry Pi Configuration and sudo raspi-config at command line. I2C shows up in neither.

image

Hi @whitneydesignlabs - here is my own screen showing raspi-config. I2C is indeed a possible choice, the 5th line down.

Germane to this discussion, I am running a RasPi 4 as my main, desktop machine, at least here in my electronics bench. The ability to turn on I2C makes sense to me, since it involves a change to the Linux kernel. I see @madmisha has already given a similar explanation, and better than mine 🙂

I would also agree with Misha that the Pi desktop OS is a little bit of an odd duck. I think it's neat that the Foundation tried something like this, but I'm not sure I would run it myself.

I'd also echo your thought about using a Pi 4 as the main brains of the system. A laptop might still come in handy, but perhaps at a higher level of commands, reading status and displaying status in a meaningful way. Sounds like a great project, good luck!

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@jbo

The original question was how to enable I2C on a LAPTOP running Raspberry Pi Desktop OS. There was never any problem enabling it on the Raspberry Pi.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Page 2 / 2