F12: All Your Base are Belong to You

From Embedded Systems Learning Academy
Revision as of 04:07, 19 December 2012 by Tyler f12 (talk | contribs) (Software Design)

Jump to: navigation, search

All Your Base are Belong to You

CmpE146 F12 AYB Raspberry-Pi.jpg

Abstract

The Automated Security system will monitor a home, and trip an if an intruder passes by the sensor by wirelessly sending a signal to the central unit. The system will incorporate several hardware devices, managed by a Web based GUI for easy activation and deactivation of both the alarm and the system

Objects & Introduction

This system will automate your security and home functions for a higher quality of life

Security Thermal Sensor

  • Security Thermal Sensor will capture movement and heat from intruders
  • Security Thermal Sensor will send an alarm signal to the server after the thermal value reaches a certain threshold
  • Alarm Signal from the Security Thermal Sensor will be sent to the server through Wi-Fi communication

Raspberry Pi or Receiving Server (server)

  • Server will receive data from the Security Thermal Sensor
  • Server will receive alarm signal and be set to an alarm state until it is deactivated

Team Members & Responsibilities

  • Christopher Cheng
    • Wi-Fi Hardware and Software Design
  • Tyler Gray
    • Raspberry Pi (server) Research and Web UI
  • Prateek Grover
    • Thermal Motion Sensor Hardware and Software Design

Schedule

Week Number Scheduled Items Actual

1

  • Identify Team
  • Identify Hardware
  • Acquire Hardware
  • Design Security Sensor Wire Diagram
  • Done
  • Done
  • Done
  • Done

2

  • Wire up Security Sensor to the LPC MicroController and read sensor data
  • Have Raspberry Pi Wi-Fi Connectivity
  • Set up communication from MicroController to Hercules using Wi-Fi Module
  • Done
  • Done
  • Done

3

  • Connect Server to Security Sensor Slave Module
  • Create Security Sensor Alarm Protocol
  • Establish Communication Between Raspberry Pi and Microcontroller through Wi-Fi
  • Done
  • Done
  • Done

4

  • Create Basic UI
  • Done

5

  • Integrate UI with the Server
  • Improve UI Functionality
  • Done
  • In Progress
Week Number Scheduled Items Actual

Parts List and Cost

Item Number Items Cost

1

  • Raspberry Pi

$86.54

2

  • 3x RN-XV WiFly Module - Wire Antenna
  • WRL-10822
  • Total = $104.85
  • Each = $34.95

3

  • Infrared Thermometer - MLX90614
  • SEN-09570

$19.95

4

  • EdiMax EW-781UN

$9.99

Item Number Items Cost

Design and Implementation

Hardware Design

CmpE146 F12 AYB TMSensorHW Diagram.png
Figure 1: Hardware design for I2C Ir Thermal Motion Sensor and UART Wifly


CmpE146 F12 AYB PIRThermalMotionSensor.jpeg
Figure 2: Implementation of Sensor/Wifly Design


CmpE146 F12 AYB RaspberryPiHW.jpg
Figure 3: Raspberry Pi Hardware

Raspbery Pi

Wireless Connectivity

The Raspberry Pi does not have Wi-Fi Capabilities built in, so we used an Edimax EW 71UN nano adapter to give it that functionality. This adapter was chosen because it has the following qualities:

  • IEEE 802.11 b/g/n capabilities
  • nano adapter, so it won't stick out
  • plug and play ability for Raspbian Wheezy Linux distribution
  • cheap(cost $10 at time of purchase)

Hardware Implementation

The hardware implementation for the project required the use of I2C bus for establishing communication between the temperature sensor and the micro controller. Along with that, wifly modules that would relay the information to the server were interfaced with the LPC board using Uart communication protocol.

Sensor

The sensor chosen to measure temperature readings was Melexis MLX90614 IR Temperature sensor. This sensor required an input voltage of 3.6 V. .This was achieved by pulling up SDA and SCL lines by using 4.7 K resistors. In addition to that a decoupling capacitor with a value of 0.1 uF was interfaced between Vss and GND. Figure 1 shows the complete hardware circuit for the sensor.

I2C communication

The IR sensor using a generic I2C communication protocol. I2C communication follows following steps
1. Master kicks off communication by sending a 1 bit start condition.
2. Master follows it up with by selecting the slave device by sending slave address over SCL line.
3. Following the slave address, a bit indicating where the operation is read or write(1=read, 0= write)
4. Slave then sends an ACK bit.
5. Master then send the address of the register that need to be either read or written to.
6. Slave again sends an ACK bit.
8. Data bits are send over SDA line by either master(for write) or by slave(for read). After each 8 bits or 1 packet, slave or master send an ACK depending on write or read respectively.
9. Communication is concluded when master device sends the stop bit.

The pins used for realizing this communication were Pin 0.2 for SCL and P 0.3 for SDA.

Wifly Interface

Wifly was interfaced over Uart line requiring two pins:Pin 0.8 TX for transmission and Pin 0.9 RX to receive data. A driver was Uart was already on hand(Uart 0) but it had to be modified to get Uart 1 since Uart 0 was already used by USB port.

Software Design

The Software Design consisted of:
1. Raspberry Pi server generates requests over Wifly module.
2. The request comes in and is stored temporarily on the Web GUI.
3. The GUI then send the stored request over the wifly.
4. Request is received by the LPC microprocessor which then controls sensor depending on the command received.



Figure 4. Software Block Diagram





LPC OS

Raspberry Pi

Operating System

    Raspbian "Wheezy" from RaspberryPi.org
  • Debian Linux variant
  • Made Specifically for the Raspberry Pi

LAMP Server

    Linux, Apach, MySQL, PHP
  • Makes Raspberry Pi a Web Server
  • Hosts WebUI

WEB UI

    Gives user control over Security System
  • Uses Twitter Bootstrap framework
  • Allows User to Activate and Deactivate the Security System
  • Uses Bootswatch to make it more visually appealing

Software Implementation

Setting up the Raspberry Pi

Setting Up the OS
  1. Download latest Raspbian Distribution and Win32DiskImager from RaspberryPi.org[1]
  2. Use the Disk Imager to create a bootable SD card of the Distribution
Configure Networking

In order for the Server to be able to connect with the sensor devices

Setting up the LAMP Server

With the Raspberry Pi OS set up, a few command line instructions were executed on the Pi to set it up as a Web Server. the following steps were taken from Penguin Tutor[2](an internet connection is necessary to install the LAMP elements):

  1. Update Repositories: sudo apt-get update
  2. Install Apache: sudo apt-get install apache2
  3. Install MySQL(needs password setup as part of the process): sudo apt-get install mysql-server
  4. Install PHP: sudo apt-get install php5
    sudo apt-get install php5-mysql

WEB UI

  • Uses Twitter Bootstrap framework
  • Allows User to Activate and Deactivate the Security System

Testing and Technical Challenges

Testing

All the testing of the All Your Base are Belong to You Home automation and security system will be described in this section.

Testing Data of MLX90614 Thermal Sensor

First we must determine that we are gathering all 3 bytes gathered from the I2C read function, and ensure that it can be usable data for a security system. Then determine the distance of the Thermal sensor for the possible use as a motion sensor.

  • The change in byte value by waving a hand over the sensor will confirm the functionality of the sensor
Figure 4: Command Parser Test

Raspberry Pi Communication Test

For the Raspberry Pi, we will use a Linux OS and download a telnet software that is usable by the terminal program.

  • First set up a Ad-hoc connection between the Raspberry Pi and the Motion Sensor Module
  • Use telnet on a linux terminal to directly connect to the motion sensor module's IP and port for a direct communication
  • Using hercules and the linux terminal, type in messages and hit enter on either hercules or the linux terminal to send a message
    • Hercules should send a message to the Linux Terminal
    • The Linux Terminal should send a message to the Hercules terminal
Figure 5: Wifly UART and Raspberry Pi Communication Test
Testing the Slave Command Parser Function

The slave will be reading all data being transmitted from the website user interface. Once the data is received, the parser function will compare the hex and set global variables or send data depending on the command it has received.

Figure 6: Command Parser Test

User Interface Communication Test

With the use of a User interface to control the Motion Sensor, we will be using socket programming embedded in a website. The website will act as a user interface to enable to disable the device.

  • Enable Button is pressed
    • The sensor will be armed
      • When the sensor is armed, the sensor can go into an alarmed state if there is motion
  • Disable Button is pressed
    • The sensor will be disabled
      • Nothing will happen, even is there is motion
  • Panic Button is pressed
    • When the sensor is enabled, the sensor will be put into an alarm state and turn on an LED
    • When the sensor is disabled, nothing will happen
CmpE146 F12 AYB Website UI.png
Figure 7: Website User Interface

Technical Challenges

In this section, we will describe all the technical challenges that we ran into while building and testing this project.

Infrared Thermometer MLX90614

The sensor would not output data therefore the testing of the network connections between the motion sensor module and the raspberry pi could not be tested.

  • Could not continue the utilization of the design and could not test and verify the usability of the MLX90614 Thermal Sensor as a motion sensor.
Determine the Problem

The wrong voltage was being passed into the MLX90614 was determined with the use of a multimeter.

  • Requires around 3.3V but was getting voltage under 1V
  • While minimum pressure was applied to the GND and V_out pins on the LPC2148 microcontroller, the correct voltage was being sent into the MLX90614.
    • We have determined that the problem was with the LPC2148, the pins were not correctly soldered
Solving the Problem

Once we have determined the problem came from the LPC2148, we decided to re-solder a GND pin and a Voltage Out Pin to ensure that we can capture the full 3.3 Voltage going in and out of the MLX90614 system.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnd from this project. How has this project increased your knowledge?

Project Video

Upload a video of your project and post the link here.

Project Source Code

Project source code is available at SourceForge

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

List any references used in project.

Appendix

You can list the references you used.