-
Notifications
You must be signed in to change notification settings - Fork 3
RaspberryPi Setup
To follow these setup instructions you need a Raspberry Pi, an SD card, and the 6LoWPAN device.
This is a run down of necessary steps to take to get the Raspberry Pi properly setup to work for the SmartWindow project. We need to install a proper OS (Raspbian) on the Pi, build a new kernel for our Pi to work with the 6LoWPAN radio, install a MySQL Database as well as some mysql client libraries, and install Flask for our web server.
- Download and install the latest version of Raspbian
- Follow one of the guides to flash the downloaded image to an SD card from your OS (Linux, Mac OS, Windows)
Follow this [How-to] (https://github.com/RIOT-OS/RIOT/wiki/How-to-install-6LoWPAN-Linux-Kernel-on-Raspberry-Pi) on setting up the RasPi and building a new kernel to work with the 6LoWPAN device.
Once Raspbian is installed and our RasPi is running the new kernel, the lowpan device needs to be setup every time the Pi boots. We followed the instructions of the already mentioned How-to and from that put together our own script, see SmartWindow/RaspberrPi/setupLowpanInterface. In /etc/rc.local
add the following line anywhere before exit 0
to run the script on startup:
/<path>/<to>/<script>/setupLowpanInterface
The script sets up the lowpan device's channel to 26 and pan id to 0x23. Note that these settings must match on all nodes for network communications to work properly.
To install the mysql server run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server
When prompted enter a secure root password. We will need it for our web server to get access to the database later on.
To access the MySQL database from a C-program we need to install mysql client libraries, these will be used by our window controller program.
sudo apt-get install mysql-client
We can now log on to the database (note: there is no space after -p
)
mysql -h localhost -u root -p<yourpassword>
When successful we can now use SQL commands to navigate the database, for example:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
To create all the necessary tables for use with our web server we provide a .SQL file that includes all the SQL commands to correctly setup those tables. Once downloaded it can be used as follows:
mysql> source /<path>/<to>/<sqlfile>.sql
To install python flask run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
sudo pip flask
To install database libary run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-mysqldb
We can now use python scrips with database connection. An script could be run with the following statement:
sudo python Webserver.py