Monday, April 6, 2020

WEEK 8- Design casing for project

Date: 1 April 2020

OBJECTIVES:

-To make a design casing for my project.  

CONTENT/ PROCEDURE:


For the design, my plan is combine casing of Pi camera, Raspberry pi and flexible tripod to be one model. To overview my project model, i use Auto cad to draw my model in 3D. Purpose i use flexible tripod for my model is to put it in a high place in the barn. 

 Daisen tech Octopus Style Portable and adjustable Tripod Stand ...

Parts to be purchased for design models:

Casing Raspberry Pi (RM 19.20)
Casing Pi camera (RM 10.85)


Flexible tripod (RM 21.03)


RESULT & ANALYSIS:

Overview design 3D model for project by using Autocad:

CONCLUSION:

As a conclusion, i had order online all the item. After the item received, i will combine it to be one model then go to test this project at the barn to see and get it result.

Sunday, April 5, 2020

WEEK 7- Test coding project with component

Date: 25 March 2020

OBJECTIVE:

- To test the coding with component and see it result.

CONTENT/ PROCEDURE:

Adjust Default Settings in Your Gmail

By default, Google does not allow you to send emails containing Python code. To update this default setting, turn on “Allow less secure apps” in your account settings with the following steps:

  1. Login to your Gmail account by entering your login credentials.
  2. Click on your profile picture and then click on “Google account”.
  3. Under “Sign-in and Security” click “Connected apps and sites”.
  4. Click “Allow less secure apps” to turn it on.


Connect the Sound Sensor to the Raspberry Pi


Connect the VCC and GND pins of the motion sensor to the 5V and GND of the Raspberry Pi, then connect the OUT pin of the sound sensor to GPIO17. Make sure that you connected the camera to the Raspberry Pi and have turned on on the camera from the interfacing options.



Before running the code, make sure the sender and receiver email addresses and the password of the email sender are all entered.
The code will read the output from the sensor and, upon detecting sound, will capture an image and save it on the database folder.
When you run the code for the first time, it will automatically create the folder. Once the camera captures an image, the image will be attached in the email and sent to the sender’s address.

RESULT & ANALYSIS:

After run the code, we can see that "No intruders" has been display at python because it did not receive any signal from sound sensor.


Next, if we make a sound, it will give an interrupt signal to sound sensor and we can see it display "Intruders Detected" then make a process sending Email that contain image generate from Pi camera to our email. 



The image result that sending from Raspberry Pi to email:



CONCLUSION:

As a conclusion, the coding and component is function successfully. Next, i will design the case for my project before going to test at the barn.


WEEK 6- Code Explanation

Date: 18 March 2020

OBJECTIVE:

- To give explanation about my project code.

CONTENT/ PROCEDURE:

First, we add the packages and modules required for this project. The GPIO package helps up to control the GPIO pins of our Raspberry Pi. The Picamera package is used for the Raspberry Pi camera, while the Smtplib package allows us to set up the Gmail server.


        import os
import glob
import picamera
import RPi.GPIO as GPIO
import smtplib
from time import sleep

We need the four modules below to send emails from a Raspberry Pi:

        from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import encoders
We need to add the receiver's email and sender's email address and password, as shown below:

sender = 'example@gmail.com' password = 'abcd1234' receiver = 'example@gmail.com'


We can then set the directory path and the file prefix for where the images will be saved:

DIR = './Database/' FILE_PREFIX = 'image'


Then, because we are going to receive the output of the sensor, we declare pin 11 as input. Any GPIO warnings should be ignored.


        GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)  # Read output from PIR motion sensor
In the send_mail() function, the system will check whether the database directory has already been created or not. If it is not created, one will be created. It will then look for the ID of the images and save the new image with a new ID. Then the most recent image will be attached to the email and sent to the receiver’s address.


        def send_mail():
    print 'Sending E-Mail'
    # Create the directory if not exists
    if not os.path.exists(DIR):
        os.makedirs(DIR)
    # Find the largest ID of existing images.
    # Start new images after this ID value.
    files = sorted(glob.glob(os.path.join(DIR, FILE_PREFIX + '[0-9][0-9][0-9].jpg')))
    count = 0
    
    if len(files) > 0:
        # Grab the count from the last filename.
        count = int(files[-1][-7:-4])+1

    # Save image to file
    filename = os.path.join(DIR, FILE_PREFIX + '%03d.jpg' % count)
    # Capture the face
    with picamera.PiCamera() as camera:
        pic = camera.capture(filename)
    # Sending mail
    msg = MIMEMultipart()
    msg['From'] = sender
    msg['To'] = receiver
    msg['Subject'] = 'Movement Detected'
    
    body = 'Picture is Attached.'
    msg.attach(MIMEText(body, 'plain'))
    attachment = open(filename, 'rb')
    part = MIMEBase('application', 'octet-stream')
    part.set_payload((attachment).read())
    encoders.encode_base64(part)
    part.add_header('Content-Disposition', 'attachment; filename= %s' % filename)
    msg.attach(part)
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login(sender, password)
    text = msg.as_string()
    server.sendmail(sender, receiver, text)
    server.quit()

In the while loop, it will read the input from pin 11 and, if the input is equal to 1, the send_mail() function will be called to send an email.
while True:
    i = GPIO.input(11)
    if i == 0:  # When output from motion sensor is LOW
        print "No intruders", i
        sleep(0.3)
    elif i == 1:  # When output from motion sensor is HIGH
        print "Intruder detected", i
        send_mail()
CONCLUSION:

As a conclusion from the explanation, i know about my project code function. Next, i need to create email for my project to send email that contain image to my email.

Friday, April 3, 2020

WEEK 5- Test Pi Camera and Sound Sensor

Date: 11 March 2020

OBJECTIVE:

- To test functionality of Pi Camera and Sound Sensor

CONTENT/PROCEDURE:

Test Pi camera:

First we need to connect Pi camera with Raspberry Pi at the port

Raspberry Pi Camera: A high-speed camera at a bargain price ...


Then write the command at terminal ('raspistill -o Dekstop/image.jpg'). The image will save at desktop with format JPG.



Test Sound Sensor:

First connect sound sensor to GPIO Raspberry Pi.

Sound Sensor (Raspberry Pi) : 4 Steps - Instructables

Then, use Python to compile the coding of Sound sensor.


GPIO we use Pin 11 as our output.


RESULT & ANALYSIS:

Result for Pi Camera we can see the image output will be display at desktop:



Result for Sound Sensor:


we can see if the signal high it will print "Detected"


CONCLUSION:

As a conclusion, the test for Pi camera and Sound sensor is in good condition. Next, i will make connection and test for my coding project to send image through email when it get interrupt signal from Sound sensor. 

WEEK 4- Buy Component Project

Date: 4 March 2020

OBJECTIVE:

- To buy component for project before test.


CONTENT/PROCEDURE:

List component:

  • Raspberry Pi 3B+ (RM 201.51)
  • Pi camera (RM 15.50)
  • Sound sensor (RM 4.60)
  • Raspberry Pi 7 inch LCD display (RM 188.30) 

Total cost for my project component: RM 409.91


Specification  of component:

Raspberry Pi 3B +:

Raspberry Pi 3 Model B+: See all the new features on the board ... Pin on RoboGems


  • Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz.
  • 1GB LPDDR2 SDRAM.
  • 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2, BLE.
  • Gigabit Ethernet over USB 2.0 (maximum throughput 300 Mbps)
  • Extended 40-pin GPIO header.
  • Full-size HDMI.
  • 4 USB 2.0 ports.

Pi camera:
The Open Camera Project – $4,000 bounty for Open Firmware/Drivers ...

  • Sensor type : Omni Vision OV5647 Color CMOS QSXGA (5-megapixel)
  • Sensor size : 3.67 x 2.74 mm (1/4" format)
  • Pixel Count : 2592 x 1944
  • Pixel Size : 1.4 x 1.4 um
  • Lens : f=3.6 mm, f/2.9
  • Angle of View : 54 x 41 degrees
  • Field of View : 2.0 x 1.33 m at 2 m
  • Full-frame SLR lens equivalent : 35 mm
  • Video : 1080p at 30 fps with codec H.264 (AVC)
  • Up to 90 fps Video at VGA
  • Board size : 25 x 24 mm (not including flex cable)
  • Mini size , easy to place and use
Sound sensor:

Sound sensor module « osoyoo.com

  • Type Sensor have 3 pin (Output, Vcc, Gnd)
  • Use For Arduino
  • Sensor Function Sound
  • Dimension(cm) 4.3 x 1.7 x 1
  • Net Weight(kg) 0.007


Raspberry Pi 7 inch LCD display:

  • Resolution: 1024*600 
  • USB interface capacitive touch , more convenient
  • Support the back-light control, saves the electricity
  • Support Raspberry Pi 2 / 3 / 3B+ / 4 model B;
  • Supports popular mini PCs such as Raspberry Pi, BB Black, Banana Pi, as well as general desktop computers
  • When works with Raspberry Pi, supports Raspbian/Ubuntu/Kali/Retropie/WIN10 IOT, driver free, 
  • When work as a computer monitor, supports Windows XP/7(single-points touch); supports Windows 10/8.1/8/7( five-points touch), and driver free,
  • General HDMI display , can be used as a computer monitor ( touch function cannot be used )
  • HDMI interface is used to display and USB interface is used to touch
  • 3.5mm audio jack(44.1Khz-196Khz), supports HDMI audio output, 
  • This 7 inch touch screen module is designed especially for Raspberry Pi 3/2 /3B+, support the portable power, convenient for DIY.



CONCLUSION:

As a conclusion, after this i will make a test my component function before make a connection and coding for my project.


Thursday, April 2, 2020

WEEK 3- FYP 2 First Briefing

Date: 26 February 2020

OBJECTIVE:

- To briefing about CLO Final Year Project to student.

CONTENT/PROCEDURE:
  • Brief project cost can be claim only RM 500 and above.
  • The Final Year Project exhibition will be held on Week 12 at Dewan Gemilang.
  • If student want to change Project Title need to fill a form with approval from supervisor before 13 March 2020. 
Mark Scheme:

  • Logbook/ Blog : 20%
  • Exhibition        : 35%
  • Final Report     : 35%
  • Technical Paper: 10%


CONCLUSION:

As a conclusion, i hope my project will be success to get good mark in this subject.

WEEK 2- Find Coding of Project

Date: 19 February 2020

OBJECTIVE:

- To find a coding for Pi camera, Sound Sensor and project for testing at Python.

CONTENT/PROCEDURE:

Coding for Pi camera to generate image:

  • raspistill -o Dekstop/image.jpg (this coding apply at terminal)

Coding for Sound Sensor to see it sensitivity:

#!/usr/bin/python
import RPi.GPIO as GPIO
import time

#GPIO SETUP
channel = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.IN)

def callback(channel):
        if GPIO.input(channel):
                print('Sound Detected')
        else:
                print('Sound Detected!')

GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300)  # let us know when the pin goes HIGH or LOW
GPIO.add_event_callback(channel, callback)  # assign function to GPIO PIN, Run function on change

# infinite loop
while True:
        time.sleep(1)
Coding for Project:

import os import glob import picamera import RPi.GPIO as GPIO import smtplib from time import sleep # Importing modules for sending mail from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email import encoders sender = 'example@gmail.com' password = 'abcd1234' receiver = 'example@gmail.com' DIR = './Database/' FILE_PREFIX = 'image' GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN) # Read output from PIR motion sensor def send_mail(): print 'Sending E-Mail' # Create the directory if not exists if not os.path.exists(DIR): os.makedirs(DIR) # Find the largest ID of existing images. # Start new images after this ID value. files = sorted(glob.glob(os.path.join(DIR, FILE_PREFIX + '[0-9][0-9][0-9].jpg'))) count = 0 if len(files) > 0: # Grab the count from the last filename. count = int(files[-1][-7:-4])+1 # Save image to file filename = os.path.join(DIR, FILE_PREFIX + '%03d.jpg' % count) # Capture the face with picamera.PiCamera() as camera: pic = camera.capture(filename) # Sending mail msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver msg['Subject'] = 'Movement Detected' body = 'Picture is Attached.' msg.attach(MIMEText(body, 'plain')) attachment = open(filename, 'rb') part = MIMEBase('application', 'octet-stream') part.set_payload((attachment).read()) encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename= %s' % filename) msg.attach(part) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender, password) text = msg.as_string() server.sendmail(sender, receiver, text) server.quit() while True: i = GPIO.input(11) if i == 0: # When output from motion sensor is LOW print "No intruders", i sleep(0.3) elif i == 1: # When output from motion sensor is HIGH print "Intruder detected", i send_mail()


CONCLUSION:

As a conclusion, i hope this coding can be use to test and get expected result for my project.