optically insulated parallel port i2c adaptor
I have modified the schematics from linux/Documentation/i2c/busses/i2c-parport to get an optical insulation while leaving the linux driver unchanged.
The design is based on the ELV type adaptor, so you have to use "type=3" as the module parameter. Insulation is done by 4 PC817 standard opto couplers. No power from PC side is required, the opto couplers are driven by the output current of the parallel port. Resistors of 470 ohms will limit the current to a value that _should_ be harmless for your parallel port, but I will take no responsibility for any damage to your hardware.
For the readback of the bus signals (SDA as well als SCL, the latter is needed for clock-stretching I2C slaves), the opto couplers will drive 2 status lines low, which are pulled up by 10k resistors to some hi level taken from data output pins.
Schematic is here: i2c_parport.png
The bus side has to be powered with 5V, but you need power for your sensors, anyway. If you use 5V from the USB, for instance, you lose the optical insulation and might harm your equipment, so better use a seperate power supply or an old DC-DC-converter (with additional regulator) from an old coax network card (the big black boxes).
Software
Driver for several i2c busses are included in the stock linux kernel. The kernel module you need is called "i2c-parport.(k)o". The module parameter you need is "type=3". This driver will attach to all parallel ports available, if you have more than one, this will result in some trouble, a common workaround is to attach the line printer driver "lp.(k)o" to all parallel ports that aren't i2c adapters connected to. The other way around, if you only have one parallel port, lp.(k)o might be attached to it (some distributions load it automatically at startup), remove this module.
If you have a i2c temperature sensor such as the LM75 attached to your adaptor, a run of "sensors-detect" (lm_sensors package, from http://www.lm-sensors.org/wiki/Download), will detect this sensor just like the ones on your mainboard.
All software that can use the "regular" sensors will be able to use you extra sensors as well. gkrellm, for instance. (Screenshot here.)
more fun
Since this parallel port i2c adapter is a full-featured one, you could attach anything to it. I2C/TwoWire EEPROMs (accessable by eeprom.(k)o and the /sys/bus/i2c/devices/ tree or the tools that come with the i2c software from http://www.lm-sensors.org/wiki/Download.
You could also attach some I2C controlled TV tuner, like those used on TV cards, or a teletext decoder or whatever, for instance some generic interface circuit like the PCF8574. Using the /dev/i2c device and the information on I2C programming from the i2c software package mentioned above, you can easily program some "blinkenlight" features. GPL'ed C sources for accessing this chip are available here. Consider this source as a quick'n'dirty hack with absolutely no warranty of any kind. If you can't get it compiled, you're on your own.
some pics
 | The adapter, built on vero board. |
 | The blinking thingie, using the PCF8574. |
 | The outdoor temperature sensor, put into a 35mm film box, connected via 10m telephone cord. Quite long, but still works. |
 | A second temperature sensor, for indoor use. The SOIC-8 LM75 (5V type) can still be soldered on vero board quite easily if you cut the pads in half with a sharp knife. |
Disclaimer
Information is provided "AS IS" without warranty of any kind. Trademarks are properties of their respective owners.
last edited 11.08.06 by hennichodernich
back to main page