I've just bought myself a raspberry pi. I'm quite excited.
I've done assorted bits of embedded C programming & PHP, but never really got into linux (altho I can do a lot of the basics).
Anyway, what I'm wanting to do is use my raspi as a webserver to connect to complex I2C chips, so I can put a pretty (and intuitive) interface on them, rather than having an LCD with a couple of buttons to try and do some complex configurations.
So, how do I go about accessing the I2C? specifically from PHP. I would be looking to write & read to a slave's register (ie slave_addr, register_address), preferably multi-byte (but I guess I can cope if that isnt possible)
I've been searching & searching google for a solution.
The closest I have found is this:
http://www.robot-electronics.co.uk/foru ... ?f=4&t=351
but that only deals with writing
Code: Select all
Summary: $i2c = fopen('/dev/i2c-0', 'w+'); $wdata = chr($data); fseek ($i2c, $adr); fwrite($i2c, $wdata, 1); fclose ($i2c);
which deals with the writing aspect, but wont translate to PHP, as php doesn't support ioctrl().
Has anyone achieved I2C coms from PHP?
or should I code a translator-type program that php can call (exec()) which handles the read/write?
it seems like such a neat way to create a nice interface for complex i2c chips. I guess the other way would be to create a hardware translater, and use the raspi UART to connect thru a microchip to the i2c device...
Anyone have any experience on this? any good reading?