Using Pi as i2c slave device?


10 posts
by Echo5 » Fri Mar 08, 2013 8:41 pm
Greetings,

Can the Raspberry Pi be configured to run as an i2c slave device?

I want to setup the Pi using Wheezy to receive and save data sent by an i2c master device.

Does slave mode exist in any of the Python (Quick2Wire or python-smbus) or C++ i2c libraries? Are there any examples of how it can be implemented?

Thank you
Posts: 1
Joined: Fri Mar 08, 2013 8:34 pm
by abcabc » Fri Nov 15, 2013 3:11 am
I have searched for this also...

I'm using rpi and arduino with the smbus-package, no problem with rpi as master.
It's hard to find any real documentation about the smbus-package. Has anyone found any real documentation? Any other package?
It seems in the git-source-code that no slave functionality is included, but I'm not sure.
I can try to extend the smbus-package, but I want to check with you all first.
/abcabc
Posts: 7
Joined: Wed Mar 27, 2013 10:08 pm
by techpaul » Fri Nov 15, 2013 11:15 am
From memory the Linux driver does not support slave mode also I do not believe the slave functionality is available on the Pi.

I could be wrong but those are my recollections
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by msperl » Fri Nov 15, 2013 11:36 am
In principle there is support for BSC(=I2C like)/SPI slave in the HW (see page 160 in the peripherals document)

After quick scanning the pages, it seems it would require the use of:

  • GPIO18,19,20 and 21 for slave SPI
  • GPIO18 and 19 for slave I2C

But only GPIO 18 is available on the RPI, so there is not option for either I2C or SPI.

Why not trigger an interrupt on your device and implement polling on the RPI instead?

If that is no possibility, then maybe add an Arduino acting as a (proxy) slave to both sides?

Martin
Posts: 315
Joined: Thu Sep 20, 2012 3:40 pm
by abcabc » Fri Nov 15, 2013 3:41 pm
Thank you for your answer. The real problem for me was that it was annoying not to know, I have other solutions.
Posts: 7
Joined: Wed Mar 27, 2013 10:08 pm
by reachparagm » Fri Dec 19, 2014 11:31 am
abcabc,
I too have similar scenario. Did you get this to work ? Can you guide other on this ?
People on other forum mention of i2c BSC slave mode. Anybody got it to work ?
Posts: 2
Joined: Fri Dec 19, 2014 11:24 am
by joan » Fri Dec 19, 2014 12:42 pm
reachparagm wrote:abcabc,
I too have similar scenario. Did you get this to work ? Can you guide other on this ?
People on other forum mention of i2c BSC slave mode. Anybody got it to work ?

No one has written a driver to support I2C slave mode on the Pi, nor do I expect one ever to be written.
User avatar
Posts: 8522
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by reachparagm » Tue Jul 21, 2015 2:54 am
3.19 kernel support i2c slave support. Has anybody played with it to get to completion ?
https://lwn.net/Articles/621558/
Posts: 2
Joined: Fri Dec 19, 2014 11:24 am
by joan » Tue Jul 21, 2015 5:27 am
reachparagm wrote:3.19 kernel support i2c slave support. Has anybody played with it to get to completion ?
https://lwn.net/Articles/621558/

First I have heard of that driver. On the Pi effort would probably better be spent trying to implement the SPI/I2C Slave peripheral.
User avatar
Posts: 8522
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by DougieLawson » Tue Jul 21, 2015 1:11 pm
reachparagm wrote:3.19 kernel support i2c slave support. Has anybody played with it to get to completion ?
https://lwn.net/Articles/621558/


I think the RPF folks are looking at that stuff in the 4.0.x kernels. Current kernel is 4.0.8 #805.
[SIG]
Hacker on ZX80, Microtan65, Raspberry Pi & Arduinos
Mainframe Database troubleshooter
MQTT Evangelist
RPi owner since 2012.
Twitter: @DougieLawson

2B, B+, A+, 5Bs

Please post technical questions on the forum, not by personal message. Thanks.
[/SIG]
User avatar
Posts: 15340
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK