Saturday, 19 March 2016

Criterion D

Objective D: Evaluating
My Raspberry Pi motion sensor alarm worked as per the design specification. However, the design specification left a few details. The motion sensor detected movement very quickly and after 0.25 seconds, the ‘computer beeps’ sound occurred. Under Sensor block palette, the GPIO sensor value ranged from 0 to 1. Note: This was a test to see whether the GPIO pin 4, connected to OUT pin of motion sensor, would respond when the sensor detects movement.
However, the display connection from Raspberry Pi to Laptop was the hardest part. I used a Wi-Fi dongle to connect Pi to laptop but it wasn’t successful as I needed the monitor to get the ip address and include it in Putty client. Instead, I used an Ethernet cable. I first set up a DHCP server client. Then, I ran the client wizard and configured the settings. I selected the adapter (Ethernet) and gave a fixed ip address: 192.168.2.100 and the range was from 100 to 110. Therefore, it was easier to connect to the device in a swift way. Putty, an application, was used to connect to the device using network protocol SSH (Secure Shell). I entered the ip address and took me to the command line of the Pi where I could issue commands. From here on, I setup a VNC Server by executing command vncserver :1. After VNC server was established, I used VNC Viewer client where I the ip address of the Pi is already given. Then, after logging in, I could see the graphical user interface of the Pi.
 Then it came to the code writing. I used Python 3 DLE software to check whether the motion sensor was working. When it came to writing the code in Python 3 program, I wasn’t able to understand what the code meant. There were always problems regarding incorrect syntax, etc. Here is the correct code below:
(nano pirtest.py)
import RPi.GPIO as GPIO
import time

sensor = 4

GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN)

previous_state = False
current_state = False

while True:
    time.sleep(0.1)
    previous_state = current_state
    current_state = GPIO.input(sensor)
    if current_state != previous_state:
        new_state = "HIGH" if current_state else "LOW"
        print("GPIO pin %s is %s" % (sensor, new_state))
(sudo python3 pirtest.py)
The mistake in this code was that I added nano pirtest.py at the start of the code and sudo python3 pirtest.py at the end. Nano pirtest.py is a command to start the Python 3 program named ‘pirtest.py’ and sudo python3 pirtest.py is a command to run the python file ‘pirtest.py’. I cleared these two mistakes from the code. As a result, the code was run and the motion sensor was able to detect movement.
In this code, we are first setting up the GPIO pins of Pi to see whether they will allow us to use pin 4 as an input; then it can detect once PIR module sends power. Therefore, we use a while True loop to check the pin continuously for any changes to be made. This is an infinite loop which can be stopped using Ctrl + C. Then two Boolean variables (a variable (motion sensor) that can have two possible values), that is True (1) and False (0), for the previous and current states of the pin. Inside this loop, we also want to compare the previous state to the current state when they are different.
Finally, the creating of the code sequence in Scratch. Here to I experienced difficulties when using block palettes (where were the specific blocks located?). I researched on the internet and found out. First, I started GPIO server which will locate the pin 4 of the GPIO header of Pi. Then, in the control block palette, I clicked and dropped broadcast block into the script. In the block, I typed config4in and double-clicked the block. This shows that pin 4 will be used as an input by configuring it. Under the sensor block palette, I click the drop-down menu on Sensor block and choose GPIO 4. In addition, I ticked the checkbox to display on screen. By doing this, you can also check whether the motion detects movement by examining the value on the screen change from 0 to 1. Then, I added a sprite and included the following code sequence for that particular sprite. Here is the code sequence:
 

·         It makes the sprite appear out of nowhere and increases its size once movement is detected. If there is no movement, the sprite diminishes and disappears.
·         After 0.25secs, the ‘whoop’ sound is played.
Feedback from a friend, Alberto:
"Good try and useful product.  Remote configuration should be done so that it can be installed in houses, inside the front door, when the residents are out of town."
Improvements:
·         An easy step by step instruction manual for setup of the system.
·         Add an ultrasonic rangefinder so that when movement is located through echolocation, the alarm will immediately occur.
·         Add a method of accessing Pi through laptop into the instruction manual.
·         Add an additional feature such as a solderless breadboard where circuits can be built and others such as LED’s, resistors, etc. which are also used to alarm the users.
·         Use longer jumper wires when installing in various places of the house (doors, windows, etc.)
Due to this alarm, users can be more alert and prepared when an intruder enters the house.
Strengths
Weakness
·         Comes with a step by step instruction manual for the setup of the Raspberry Pi system.
·         Can detect movement immediately and the alarm comes in the form of sound.
·         The code or code sequence can be edited according to the user’s perspectives.
·         Low power consumption.
·         Has a low cost.
·         You can use it as a troubleshooting tool.
·         Can open some applications without the internet.
·         Due to its independent network connectivity, you can set it up using SSH or transfer file via FTP.
·         The Linux operating system makes it easy for pi to be used as a media streamer, video game emulator, etc.








·         Jumper cables, micro USB power adapter wire and Ethernet cable are too small. Therefore, it might cause problems for installation in different places of the house.
·         Not waterproof.
·         If it is connected to a high source of power, then it may overload or malfunction.
·         In addition, randomly plugging in wires in different pins of the GPIO header may kill Pi.
·         Due to its processor, it cannot run x86 operating systems such as Windows and Linux distros.

Tuesday, 23 February 2016

Criterion C (Creating the product)

Criteria C – Creating the Solution

A flowchart showing how the product will be made:


Materials:
·         HDMI Cable: To transfer data to be displayed on the monitor.
·         Female to Female Jumper Wires: Used to connect to external devices.
·         PIR motion Sensor: Sensor that detects movement
·         Raspberry Pi (model b): A mini computer 
·         Ethernet cable: Connect one device to another so the internet can be shared. 
·         USB keyboard and mouse: USB used to connect to keyboard and mouse.
·         SD card and adapter: Stores data. Put into adapter for accessibility on computer. 
·         Protective case for raspberry pi: To protect raspberry pi.
·         TV or HDMI monitor: To display the output. 

Software:
·         Raspbian
·         SD formatter
·         NOOBS
·         Python 3 DLC Programming

Creating the product (step-by-step process)
Steps
Parts required
Description
Date
Time taken
Assemble a protective for my Raspberry Pi Model B
·         Opaque plastic case
·         Raspberry Pi Model B
Disassemble the case. Put the Raspberry Pi inside and put the parts all together.
3rd February
5min
Install NOOBS
file into Raspberry Pi
·         SD Formatter (in computer)
·         SD card
·         SD card adapter
·         NOOBS file (in computer
Go to raspberrypi.org site and download NOOBS file. Go to sdcard.org site and download SD formatter program. Place SD card inside card adapter. Put it in the SD card reader of the computer. Format file and extract NOOBS files into the SD card.
5th February
20min (extra 1hr for installation of NOOBS file and 5min for SD card Formatter program)
Make all connections from the circuit board to the TV or Monitor
·         Ethernet cable (if you want to use any other operating system)
·         HDMI cable
·         USB keyboard and mouse
Attach USB (for keyboard and mouse) into the USB port of the circuit board. Connect HDMI cable (and/or Ethernet cable) to TV or Monitor.
6th February
5min
Then, connect the power adapter to the board.
·         Micro USB power adapter
Attach the power adapter to the board. It will be supplied with power and will start to boot.
6th February
5min
Select operating system and install it
-
Choose an operating system and it will start installing. After that, you change details such as preferences, network, etc.
6th February
30min
Search extra parts for alarm
Internet
Search the internet for a PIR motion sensor and female to female jumper wires for alarm
7th February
1 day (for delivery)
Connect the raspberry pi to the PIR motion sensor
·         PIR motion sensor
·         Female to Female jumper wires
For the GPIO header of the circuit board, connect the 5V pin to the part labelled VCC on the sensor, GPIO pin 4 to OUT and GND to GND.
9th February
5min
Boot the Pi software into TV and write the code for movement detection
Python 3 DLE
Go to Python Software in order to write a program for movement detection. Run the code and check whether is functioning properly. If pin is HIGH, it means there is movement. If it is LOW, there is no movement.
9th February
30min
Add any other improvements
PIR motion sensor
Adjust sensitivity and detection time by using the potentiometers in the motion sensor.
7th March
40min
Create a program sequence in Scratch for movement detection (Additional)
Scratch
First, start GPIO server. Then, double-click background stage. In the script section, take a “broadcast” block palette from Control. Type in the box, config4in. This shows that the OUT pin of the motion sensor is configuring with GPIO pin 4. After this, select a sprite and create a program sequence where it will appear enlarged and sound will emerge when movement is detected.
8th March
16mins

Screenshots for my project:



In this picture, I am assembling my parts for the setup. Here are some parts: USB keyboard and mouse, raspberry pi + (model b), USB power adapter, HDMI cable, SD card, SD card adapter and ethernet cable. 



Here, I am assembling the case for raspberry pi. First, I disassemble the covering of the case. Then, i place the raspberry pi inside and lock in place with the disassembled case and cover with lid. 


Here are my SD card and SD card adapter. I put the SD card inside the adapter into the adapter so it can be accessed on the computer.



On the computer, I am downloading a NOOBS file so that it can be preloaded into the SD card. Then, I extract the files from the NOOBS file to the SD card. After that, I will remove the micro SD card from the adapter and put into micro SD card slot in the Raspberry Pi. 


The diagrams above show how the program will be carried out. Firstly, I make all connections from circuit board to TV. I connect the HDMI cable and the USB keyboard and mouse. In this project, i didn't add an Ethernet cable, however, it isn't necessary. Then I supply power to the board using a micro USB power adapter and it will boot on the TV. Then an option bar will occur telling which one to select. I selected Raspbian and downloaded it. Here is the program above.

However, I used another method instead of the HDMI monitor or TV. I connected the Pi to laptop using direct network connection.


Firstly, I ran the DHCP Server Wizard. It presented a list of all the devices that are connected to the Wi-Fi network. I selected the Ethernet (connecting raspberry pi to laptop) with an ip address 192.168.2.1. The goal of this server is to assign a fixed ip address to the device.



In the IP Pool, I changed the range of the ip address from 100 to 110. This way it will swiftly locate the device and connect to it.


d
In the Putty application, I entered the ip address of the Pi (after setting up a fixed ip address through DHCP Server Wizard). Putty is an open-source terminal emulator which supports network protocols such as  SCP, SSH, Telnet, rlogin and raw socket connection. Here, it uses Secure Shell network protocol (SSH). This will direct me to Pi's command line where I can execute commands.

After getting access to the command line of the Raspberry Pi, I set up a VNC server by using this command: vncserver :1. This server can then be found by other devices using a VNC viewer client. Virtual Network Computing is used to display a device's desktop display on another device.


In VNC viewer client, I entered the ip address as 192.168.2.100:1. I wrote :1 because the Ethernet is connected to port 1 through the computer. I entered my password and got access to raspberry pi's desktop as shown above.



Finally, I created my code sequence in Scratch. First, I started the GPIO Server. Then, in the Sensor block palette, I clicked GPIO 4 and the checkbox. It was displayed on the background. I then created the code sequence for the Robot sprite. This sequence's aim was to make the sprite appear immediately once movement was detected. In addition, the computer beeps sound was added to signal the person that there is an intruder. If there was no movement detected, the sprite would disappear and the sound would stop.


Gantt Chart:




Thursday, 28 January 2016

Criterion A (Inquiring and Analysing)


Criterion A (Inquiring and Analyzing)


Introduction: 

In this project, I am going to create a technological invention for showcasing at the Tech Fair. I am deciding on what to create for my project. These are my ideas:

  1. I am going to create an electronic alarm for this idea. I will be creating this in order to show how the alarm works and how it is beneficial to the community in terms of security. This project idea is made by assembling the parts from the Raspberry Pi Projects Kit. It consists of a tiny computer called Raspberry Pi where you can write computer programs, build simple circuits, etc. This Projects Kit is not only used for making alarms. As your ideas become stronger, you will be able to create more extraordinary projects. 
  2. My second idea is to build an all-terrain vehicle (mini). Many people have problems when travelling on different terrains. This project will also be built to show how all- terrain vehicles travel on different terrains using special wheels. This will be built by using the Lego Mindstorms Kit which consists of a programming block called the NXT Brick. 

Chosen Project: Electronic Alarm. Since this is the first time I will be creating a project, I want to start with something interesting, involving circuit boards, LED's, etc. 



Introduction (Electronic Alarm): 

I am going to create an electronic alarm for this idea. I will be creating this in order to show how the alarm works and how it is beneficial to the community in terms of security. This project idea is made by assembling the parts from the Raspberry Pi Projects Kit. It consists of a tiny computer called Raspberry Pi where you can write computer programs, build simple circuits, etc. This Projects Kit is not only used for making alarms. As your ideas become stronger, you will be able to create more extraordinary projects. I will be using the Raspberry Pi Kit. This kit contains the basic knowledge of computer programming and electronic skills in which a person can use sensors, lights, sounds, images, etc. to create interactive, innovative projects.

I will be creating this for my community, The Greens. They require the use of inbuilt alarms in their doors, safes, etc. so that no thief can steal anything and will be exposed at once it is triggered. Even though Greens has a high level of security, thieves are still able to enter. They finally had enough and decided to call me to deal with this threat. In order for this to happen, I must consult with the manager of the community for the allowing of the installation of these alarms in people's houses. In addition, I will also do an interview with a resident on how the overall performance of the product was. 

Examples of the applications of the Raspberry Pi includes making a video game, wirelessly control your stereo, wireless extender, etc.





Primary and Secondary Research:

Primary Research
Secondary Research
I will interview the manager of the community, The Greens, for the installation of alarms.
I will research about Raspberry Pi and the common examples using this circuit board.
I will interview a resident on the overall performance of the invention.
I will research on how to create different projects using Raspberry Pi.
I will read books and other literary sources on computer programming.
I will check the prices of this Kit on the internet.



Research Plan:

Task
Primary Research/Secondary Research
Reason for the research
Date
Raspberry Pi setup



Get the Raspberry Pi (Model b) Kit
I will go to the computer market and gather the parts required to build the project. Or I might buy the whole kit on the internet which will be better as an alternative but will cost more than the one in the market.
I want these parts so that I can build my project. I can also search for extra parts that will further enhance my invention.
25th January
NOOBS (New Out of the Box System)
I will check on the internet on how to install the NOOBS file into my SD card.
By installing this system, I will be presented with a variety of software from which I can download.
2nd February
Displaying the Graphical User Interface
I will check on the internet on how to connect the Pi to the HDMI monitor or TV.
When the Pi boots into the device, I will be presented with a variety of software or a software to download. After the download, I can then view the GUI of Pi.
3rd February
PIR Motion Sensor Alarm



Connect Pi to PIR Motion Sensor
I will check on the internet to find out what wires are used to connect them to each other and to which specific GPIO pins.
The GPIO pins are a physical interface between Pi and any other device. In the 26 pins, 17 are GPIO while the rest are power or ground pins. These pins conduct power to the motion sensor. Therefore, we have to make sure that motion sensor is connected to the specific GPIO pins using female-female wires.
13th February
Build the Python script for alarm
I will check on the internet to find the code used for programming the alarm.
Once the code is found, I will run it and see whether it is working. The OUT pin of the motion sensor is connected to GPIO pin 4 on the Pi. So we need to check if this pin has power. If the pin has power, it is known as high or low if it doesn’t have. From this, I will then set up the Raspberry Pi GPIO pins which will allow me to use pin 4 as an input; it can then detect movement when the PIR module sends power.
14th February
Scratch
I will check on the internet on how to use the different commands on Scratch to create a code for the alarm.
This is additional method where I am going to use sound. Once the alarm detects movement, the chosen sprite will appear and sound will emerge.
15th February





SWOT Analysis:

Strengths:

·               Can detect the lightest of movements.
·               Can easily be installed in people’s homes.
·               Easy to set up with step by step instructions.
·               Can be connected using Ethernet and Wi-Fi dongle.


Weaknesses:

·               Not waterproof
·               Sometimes, there can be a malfunction.
·               Kit used to build it is expensive.
·               Through Ethernet, lots of steps are required. 
Opportunities:

·               A free discount voucher.
·               Water bottle as well as a Raspberry Pi T-shirt.
·               Comes with a free Wi-Fi Dongle.

Threats:

·               If wet, avoid being electrocuted.
·               Keep small parts away from infants.
·               Do not connect LED’s, etc. to any high voltage pin. If done, the Pi may malfunction and LED will not work.


 Design Brief:

·               Linux based computer, Raspberry Pi, which can create not only alarms but others such as games, word processing, computer programming, etc.

·               An alarm computer program code can be written on the computer to activate it.

·               Can be easily connected to the Internet using a Wi-Fi dongle or Ethernet cable.

·               Low cost device in which the person can install easily using the manual.

·               An alternative to a computer or laptop which requires low power consumption.

·               Consists of 256MB of RAM, 4 USB ports, 1 Ethernet port, 1 A/V display, GPIO Header, HDMI Port, Camera display, Micro-USB power supply port and a SD card slot.

·               Includes programs such as Mathematica, Python 2 and 3 DLE, Wolfram, etc. where lots of computer programming can be done.

·               An lx terminal where you can execute commands.

·               The motion sensor, when detects movements, gives a range between 0 to 1. If 0, means there is no movement whereas if 1, then it has movement.

·               Motion sensor has potentiometers where we can adjust the sensitivity and detection time.








Interview:

I have also conducted an interview with a resident, Richard James, on what the features of the product should be. Here is the full interview:

Q1) In your opinion, what features must an alarm have?

Ans) An alarm should make big sound, should continue making the sound till it is stopped, and should respond to the signal promptly.

Q2) If a robbery has been conducted, mention from where did they enter?

Ans) From the main door

Q3) What alarm style do you want to have, beacon, by the seaside or chimes? If you want to choose any other, mention.

Ans) I am indifferent to the sound but it should be loud and I should feel like stopping it immediately.

Q4) Do you require a manual on how to install and activate it?

Ans) Yes, that will be very useful.

Q5) What extra items do you want to come along with this product?

Ans) A motion sensor camera which can take pictures even in darkness

Q6) Do you want to give any more ideas that we can add in this product?

Ans) The sound should become louder after every one minute