Tuesday, 19 February 2013

Python Command Code Scripts


Below are the Python command code scripts, the theory is that when a command is pressed on a handheld mobile device a certain sequence of script(s) will run thus executing the command given a distance away over a wireless network.

GPIO_SETUP:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(3, GPIO.OUT)
GPIO.setup(5, GPIO.OUT)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)

GPIO_3_HIGH:
import RPi.GPIO as GPIO
GPIO.output(11, GPIO.LOW)
GPIO.output(7, GPIO.LOW)
GPIO.output(5, GPIO.LOW)
GPIO.output(3, GPIO.HIGH)

GPIO_5_HIGH:
import RPi.GPIO as GPIO
GPIO.output(3, GPIO.LOW)
GPIO.output(11, GPIO.LOW)
GPIO.output(7, GPIO.LOW)
GPIO.output(5, GPIO.HIGH)

GPIO_7_HIGH:
import RPi.GPIO as GPIO
GPIO.output(3, GPIO.LOW)
GPIO.output(5, GPIO.LOW)
GPIO.output(11, GPIO.LOW)
GPIO.output(7, GPIO.HIGH)

GPIO_11_HIGH:
import RPi.GPIO as GPIO
GPIO.output(3, GPIO.LOW)
GPIO.output(5, GPIO.LOW)
GPIO.output(7, GPIO.LOW)
GPIO.output(11, GPIO.HIGH)

GPIO_RESET:
import RPi.GPIO as GPIO
GPIO.output(3, GPIO.LOW)
GPIO.output(5, GPIO.LOW)
GPIO.output(7, GPIO.LOW)
GPIO.output(11, GPIO.LOW)

Project Week 3

Project week three started in disaster as the SD memory card of the Raspberry Pi has once again corrupted on start-up right at the start of the day. It was not until approximately three hours later, that we were back to where we finished on project week two. For the rest of the day we tried to install and configure Apache2 on the Raspberry Pi which allows us to create a web-server for the Raspberry Pi. We started off great during the installation as every command worked however, we began to go round in circles once Apache2 was installed and was configuring it. Soon we just got lost in the maze of sub-system commands. We tried restarting the system and begin the procedure again but again no hope as anger and frustration builds. On the other hand, the Python command code scripts were written and typed up.

Tuesday, 12 February 2013

Project Week 2 Timetable

After project week two this is where we stand in terms of our timetable:


As shown in the timetable after project week two, we are still on track and well on our way to complete our project on time. In the upcoming project week three we will try and install Apache2 which allows us to create a web-server on the Raspberry Pi. We also aim to type up some Python command scripts that when connect and a command is given from a website on a handheld mobile device, that script will be called up and run. If we are ahead of schedule in project week three, we will try and connect the whole system together and begin initial system test.

GPIO Install / Configuration Code

Below was the code used to download, install and configured the GPIO ports which allows us to program the GPIO ports using the official Raspberry Pi programming language - Python.

First open the "LX Terminal" which can be found at the desktop and then enter the following code:

sudo apt-get update
# downloads the latest updates #
sudo apt-get install git
# install specific update, the software: git #

git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
# collect a collection of codes from this website directory using the software just installed: git #
cd Adafruit-Raspberry-Pi-Python-Code
# enter into that directory #
ls
# confirm #

When prompted to confirm, enter "Y"

Exit LX Terminal before opening it again and enter:

sudo apt-get update
# downloads the latest updates #
sudo apt-get install python-dev
# install specific update, Python Development Toolkit #
sudo apt-get install python-rpi.gpio
#  install specific update, which allows us to program the GPIO ports in Python #

When prompted to confirm, enter "Y"

The GPIO were setup and configured, ready to be commanded by programming each port using Python.

Project Week 2

Project week two started fantastically, with the wireless internet set up in no time as shown figure 1 below.

Figure 1: Successful configuration of wireless internet

Then within an hour of programming the general purpose input/output pins (GPIO) using the official Raspberry Pi programming language - Python. After installation and configuration of the GPIO pins, they were tested as we picked two random pin (11 and 8) and typed in a simple Python command script to switch on a LED on and off as shown in figure 2 and figure 3 below.

Figure 2: A simple command script to turn on and off a LED at pin 11

Figure 3: GPIO pins test after configuration successfully switching a LED on and off

We then moved on to install Apache2 which allows us to create a web-server for the Raspberry Pi to receive information or commands from a certain website. However, during the installation process, the SD memory card which acts like a computer hard drive was corrupted. We tried to reboot the memory card but failed. We spent nearly two hours to download a new Raspian Wheezy operating system as well as installing it onto the formatted SD memory card. We then had to re-install everything we done in the past two weeks, and by the end of project week two we where back in business as GPIO pins were again configured. For the upcoming project week three, we will try to install Apache2, type up Python code scripts for the server to run upon command from a website and maybe even start testing the communication link between the web-site on our handheld mobile devices and the Raspberry Pi's web-server.

Thursday, 7 February 2013

Project Timetable

Prior to the start of project week one, we have created a simple Gantt chart to help keep ourselves on track as well as to illustrate our current progress. As shown in the screenshot of our timetable below after week one of the project week, we are pretty much on target as predicted.


Project Week 1

In the first week of the project, we have received and inspected all the parts and components ordered before the Christmas holidays. Everything were working with no defects or missed items, everything were in place to start. Embodiment of parts where necessary such as soldering the Raspberry Pi cobbler breakout kit were completed in no time.


Then the Raspberry Pi was connected to the necessary peripherals.



The Raspberry Pi was ready for its initial start-up.


Upon initial start-up, basic setup procedure was completed along with installation of new updates as well as the installation of the necessary software packages and hardware also such as the wireless dongle.

As the day draws to an end on project week one, me and my project partner discussed our plans for the following project week two where we will be doing some hardcore programming.