SmartGPIO - Raspberry Pi with PHP Returns GPIO Pin Status to ST Image Tile

Hi all,

This project consists of a Raspberry Pi running Raspbian OS. It runs HTTPD with index.php as the source. The PHP has many functions but this device driver is specifically to see the GPIO status of all pins in a picture format.

Here’s a related topic which contains the PHP file needed. I didn’t want to keep a copy in two places so pick up index.php from this post:

Use the TEST button first to make sure that you install a required graphic component for PHP called php5-gd. Once my app senses that this component exists, it will populate the image tile. Otherwise the TAKE button will not work and not return an image as expected.




Great achievement, it’s me again :smiley:

I have a question about your index file if you don’t mind, when you send the image back to ST, is it already a jpg or png file? and on which line does it transmit the image to ST?

Thanks @Casper! Go grab the new PHP just because the color blue will be darker and not so bright. After seeing how bright blue it was, I had to change it :slight_smile:

It is indeed Jpeg format and this is the line that controls it:
imagejpeg($im, NULL, 85);

change the function to imagepng() but verify if that function has the same “quality” indicator like you see above with the number 85. That’s the Jpeg quality and you want to be careful as SmartThings will die at about 40KB’s of data being passed via their Amazon S3 temp bucket.

Amazon S3 is used to store the image. It is then pulled down to your ST application. It is NOT stored on the hub but the hub is used to grab it from our Raspberry Pi and put onto the Amazon cloud solution, then the app knows how to download/link those. If you’re unaware of this, search the Generic Camera Driver thread from @pstuart where this is discussed many times.


Hey @JZst thanks for the info, but I still trying to understand where in the index that actually sends the image to S3/ST. Thing is I have my .jpeg file and I want to replace the part of your code that generates the image with my path to image.

See the two function: putImageInS3 and getPictureName in the code. Also see the manual for image tile in ST.

I never fully understood how it all worked but based on my experience any device.image tile will get the resulting image unless the parse() function does not succeed. Meaning you don’t directly relate any image to a tile. Seems that the relationship is implied. This source code and the generic camera driver should be your best resources.

Notice that after putting the image into S3 there is no more references to that object or tile. Hence the implicit claim.

1 Like