frak / php_spi

An OO PHP interface to SPI devices developed for use on the Raspberry Pi
Other
17 stars 7 forks source link

Reading SPI Data from Sensor #2

Closed jeffsrepoaccount closed 9 years ago

jeffsrepoaccount commented 9 years ago

First off, I love the fact that you're porting SPI support to PHP.

I am working through a tutorial using a Rasberry Pi to take sensor readings from an analog moisture sensor connected to an MCP3008 channel which in turn is connected to my model B rev 2 MOSI / MISO pins. Instead of using python, I (like you) want to use PHP for taking the readings on the sensor.

I have the extension compiled / installed (showing up in $ php -i | grep -i sdi) on the rasberry pi, and I can construct an object using your example and call the transfer method on it. My problem is that I do not know how to read data from the sensor.

The sensor itself is the Octopus Soil Moisture Sensor, and I can't really find too much documentation out there about it. Is the method for reading data from an SPI sensor just missing / incomplete, or do you use the transfer or blockTransfer method on the spi object and read the return value?

frak commented 9 years ago

I haven't actually ever got to use my extension in anger, so to speak. I wrote it quickly when I thought I would need it but then life changed my direction.

Please check that you have the spi kernel module activated http://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md and then it should just be a case of reading data from the bus. Sorry I can't be of more help.

jeffsrepoaccount commented 9 years ago

Thanks for the reply. My issue was mostly related to my own misunderstanding of SPI, so closing this issue. FYI- still using this extension and seems to be working great.

frak commented 9 years ago

That is good to hear :o)