Hello,
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)

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...

I may be a bit late to the party, but I struggle accessing I²C from withing PHP and can't find any useful information on it.
I searched on what seemed to be the entire internet an I thought someone here might be able to help.

Fist of all:
Your code does not work for me as PHP reports "PHP Warning: fseek(): stream does not support seeking "
I'm using the model B and I²C works if I use other tools outside php like i2cget.

Second of all:
could you explain why you shifted the bytes the way you did in your second post?

I never really got this to work.
I *think* it's because of the way i2c works
Raspi sends a message of address:registry in a 16 bit packet
So highest 8 bits are the chip address (7 bit) with the read/write bit set using the '& 0xFE' and '| 0x01'
And the lowest 8 bits are the registry to set ( I presume, although not tested, that you can then read/write consecutive bytes as per i2c standard).
FSeek was recommended for i2c (and peripherals) use in C, so I thought i'd try it in php, but as youve seen it doesnt work. After trying that, I couldn't find anything that replicated the behaviour of fseek... So it might have to be shell()

If you can make any progress on this, it would be amazing.
I kinda gave up on it after hitting this brick wall... Kinda gave up on raspi as well...
Maybe someone else has done the bit I couldn't get on the paste year.

Here is a PHP I2C Library I started for use with Raspberry Pi. There is a core I2C class that can be extended to work with various peripherals. There are also some specific classes that extend the I2C class for some specific peripherals that are all mentioned in the readme.

as far as I know the bmp180 is just a newer version of the bmp085, so it ought to work fine.

Personally, I don't think I'd do much I2C directly from PHP - I'd be writing a little shim program in C to return the result like the gpio program does above, then call it from a PHP program - only because C has better bit twiddling and arithmetic needed for some I2C devices.

I'm so sorry for not answering your posts. It has been some years and I'm not sure if anyone is still interested. I have to look for the extension in my old HDD. If I find it, I will post it here for sure.