Pure Python I2C : access to I2C components through serial or parallel interface.
Download
Note : no warranty, no liability, project is provided 'as is' but I hope you will enjoy it !
Why ?
Access to I2C components from a very low cost interface, in pure python, over serial, parallel (maybe more in the future) interfaces, with a minimum hardware.
This implementation is intended to be fast but simple and minimalist.
Features (0.3)
- handle SDA and SCL pins
- handle your own hardware interface simply adding your puthon driver in drivers directory,
- auto-detect available interfaces (COM1, COM2, LPT1, etc...)
- LM75/DS75 I2C sensors,
- analyse SCL/SDA signals with pyScope :
Future features
- add more I2C components,
- add your own driver if you send it to me,
Example
>>> import I2C
>>> import I2C.sensors
>>> i2c = I2C.BusI2C('COM2')
>>> i2c.bus.setSpeed(2000) # you can set i2c speed adapted to your hardware
>>> sonde = I2C.sensors.LM75('Room 1', i2c)
>>> print "T = %02.03f C" % sonde.getTemperature()
get more examples here
Example minimal serial port I2C interface
This interface is really low speed and minimalist, it's based on specific optos. You can find better also better solutions : http://www.standardics.nxp.com/support/documents/i2c/pdf/optoisolation.pdf
Example minimal parallel port I2C interface
It-s possible to select SDA input signal, python driver can be easily adapted to you choice.
Python packages required
- pySerial if you plan to use I2C over serial port
- pyParallel if you plan to use I2C over parallel port
Win32 platform
pyParallel need you install and start giveio.sys driver
Linuxes
pyParallel on linux is based on ppdev module, make sure ppdev module is loaded and not lp.
add change device access rights to make non root users or add users in right group (lp group on most systems).
On most systems, ppdev is not the default parallel port handler, you must make sure module ppdev is loaded :
sudo modprobe ppde
sudo rmmod lp
sudo chmod go+rw /dev/parport0
Install from tarball
tar -xvzf pyI2C-0.3.tar.gz
cd pyI2C
python setup.py install