Page 1 of 1

Connecting Wordpress to GPIO

Posted: Sat Jan 12, 2013 8:05 pm
by Digital Larry
Sometimes it's amazing what you can accomplish without really knowing what you're doing. And other times it's amazing how an old dog such as myself actually can learn a new trick or two.

So, long story short, I started with Raspbian "Pisces" image and installed lighttpd, MySQL, and PHP. Got the basic "Hello world", or... sorry "It works!" and then some basic php functions told me it was working OK. I installed Wordpress this morning and after just a couple false starts it actually works! That's kind of amazing.

Now, I want to integrate the Adafruit project to connect to a DHT series temperature and humidity sensor with Wordpress.

http://learn.adafruit.com/dht-humidity- ... g/overview

As written, this integrates with Google Docs and OK that's pretty cool. But I want to give this to my brother who's way less geeky than I am and allow him to use this thing in conjunction with his indoor exotic flower growing thing so that he can make observations in the Wordpress posts and automatically insert the temperature, or eventually a photo of the plant taken with a USB camera.

I think the sensor interface code is written in C. How do I get that info out of there and into Wordpress?

Without knowing any better, I can think of:

1) Have the C code write some OS environment variables which Wordpress can pick up somehow (PHP?).

2) Have the C code interface with MySQL and then WordPress can call PHP to get the stuff out of MySQL.

Any brilliant ideas or caveats?

Thanks!

DL

Re: Connecting Wordpress to GPIO

Posted: Sun Jan 13, 2013 10:46 pm
by Chapindad
I have done wordpress and built templates but that was a few years ago in a different life. I would look for a Wordpress plugin that will allow you to pull MYSQL fields into a post and then write the C code to insert the data into the fields.

Re: Connecting Wordpress to GPIO

Posted: Thu Jan 17, 2013 10:18 pm
by KiltedPi
When you say:
1) Have the C code write some OS environment variables which Wordpress can pick up somehow (PHP?)
I would do it that way since its more secure.

I'd write BASH scripts that would write to an SQL database from my Pi-side. Dunno how to do the web dev tho.

Re: Connecting Wordpress to GPIO

Posted: Fri Jan 18, 2013 5:20 am
by technion
KiltedPi wrote: I would do it that way since its more secure.
.
Just to spell out why that's important...

GPIO access, such as accessing temperature monitors, must be done as the root user due to access to /dev/mem.

Your webserver definitely should not be running as root user.