Skip to content
Ioannis Papapanagiotou edited this page Apr 4, 2016 · 5 revisions

Raspberry Pi Configuration

Raspberry Pi

alt text

Raspberry Pi is the actuator for the “Internet of Things” system. The Raspberry Pi will initiate the devices once a user is in a specific location. It will be running a python script that will be continuously checking the database to see if the server has sent a flag indicating that the user is in a specific location.

Instructions:

1.) Connect the WiFi Dongle to the Raspberry Pi

2.) Turn on the Raspberry Pi

3.) Download the QueryDatabase.py script

4.) Download the WeMo.py script

5.) Download the mp3 and mp4 files that you want to play

6.) Put these files into a directory and ensure lines 70 and 85 (found in QueryDatabase.py) are correlating correctly with the names of the mp3 and mp4 files

7.) Change wemo1ip and wemo2ip (lines 30 and 31 of QueryDatabase.py) to the current IP addresses of your WeMo switches

8.) Run the QueryDatabase.py script with username and password of your Cloudant Database

CloudantDB

IBM Cloudant Database is what we used as our means of communication between devices. It allowed us to seamlessly integrate the Raspberry Pi into the system without direct communication to the Raspberry Pi. Through HTTP POSTs and HTTP GETs, our system became fully capable to do what we like to do.

Setting Up

After you have created a Cloudant Account, you can start creating a database.

To integrate easily into the Server code’s POSTs and Raspberry Pi code’s GETs, follow the following steps:

  1. Click on the Database Tab

  2. Click Create Database

  3. Name the Database “microlocation”

  4. Now, under All Documents, you can click the + sign where you can add new documents

  5. Cloudant will generate a randomized name for your new document. Instead of this randomized name, change it to “ThingsParameters”

  6. Now add entries for the “Things” you would like to interact with

alt text

Note: Current Server Code (interactiveRoom.java) and Raspberry Pi Code (QueryDatabase.py) use above entries to interact with “Things”. Before continuing make sure you add these entries into your Cloudant Document.

End to End

The IoT end-to-end solution provided uses the Raspberry Pi's ability to interact with HDMI via a technology called HDMI-CEC. This solution is often used for media devices such as HTPCs or smart devices such as LG's bluray players. Some manufacturers call it "Simple-link". Any Raspberry Pi has support for the technology as long as the proper packages are installed in the OS. In this example, the OS is Raspbian.

Requirements for Raspbian

  • 4GB SD Card
  • PC or Mac
  • Raspbian Image - Not to be confused with NOOBS

Installation for MAC

Installation for Windows

Once installed on the SD card Raspbian can be installed following another guide or just running through the prompts.

Installing HDMI-CEC on Raspberry Pi

  • Clone the open-source CEC library git clone https://github.com/Pulse-Eight/libcec
  • Install extra packages for building sudo apt-get install gcc liblockdev1-dev autoconf automake libtool
  • Build the actual package cd libcec ./bootstrap ./configure --with-rpi-include-path="/opt/vc/include" --with-rpi-lib-path="/opt/vc/lib/" --enable-rpi make sudo checkinstall sudo ldconfig

Using the Raspberry Pi script

  • Copy the tv.sh script to the raspberry pi and use chmod a+x to set to execute permissions.
  • To run the script simply execute as follows ./tv.sh (on/off/input). Your mileage way very due to varying HDMI-CEC support between different manufacturers.

Clone this wiki locally