A client and server for I2C control over TCP
A SMBus class-compatible TCP proxy allowing you to host or connect to a Remote I2C session with minimal effort.
My use case for writing this module is to allow me to work with I2C on a Raspberry Pi that is on my network, without having to install anything that takes up too much memory or processing power. I serve this thin SMBus server module on the Pi, then I can develop as I please on my computer and interact with the I2C bus as if it was on my own machine.
This module was developed:
- without tests
- for the purpose of development
It is NOT:
- a replacement for an actual local I2C connection (particularly for real-time comms)
- guaranteed to be free of bugs
- suitable for production use (unless you're happy to take your chances)
Install with pip:
pip install remote-i2c
On the I2C Host (e.g., Raspberry Pi)
- Ensure that I2C is enabled! (
- Ensure that the user you're operating under has permission to access the I2C hardware! (e.g., part of the i2c group)
- Run the remote-i2c module directly with the python interpreter from the command line:
python3 -m remote_i2c
- Alternatively, run the module from a python script:
#!/usr/bin/env python3 # Import the RemoteI2CServer class from remote_i2c import RemoteI2CServer # Create the server (see docstring for additional args) server = RemoteI2CServer() # Start the server (blocks forever!) server.serve()
On the I2C Client (e.g., Desktop/Laptop)
#!/usr/bin/env python3 # Import the RemoteI2CClient class from remote_i2c import RemoteI2CClient # Connect to the I2C Host (see docstring for additional args) remote_i2c_host = '192.168.1.2' bus = RemoteI2CClient(remote_i2c_host) bus.connect() # Perform I2C operations as you normally would with SMBus2 addr = 0x67 reg = 0xf2 value = bus.read_byte_data(addr, reg) bus.write_byte_data(addr, reg, value + 1 % 0xff) # Disconnect when you're done, if you feel the need bus.disconnect()
Copyright © 2019 Daniel 'Vector' Kerr (email@example.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size remote-i2c-0.0.9.tar.gz (4.6 kB)||File type Source||Python version None||Upload date||Hashes View|