GettingStarted

From RasPiConnect/ArduinoConnect
Jump to: navigation, search

RasPiConnect Home

Contents

Getting started

RasPiConnect

Setting up the RasPiConnect App

1) Go to the Apple appstore and download the RasPiConnect app for your iPad / iPhone

2) Open the app and you will see the demo page. Hit the green Refresh Button. The controls will change.

3) Setup the RasPiConnectServer on your Raspberry Pi (as shown below)

4) Test the app as shown in the Testing section below

Setting up the RasPiConnectServer

1) Get the latest packages and kernel for your Raspberry Pi (Assuming you are using the Raspian distribution) Updating Packages

sudo apt-get -y update && sudo apt-get -y upgrade

2) install easy_install (included in python-setuptools)

sudo apt-get install python-setuptools

3) Install web.py on your Raspberry Pi

sudo easy_install web.py

4) Install git on your Raspberry Pi

sudo apt-get install git-core

5) Download the RasPiConnectServer from github and install it on your Raspberry Pi

cd /home/pi
 
git clone git://github.com/milocreek/RasPiConnectServer

6) Edit the Config File

(note the capital "C" on Config.py)

cd /home/pi/RasPiConnectServer/config
 
 
nano Config.py

Now edit the Config.py file

#!/usr/bin/python
# Filename: Config.py
# Version 1.3 04/22/13
 
# set to True if you wish to see debugging output from the server otherwise False
DEBUG = False
 
#WEB_SERVER_PORT is the port that the RasPiConnect Webserver will be responding to requests from the RasPiConnect App
WEB_SERVER_PORT = "9600"
 
#LOCALURL is the address of your pi. If you poke a hole through your firewall and expose it to the Internet, insert that address here
#Usually, the port in the URL (9600) will match the WEB_SERVER_PORT above but can be remapped in most routers/firewalls
LOCALURL = "http://192.168.1.120:9600/"
 
 
#USERNAME is the username that you have entered in the RasPiConnect App.  It must match and is case sensitive
USERNAME = "RasPiConnect"
 
#PASSWORD is the password that you have entered in the RasPiConnect App.  It must match and is case sensitive
PASSWORD = "RasPiConnectPassword"
 
# set to True if you have an I2C bus set up and has an AdaFruit BMP085 and two BlinkM modules (addresses 0xC and 0xB) False if not
I2CDEMO = False
 
#RASPICONNECTSERVER Version Number.  Do not change!
VERSIONNUMBER = '2.4'
 
def localURL():
        return LOCALURL
 
def password():
        return PASSWORD
 
def username():
        return USERNAME
 
def web_server_port():
        return WEB_SERVER_PORT
 
def version_number():
        return VERSIONNUMBER
 
def debug():
        return DEBUG;
 
def i2c_demo():
        return I2CDEMO;


7) Start the RasPiConnectServer

Starting the RasPiConnect Server

There are three ways of starting the RasPiConnect server:

Running from the command line
cd /home/pi/RasPiConnectServer
sudo python RasPiConnectServer.py

For the RasPiConnectServer to continue working, the terminal window must remain open.

Running in the background from the command line
cd /home/pi/RasPiConnectServer
nohup sudo python RasPiConnectServer.py &

This runs the RasPiConnectServer in the background and the "nohup" means that it will continue running even if you terminate the terminal or log out. Output from the RasPiConnectServer will be placed in the same directory in a file "nohup.out"

Running RasPiConnectServer on startup

/etc/rc.local is a script on the Raspberry Pi which runs when Linux first boots. To edit it, you will need root privileges:

sudo nano /etc/rc.local

and add to the file (before the exit 0 statement):

date >> /var/log/RasPiConnectServer.log
 
echo "Starting RasPiConnectServer..." >> /var/log/RasPiConnectServer.log
 
nohup sudo /home/pi/RasPiConnectServer/startserver.sh >>/var/log/RasPiConnectServer.log 2>&1 &

Error: web.py module not present

If you receive an error like this from RasPiConnectServer:

Traceback (most recent call last):
    File "RasPiConnectServer.py", line 22, in <module>
        import web
ImportError: No module named web

Then you don't have web.py installed. Run the following commands:

sudo apt-get install python-setuptools
sudo easy_install web.py

If you aren't running Raspian, then take a look at additional installation options at http://webpy.org

Testing

Testing the RasPiConnectServer

To test that your RasPiConnectServer is running correctly, do one of the following:

On your Raspberry Pi, type into a web browser:

http://localhost:<Your port number>/Version
 
example:  http://localhost:9600/Version

OR

On another computer (on the same local network), type into a web browser

http://<your IP Address>:<Your port number>/Version
 
example:  http://192.168.1.130:9600/Version

To find out your local IP number type:

ifconfig

If you see "RasPiConnectServer Version X.Y", then you are successfully running the RasPiConnectServer

Testing the RasPiConnect App

1) Make sure you are running the RasPiConnectServer and it passes the above test

2) Go to the Settings Tab on the RasPiConnect App and make sure that the Username and Password match the Username and Password in the RasPiConnectServer

3) Add a System URL pointing to your Raspberry Pi (including port number), making sure you append the "raspi" to the end ( example: http://raspberry.example.com:9600/raspi )

4) Go to the Settings Tab -> Server Report

The line corresponding to your Raspberry Pi should have a green LED indicating a connection was successful

5) On the initial Demo page, go to the Panel Setup Tab and change the "Server Status" control to point to your added System URL

6) Hit Refresh on the Control Panel Tab and your indicator should change to Green.

ArduinoConnect

Setting up the ArduinoConnect App

1) Go to the Apple appstore and download the ArduinoConnect app for your iPad / iPhone

2) Open the app and you will see the demo page. Hit the green Refresh Button. The controls will change.

3) Setup the ArduinoConnectServer on your Arduino (as shown below)

4) Test the app as shown in the Testing section below

Setting up the ArduinoConnectServer

1) Download the ArduinoConnectServer from github and install it on your host computer


2) Edit the Config.h File

(note the capital "C" on Config.h)

// Filename: Config.h
// Version 1.5 08/06/13 BP MiloCreek
 
// your local function include file
// ----------
// Note:  This program is designed for you to supply your own functions in a file called Local.h
// Out of the box, the program uses LocalExample.h included in ExecuteJSONCommand.h
//
// If you change LocalExample.h and update the software, LocalExample.h WILL BE OVERWRITTEN!
//
// Change #define LOCALFILE "LocalExample.h" to #define LOCALFILE  "Local.h" to #include "Local.h" in ExecuteJSONCommand.h
// ----------
#define LOCALFILE "LocalExample.h"
 
//define if you want debug on, otherwise #undef
#undef DEBUG
 
//define if you want to only debug local files, otherwise #undef
#undef LOCALDEBUG
 
//WEB_SERVER_PORT is the port that the Arduino Webserver will be responding to requests from the RasPiConnect/ArduinoConnect App
#define WEB_SERVER_PORT 9650
 
//LOCALIP is the address of your device. If you poke a hole through your firewall and expose it to the Internet, insert that address here
//Usually, the port in the URL (i.e. 9600) will match the WEB_SERVER_PORT above but can be remapped in most routers/firewalls
//Note that the address for your SystemURL in the RasPiConnectApp/ArduinoConnectApp should be of the form:  http://192.168.1.120:9600/arduino 
// (see manual for more information)
 
#define LOCALIP  { 192, 168, 1, 177 }
 
// LOCALMAC must be a unique value on your network.  Do not have two Arduinos as the same MAC on a network
#define LOCALMAC { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }
 
 
//USERNAME is the username that you have entered in the RasPiConnect App.  It must match and is case sensitive
#define USERNAME "RasPiConnect"
 
//PASSWORD is the password that you have entered in the RasPiConnect App.  It must match and is case sensitive
#define PASSWORD "RasPiConnectPassword"
 
// set to True if you have an I2C bus set up and has an AdaFruit BMP085 and two BlinkM modules (addresses 0xC and 0xB) False if not
#define I2CDEMO FALSE
 
//ARDUINOCONNECTSERVER Version Number.  Do not change!
#define VERSIONNUMBER  "1.6"

3) Compile and download the sketch into your Arduino. If you are watching the Serial display screen, you will see the webserver startup much like this:

ArduinoConnectServer 1.6 08/23/13
Compiled at:18:49:00 Aug 23 2013
ip address = 192.168.1.177
port number = 9650
mac address = 0XDE 0XAD 0XBE 0XEF 0XFE 0XED

Testing

Testing the ArduinoConnectServer

To test that your ArduinoConnectServer is running correctly, type into a web browser

http://<your IP Address>:<Your port number>/
 
example:  http://192.168.1.130:9600/


If you see "{"OBJECTTYPE" : "" "OBJECTID" : "", "ERROR" : "Username or Password Mismatch" }", then you are successfully running the ArduinoConnectServer

Testing the ArduinoConnect App

1) Make sure you are running the ArduinoConnectServer and it passes the above test

2) Go to the Settings Tab on the ArduinoConnect App and make sure that the Username and Password match the Username and Password in the ArduinoConnectServer

3) Add a System URL pointing to your Arduino (including port number), making sure you append the "arduino" to the end ( example: http://raspberry.example.com:9600/arduino ), making sure the Destination is set to "ArduionJSON"

4) Go to the Settings Tab -> Server Report

The line corresponding to your Arduino should have a green LED indicating a connection was successful

5) On the initial Demo page, go to the Panel Setup Tab and change the "Server Status" control to point to your added System URL

6) Hit Refresh on the Control Panel Tab and your indicator should change to Green.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox