More work to do, but big breakthroughs with FridgeGizmo today. I got the RaspberryPi pulling London weather and random worldwide tweets and trends and displaying them on my LCD display via an Arduino Uno.
I installed Apache 2, the Apache curl module and PHP on the Raspberry Pi using the excellent instructions here: http://fusionstrike.com/2012/installing-apache2-raspberry-pi-debian
I added the PHP Serial class to my Apache directory
/var/www/ and used similar files I used on my OS X test version – changing the device name to
ttyACM0, which is how an Arduino Uno appears on the Raspberry Pi running Raspbian.
I had to power the Arduino & LCD display shield with another power supply – the screen’s contrast was dim otherwise, suggesting it wasn’t getting enough current from the Raspberry Pi’s USB port alone.
When I ran my bash shell script to fire it off.. not much happened. It pulled the weather ok, then just hung with no error messages. It looked like it might be a similar problem I had in OS X, with serial connections over USB getting dropped. I found that typing
stty -F /dev/ttyACM0 -hupcl
at the RaspberryPi command line before running the script, made it work. Lots more tidying up and tweaking to do, but I have a self-contained RaspPi/Arduino combo that gets weather and tweets over wifi and displays them on an LCD screen. Yay!
UPDATE: having powered it all off and on, I’ve struggled to get this working again without typing
screen /dev/ttyACM0 9600 and sending some characters to the Arduino before quitting Screen and running the script. More work needed… :)
UPDATE TO THE UPDATE!
Well, seems like
stty -F /dev/ttyACM0 -hupcl was a red herring. According to this article, there are big problems with serial communication between the Raspberry Pi and Arduino. So how did I get it to work? I think the
screen command (which I used in my Raspberry Pi/Arduino Morse code project) must do something to force open a connection. I tried getting my bash launching script to run
screen but it would just hang and go no further until you manually quit the screen session. I then found you can run
screen without starting a new console by using the command
screen -d -m. So my bash script that launches the PHP code to pull tweets & weather down from the internet, now looks like this:
screen -d -m /dev/ttyACM0 9600
I know this is a horrible kludge, and I have no idea how or why it works, but it does seem to do the trick. As I recall
screen doesn’t come included with Raspbian, I had to install it using
sudo apt-get install screen at the Raspberry Pi terminal command line.
Now I just need to get my bash script to run automatically when the Pi boots up and it really will be self-contained, requiring no keyboard, TV or mouse.