What I find to be quite a good combo together is the Raspberry Pi, an Arduino Mega, and a Xbee pro with Arduino shield.
First off, download the Raspbian image or Xbian (XBMC for raspberry pi). The Xbian installer is very easy to install because it flashes the SD card with the image it downloads from the internet. When the installation to SD card is complete, pop it into the Raspberry Pi.
Hook up the Pi to an HDMI capable TV and use a USB micro power cable to give it power.
Grab an ethernet cable and connect the Pi to your router.
You can either directly connect a keyboard to the Pi, or you can use Putty (Windows) or Terminal (Mac) to communicate with SSH to the Pi by grabbing the Pi's IP address (192.168.0.###).
If using Xbian, it will tell you in System info. The default login in is username xbian and password Raspberry. Raspbian's default username is pi with password raspberry.
Go to your router's configuration page (192.168.0.1) and login.
Go to Gateway→Port Forwarding. Enable two ports to be forwarded. For both, put the local port to be forwarded that corresponds to Pi's IP address. For example, if Pi is at 192.168.0.100, then put 100 for both.
Next you want to set one to Internal port 22 and one to internal port 80 and have the start and end ports the same (100,22,22,22; 100,80,80,80). Leave public interface port alone, and enable both.
Also download WINSCP for FTP to your Raspberry Pi server you are about to create.
If you are using Raspbian, you want to expand the root partition to fill the SD card, else you will quickly run out of room…the default partition when flashing an SD card is somewhere around 55 Mb for the Linux operating system. Xbian does the root partition expansion automatically when it first powers on.
So the next step is to make Raspberry Pi a full fledged server. If using Xbian, use Putty to connect to your Pi (have to have ethernet cable connected). Get away from the setup box by clicking Return. This should bring up the command prompt, looking like xbian@192.168.0.100:~#. You can change the default password, do an update, and install any packages from here. Just Google “Raspberry Pi command prompt” to get an idea how.
So, first install Apache webserver (sudo apt-get install apache2 php5 libapache2-mod-php5). Hit 'y' for yes, wait about 5 min and you should now have your very own webserver at 192.168.0.### from the URL bar), it should bring up the default page “It works!”. You may have to restart the Apache server (sudo service apache2 restart). Change ownership of the folder where html files for your webserver are put (sudo chown -R xbian /var/www).
Install a FTP service to make transfer of files possible from anywhere in the world (sudo apt-get install vsftpd). There are some things you want to change in the configuration file (sudo nano /etc/vsftpd.conf). Scroll down, delete the #(comment out symbol) infront of local_enable=YES and write_enable=YES. Scroll all the way to the end and typle in “force_dot_files=YES”. Hit Ctrl+X,'y',Enter to save. Now you can use WINSCP to connect to your server, use SFTP to connect, default to port 22(I think).
Go to Google and type in “what is my IP address” to get you external IP address to the world. Since you did port forwarding, you can access your webserver from anywhere; to test, turn off wi-fi on your phone and go to your ip address. It is different than the 192.168.0.###. It'd be like 74.##.#.###.
By default, your browser loads the index.html file. You can create more html files, link to them, do whatever you want. Learn a little html programming for use later on. Practice making drop down menus cause this will really pay dividends in a bit. Create radio buttons, check boxes, text enter fields, play with headers, have left justified, center justified, right justified columns, basically just arrange things the way you want. Change background color, font size, button size, etc.
Now comes the great part that makes the Raspberry Pi do truely useful things for you. You want to have Pi communicate through Serial interface to Arduino to do functions on the backside.
Look up the pin layout for the Pi to see the transmit pin and the ground pin. Be careful, as Pi is at 3.3V logic level and Arduino's other than the Due are at 5V logic level.
Transmitting from the Pi and receiving to the Arduino works just fine. Go back to the command prompt. Type in “sudo nano /etc/inittab”. If using Xbian, go to the bottom where it says “TO:….ttyAMA0”. Comment that line out using a # sign. Save and go back to the command prompt.
You want to give yourself dialout access, ie serial output from programs. Type in “sudo usermod -a -G dialout xbian” and “sudo usermod -a -G dialout www-data”. It should give you no problems, then sudo reboot.
Google raspberry pi php serial class. You want your submit buttons affiliated with buttons, dropdown menus, etc to be a POST, which the php script reads and acts on to PUT the posted values onto the Serial transmit line with a selected baud rate, have correct parity, and stop bits.
I would take a look at http://ictoblog.nl/raspberry-pi/arduino … unications.
You want to put the php_serial_class.php file into whatever folder in the www-data folder you want to try doing Pi→Arduino communication.
Create a file.php for each html link or button you have. I can include examples that work if anyone wants them.
So now that Raspberry Pi up and running and sending out data over Serial interface, now what?
Have 2 or more Arduino's and 2 or more Xbee's? Then you are in luck. For one Arduino, connect its Serial1,Serial2,or Serial3 receive pin to Raspberry Pi's transmit pin. Everytime something goes out, the Arduino can read it in.
Using a little programming and string comparison, you can use a little ingenuity to directly address what Arduino you want to do something.
Have the one Arduino connected to the Pi have a Xbee shield that uses the main Serial port (UNO only has one so it is harder to debug). In your PHP script, you can predetermine which Arduino will be addressed.
You can make an html page that can talk to infinite Arduino's, set any of the digital pins HIGH or LOW, analogWrite any of the 13 PWM pins to any value 0-255, digitalRead any of the digital pins, or analogRead any of the analog pins. Just do a “for” loop in the setup to iterate through all of them to initialize them as output.
So how useful is this? Well, get a 2 channel relay from Ebay and a 3 foot power strip, a gang box, an outlet receptacle, some wire strippers, some thermostat wire (for carrying a digital signal), and some electrical tape from Home Depot. Cut the power strip cord as close to strip itself as possible, you just want the cord and prong. If you only have the cord itself for this project, you want a little extra wire for splicing purposes, otherwise get wire that is rated to 15-20A, or is pretty thick gauge. The 2 channel relay will require 4 signal wires (cut two pieces of 2 strand or one piece of 4 strand). These will go to any of the digital pins, plus ground, plus 5/3.33 V. Connect them using a female to female Dupont wire to connect to the Pi's male pins. Splice the Live Wire to go to 2 of the relay terminals. You will one of two types of relays. Either it needs a HIGH signal to close the normally open contact, or it will need a LOW(ground) signal to close the normally open contact. The type matters, any you might need to switch your logic in Arduino to account for this cause if you are trying to control a lamp and Arduino gets unplugged, the lamp might get turned on (or off). I recommend testing this all out before working with 120 VAC. But I leave that up to you. I have had good success with analog magnetic reed style relays. I had a friend who used solid state relays that literally melted when too high of a starting current passed through it. So now that you have an outlet box, you can take the first Arduino and pass the command onto infinite other Arduino's that have similar scripts that each look to see if itself is being addressed, run some string comparisons and act on them. You could quickly scale this to have every lamp or fan in your house controlled from your phone.
If you need any example code or have any trouble, just ask me what you need.
If you have a cool project in mind, let me know!
Good luck and be safe with high voltage.