2

I have 3 I2C devices connected to my raspberry pi 3 i2c bus 1.

I want to share this whole I2C bus 1 (/dev/i2c-1) to another linux server, which is running in the cloud, through a secure TLS, username and password based socket connection, and use the linux server to do all the i2cset and i2cget using i2c-tools package.

The raspberry pi will just act as an API for the I2C bus 1. What is the best way to achieve this? Any suggestions would be appreciated.

  • Read the data on one RPi publish it on MQTT. The other systems subscribe to the data they need. hivemq.com/mqtt – Dougie Oct 20 at 6:38
  • I do not want the RPI to do any reading or writing to the bus. Just want a simple socket to share the whole bus to another linux server and do everything that is needed to be done (read/write) in that server. – Farukh Oct 20 at 6:47
  • The only way to achieve what you want is to connect the server directly to the I2C bus. The Pi is thus irrelevant to your question and therefore the question is off-topic. – joan Oct 20 at 8:09
  • @joan you sure that is the only way? – Farukh Oct 20 at 8:10
  • 2
    With MQTT the Raspberry could be just running the message broker. It doesn't have to go near the I²C devices. You could read the I²C stuff with an Arduino or ESP8266 and publish on MQTT. – Dougie Oct 20 at 15:30
1

"Connecting directly" in this context is ambiguous. Applications running directly on the Pi, using the I2C bus, would generally use some kind of library interface, such as the various Pi specific (eg. pigpio) or linux specific (I would guess python has something like that) things or the kernel API.

Point being, there is no singular "connect to the bus" mechanism. If you have been working with I2C at all, you must be somewhat aware of this.

Using ssh (or anything that networks a shell) would in fact be the closest you will get to directly interfacing with the bus in the sense that you could use the command line like you do locally.

You can instead use a custom socket if you want. However, I doubt there is an existing generic TCP <-> I2C interface application, meaning you'd have to create your own. In the end, unless you also want to pointlessly reinvent the wheel represented by pigpio, whatever python module, the kernel API etc. you'd have to choose one of those to back your implementation. This is a perfectly fine idea, but it will be much, much more work than using ssh or MQTT.

Sockets of any sort and existing I2C interfaces are simply too dissimilar to "connect directly" in the way that you could, for example, directly connect a socket and a UART interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.