Difference between revisions of "F15: Laser Security System"
Proj 146u4 (talk | contribs) (→Software Design) |
(→Grading Criteria) |
||
(48 intermediate revisions by one other user not shown) | |||
Line 6: | Line 6: | ||
[[File:CMPE146_F15_LaserSecuritySystem_secondboardinterface.jpg|600px|thumb|centre|Final hardware design for second microcontroller, bluetooth module, cellular shield and Arduino board]] | [[File:CMPE146_F15_LaserSecuritySystem_secondboardinterface.jpg|600px|thumb|centre|Final hardware design for second microcontroller, bluetooth module, cellular shield and Arduino board]] | ||
− | == Abstract == | + | == '''Abstract''' == |
− | The Laser Security System allows to maintain security in a room. For example by shining a laser across | + | The Laser Security System allows to maintain security in a room. For example by shining a laser across a photo-resistor inside a box. When laser is block from the photo resistor we send an alerting message via bluetooth communication to a guarded slave micro controller. The slave micro controller, Arduino and cellular shield will work together to send a text message to alert the owner that there has been a breach. |
− | == Objectives & Introduction == | + | == '''Objectives & Introduction''' == |
− | This security system will be using GPIO pins on the | + | This security system will be using GPIO pins on the SJ One Board to detect if the laser has been trip. This board will use TX and RX lines to connect to the RN42-XV Bluetooth Module using serial communication (UART). There are two bluetooth modules, each one is connected to a SJ One Board and will communicate with each other, in order to specify when a text message should be sent. The Arduino module will provide power to the cellular shield and retrieve the information from the slave micro controller to send the according commands to the cellular shield. |
Objectives for this project: | Objectives for this project: | ||
− | *Research and design the schematics to connect a light detection circuit to one of the | + | *Research and design the schematics to connect a light detection circuit to one of the SJ One Board and showing the output by lighting an LED |
*Research bluetooth communication and integrate it to the light detection circuit | *Research bluetooth communication and integrate it to the light detection circuit | ||
*Research gsm communication | *Research gsm communication | ||
Line 28: | Line 28: | ||
Irlanda Altamirano: Hardware Implementation and Report Writer | Irlanda Altamirano: Hardware Implementation and Report Writer | ||
− | == Schedule == | + | == '''Schedule''' == |
{| class="wikitable" | {| class="wikitable" | ||
Line 46: | Line 46: | ||
• Purchase all required parts | • Purchase all required parts | ||
− | | | + | |Completed: |
− | • | + | • Project Research |
|- | |- | ||
Line 59: | Line 59: | ||
• Test individual components | • Test individual components | ||
− | | | + | |Completed: |
• Schematics for the overall system is done | • Schematics for the overall system is done | ||
Line 73: | Line 73: | ||
• Test the hardware design | • Test the hardware design | ||
− | | | + | |Completed: |
− | |||
• Hardware design implementation started | • Hardware design implementation started | ||
Line 85: | Line 84: | ||
• Test the hardware as a whole | • Test the hardware as a whole | ||
− | | | + | |Completed: |
• Hardware design implementation interfacing a laser, photo-resistor and SJ One Board completed | • Hardware design implementation interfacing a laser, photo-resistor and SJ One Board completed | ||
Line 96: | Line 95: | ||
• Build Bluetooth circuit | • Build Bluetooth circuit | ||
− | | | + | |Completed: |
• Test the hardware design | • Test the hardware design | ||
Line 111: | Line 110: | ||
• Test the complete hardware interface | • Test the complete hardware interface | ||
− | | | + | |Completed: |
• Order another board for Bluetooth communication | • Order another board for Bluetooth communication | ||
Line 122: | Line 121: | ||
• Test Bluetooth communication with SJ One Board | • Test Bluetooth communication with SJ One Board | ||
− | | | + | |Completed: |
• Hardware design implementation interfacing a laser, photo-resistor, bluetooth communication and SJ One Board started | • Hardware design implementation interfacing a laser, photo-resistor, bluetooth communication and SJ One Board started | ||
Line 133: | Line 132: | ||
• Implement text message feature with Bluetooth communication | • Implement text message feature with Bluetooth communication | ||
− | | | + | |Completed: |
• Debugging bluetooth communication interface | • Debugging bluetooth communication interface | ||
Line 146: | Line 145: | ||
• Test system design | • Test system design | ||
− | | | + | |Completed: |
• Started implementing SMS feature with bluetooth communication | • Started implementing SMS feature with bluetooth communication | ||
Line 159: | Line 158: | ||
• Finish project report | • Finish project report | ||
− | | | + | |Completed: |
• Debugging SMS/ bluetooth communication | • Debugging SMS/ bluetooth communication | ||
Line 174: | Line 173: | ||
• Demo Project on Thursday, December 17, 2015 | • Demo Project on Thursday, December 17, 2015 | ||
− | | | + | |Completed: |
• Demo Project completed | • Demo Project completed | ||
Line 187: | Line 186: | ||
! scope="col"| Item | ! scope="col"| Item | ||
! scope="col"| Cost | ! scope="col"| Cost | ||
+ | ! scope="col"| | ||
|- | |- | ||
Line 192: | Line 192: | ||
|SJ One Board | |SJ One Board | ||
| $80.00 | | $80.00 | ||
+ | |SJSU from SCE at Engr294 | ||
|- | |- | ||
|- | |- | ||
Line 197: | Line 198: | ||
|Quad-band Cellular Duck Antenna SMA | |Quad-band Cellular Duck Antenna SMA | ||
| $7.95 | | $7.95 | ||
+ | |https://www.sparkfun.com/products/675 | ||
|- | |- | ||
Line 204: | Line 206: | ||
|RN42-XV Bluetooth Module - PCB Antenna | |RN42-XV Bluetooth Module - PCB Antenna | ||
| $24.95 | | $24.95 | ||
+ | |https://www.sparkfun.com/products/11601 | ||
|- | |- | ||
Line 211: | Line 214: | ||
|Mini Photocell | |Mini Photocell | ||
| $1.50 | | $1.50 | ||
+ | |https://www.sparkfun.com/products/9088 | ||
|- | |- | ||
Line 218: | Line 222: | ||
|SparkFun Cellular Shield - MG2639 | |SparkFun Cellular Shield - MG2639 | ||
| $69.95 | | $69.95 | ||
+ | |https://www.sparkfun.com/products/13120 | ||
|- | |- | ||
Line 225: | Line 230: | ||
|Arduino Uno R3 | |Arduino Uno R3 | ||
| $24.95 | | $24.95 | ||
+ | |https://www.sparkfun.com/products/11021 | ||
|- | |- | ||
Line 231: | Line 237: | ||
! scope="row"| 1 | ! scope="row"| 1 | ||
|LED | |LED | ||
− | | $0. | + | | $0.35 |
+ | |https://www.sparkfun.com/products/9590 | ||
|- | |- | ||
Line 237: | Line 244: | ||
|- | |- | ||
! scope="row"| 1 | ! scope="row"| 1 | ||
− | |Resistors 8.2K, 2.7K and 1K ohms | + | |Resistors 8.2K, 2.7K and 1K ohms, |
− | | $ | + | | $7.99 |
+ | |Frys- Resistor set of 610 assorted | ||
+ | |- | ||
+ | |||
+ | |- | ||
+ | ! scope="row"| 1 | ||
+ | |AT Command Application | ||
+ | | FREE | ||
+ | |Android Play Store | ||
|- | |- | ||
|} | |} | ||
== '''Design & Implementation''' == | == '''Design & Implementation''' == | ||
− | |||
=== Hardware Design === | === Hardware Design === | ||
+ | |||
Figures 1-5 show the modules needed for this project as listed in the Parts list. | Figures 1-5 show the modules needed for this project as listed in the Parts list. | ||
− | The security system is made up of two main two components, the laser detection component and the transmitting text messaging component/ receiving text message commands. Figure 7 is the first circuit, it includes the master | + | The security system is made up of two main two components, the laser detection component and the transmitting text messaging component/ receiving text message commands. Figure 7 is the first circuit, it includes the master SJ One Board connected to a bluetooth module by using UART communication. The master SJ One Board is also connected to the laser detection circuit. The circuit is comprised of a transistor that relies on a set amount of current to create a channel from the collector to the emitter. The photocell is used to increase and decrease the resistance, thus limiting or increasing the current flow. When there is enough light or the laser is shining on the photocell the resistance decreases allowing the current to travel to ground instead of the base of the transistor. When the laser is interrupted from shining on the photo cell that is encased in a box then this produces high resistance, and allowing the current to flow into the base of the transistor instead of going to ground. The micro controller will take this input and and output 3.3v through another gpio pin to an led to indicate the laser has been trip. Once we receive input from the photo circuit, the micro controller will transmit data (UART communication) to the bluetooth module and will send the information to the other bluetooth module which is connected to the second micro controller. The second circuit is shown in Figure 8 which shows the second SJ board. This board is connect to a bluetooth module that receives information when the laser has been interrupted. The SJ One board #2 connects to the Arduino and communicate through GPIO. When the Arduino gets an input from the second board it sends commands to the cellular shield to send a text message. |
− | |||
− | |||
− | [[File:CMPE146_F15_LaserSecuritySystem_SJSUboard.jpg| | + | [[File:CMPE146_F15_LaserSecuritySystem_SJSUboard.jpg|700px|thumb|centre|Figure 1. SJ One Board]] |
Line 270: | Line 283: | ||
− | [[File:CMPE146_F15_LaserSecuritySystem_MasterBoardCircuitSchematics.jpeg|600px|thumb|centre|Figure 7. Master | + | [[File:CMPE146_F15_LaserSecuritySystem_MasterBoardCircuitSchematics.jpeg|600px|thumb|centre|Figure 7. Master SJ One Board and Bluetooth schematics with light sensor circuit]] |
− | [[File:CMPE146_F15_LaserSecuritySystem_bluetooth2schematics.jpeg|600px|thumb|centre|Figure 8. Second | + | [[File:CMPE146_F15_LaserSecuritySystem_bluetooth2schematics.jpeg|600px|thumb|centre|Figure 8. Second SJ One Board connected to Bluetooth module circuit schematics]] |
− | [[File: | + | [[File:CMPE146_F15_LaserSecuritySystem_secondcircuit.jpeg|600px|thumb|centre|Figure 9. Second SJ One Board connected to Bluetooth module, cellular shield, and Arduino board schematics]] |
=== Hardware Interface === | === Hardware Interface === | ||
− | To sync our the devices and connect them via bluetooth | + | To sync our the devices and connect them via bluetooth an app called "AT command" was downloaded from the Android app store for free. First we make sure our circuits are powered on. Then we open the App and scan for nearby bluetooth devices using an AT command. Once we see the desired device name/serial number, we store the serial number on the master bluetooth module. We then send another AT command to connect to the master SJ board so that it can communicates to the slave SJ board via bluetooth. Note that one bluetooth module must be set to master, since the module default state is slave. |
− | The command inX is used to search for nearby bluetooth devices, "in" stands for inquiry and the X represent a variable number that tells the searching bluetooth module | + | The command inX is used to search for nearby bluetooth devices, "in" stands for inquiry and the X represent a variable number that tells the searching bluetooth module how long it has to wait in seconds to search for other bluetooth devices. |
− | After the searches in X seconds | + | After the searches in X seconds is complete then we connect to the second module by sending the character c. |
*note again once you find the desire bluetooth module, the serial number must be store in the master bluetooth module before we can connect. | *note again once you find the desire bluetooth module, the serial number must be store in the master bluetooth module before we can connect. | ||
− | + | Another useful command is "h", which provides you with the list of AT commands and a description of their purpose. | |
After once the bluetooth modules are connected they can begin transmitting data. Allowing both components to do their intended tasks. | After once the bluetooth modules are connected they can begin transmitting data. Allowing both components to do their intended tasks. | ||
+ | |||
+ | [[File:CMPE146_F15_LaserSecuritySystem_pinconnectiontable.jpg|600px|thumb|centre|Pin connection tables for figure 9]] | ||
+ | |||
+ | ===Master microcontroller=== | ||
+ | <pre> | ||
+ | bool init(void){}// initialize GPIO pins for laser detection and initialize UART for bluetooth communication | ||
+ | char printchar_UART2(char out){}// transmit data when ready | ||
+ | bool run(void *p){} //check GPIO pins from laser circuit, if triggered light led and transmit data | ||
+ | </pre> | ||
+ | |||
+ | ===Slave microcontroller=== | ||
+ | <pre> | ||
+ | bool init(void){}// initialize GPIO pins for Arduino trigger and initialize UART for bluetooth communication | ||
+ | char getchar_UART2(void){}// Retrieve data when ready, light on board LEDs to indicate data is obtained | ||
+ | bool run(void *p){}// constantly check if data is obtained, trigger GPIO pin to notify Arduino data has been received, | ||
+ | // if buffer is full, clear the buffer | ||
+ | </pre> | ||
+ | |||
+ | ===Arduino=== | ||
+ | <pre> | ||
+ | // initialize shield requirements, | ||
+ | variables to hold phone number , text message string, pin setting, set serial communication baud rate, | ||
+ | send power to cellular shield and verify if shield is working properly, delay system to allow sim to set up | ||
+ | call set SMS mode protocol | ||
+ | void loop(){}// check if pin has been set, for both cases print pin information, if pin is set call writeSMS function | ||
+ | void writeSMS()// notify shield we are about to send a message, we can send a unique text message or predefined text message | ||
+ | // fill buffer until delimiter character then send text message | ||
+ | </pre> | ||
=== Software Design === | === Software Design === | ||
Line 297: | Line 338: | ||
=== Implementation === | === Implementation === | ||
− | The first step was to initialize the GPIO pins for the laser detection. Then we initialized the micro controller for UART communication. We | + | The first step was to initialize the GPIO pins for the laser detection. Then we initialized the micro controller for UART communication. We created to one function for the master to transmit and another for the slave to receive. Within our run function for the master, we are continuously checking if the light has been block. If the light is blocked the master will transmit data to the slave via Bluetooth. Note that the bluetooth devices need to be initialized using AT commands. After downloading the ATCommand application from an Android app store we scan for the master bluetooth device as shown in the picture below. |
+ | |||
+ | [[File:CMPE146_F15_LaserSecuritySystem_mainscreen.png|300px|thumb|centre|Figure 11. AT command application main screen]] | ||
+ | |||
− | == Testing & Technical Challenges == | + | We select the set option to configure and set the master bluetooth as our master device in which it will be control by this application. |
+ | |||
+ | [[File:CMPE146_F15_LaserSecuritySystem_connection.png|300px|thumb|centre|Figure 12. AT command application setting master connection]] | ||
+ | |||
+ | |||
+ | One bluetooth device needs to be set to master so it can transmit to the other. Once the bluetooth devices are initialized, the master will search for any nearby devices it can communicate with. To search for bluetooth module #2 we select the advance option and then we type the command in5 to search for nearby bluetooth connection from the master. Then type the command c to connect to bluetooth module #2. | ||
+ | |||
+ | [[File:CMPE146_F15_LaserSecuritySystem_settings.png|300px|thumb|centre|Figure 13. AT command application pairing bluetooth connection to the second bluetooth device using advance settings]] | ||
+ | |||
+ | Once we see our bluetooth module #2 device we need to record its name in the master bluetooth device so it can easily pair with this device the next time we setup communication. Once the slave or bluetooth device #2 receives data that the laser has been trip, the slave will then communicate with the Arduino one board using a GPIO pin. The Arduino board initializes the cellular shield and provides power to the board. If the Arduino receives the signal from the slave microcontroller, the Arduino will send commands to the cellular shield. Then the cellular shield will then send a text message to the predefined phone number. If the Arduino does not receive the signal from the slave microcontroller, it will stay idle until it is triggered by the slave micro controller. | ||
+ | |||
+ | == '''Testing & Technical Challenges''' == | ||
The following difficulties were encounter during this project but were able to successfully overcome them to delivery a functional project. Most of the time spent in this project was testing and debugging our program. | The following difficulties were encounter during this project but were able to successfully overcome them to delivery a functional project. Most of the time spent in this project was testing and debugging our program. | ||
=== My Issue #1 === | === My Issue #1 === | ||
− | At the beginning of the project we encounter some problems since we never had worked with bluetooth communication, gsm communication,and interfacing it with laser detection circuit between two microcontrollers. This was challenging but not impossible to solve this problem so from our part we conducted a lot of research before even building the first circuit in this project which was the light detection sensor circuit. | + | At the beginning of the project we encounter some problems since we never had worked with bluetooth communication, gsm communication,and interfacing it with laser detection circuit between two microcontrollers. This was challenging but not impossible to solve this problem so from our part we conducted a lot of research before even building the first circuit in this project which was the light detection sensor circuit. So we wouldn't feel overwhelmed, we broke our project into three parts, the laser detection component, the bluetooth communication component, and gsm communication component. We made sure each component was working properly before moving onto the next component. |
− | |||
− | |||
=== My Issue #2 === | === My Issue #2 === | ||
Another problems we encounter in this project was that the cellular shield was not receiving enough power to work correctly. We tried sending commands and or send text messages but we were not receiving any feedback from the board. To solve this problem we connected an external power supply to the Arduino board and connected the voltage pin to the cellular shield board. | Another problems we encounter in this project was that the cellular shield was not receiving enough power to work correctly. We tried sending commands and or send text messages but we were not receiving any feedback from the board. To solve this problem we connected an external power supply to the Arduino board and connected the voltage pin to the cellular shield board. | ||
− | == Conclusion == | + | == '''Conclusion''' == |
− | After overcoming the problems associated with this project and a lot of software debugging was performed we were able to successfully complete this project. Through out this project we learn | + | After overcoming the problems associated with this project and a lot of software debugging was performed we were able to successfully complete this project. Through out this project we learn how to implement bluetooth communication between two microcontrollers and being able to send and receive data successfully. From the hardware to software design and implementation, we learned the basics functionality for a security system. Due to time constraints, we were not able to incorporated an alarm sound. Understanding data sheets for the devices and obtaining the information needed to implemented the desire functionality from the bluetooth module, SJ one board, Arduino board, and cellular shield was crucial in order to obtain a successful outcome and create a fully functional text message security system. |
=== Project Video === | === Project Video === | ||
Line 318: | Line 371: | ||
=== Project Source Code === | === Project Source Code === | ||
− | * | + | * https://sourceforge.net/projects/laser-security-system/files/ |
− | == References == | + | == '''References''' == |
=== Acknowledgement === | === Acknowledgement === | ||
Line 339: | Line 392: | ||
http://www.nxp.com/documents/data_sheet/LPC1759_58_56_54_52_51.pdf | http://www.nxp.com/documents/data_sheet/LPC1759_58_56_54_52_51.pdf | ||
+ | |||
+ | '''SJ One Board LPC1758 schematics''' | ||
+ | |||
+ | http://www.socialledge.com/sjsu/images/d/de/2012SJOneBoardSchematic.pdf | ||
'''LPC176x/5x User manual''' | '''LPC176x/5x User manual''' | ||
Line 348: | Line 405: | ||
http://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/RN42XV.pdf | http://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/RN42XV.pdf | ||
− | '''General Purpose Transistor''' | + | '''General Purpose Transistor BC547B''' |
+ | |||
+ | http://www.farnell.com/datasheets/410427.pdf | ||
+ | |||
+ | '''MG2639 Cellular Module''' | ||
+ | |||
+ | https://cdn.sparkfun.com/datasheets/Cellular/MG2639%20Cellular%20Shield_v11.pdf | ||
+ | |||
+ | '''Arduino schematics''' | ||
− | + | https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf |
Latest revision as of 17:54, 19 December 2015
Contents
Laser Security System
Abstract
The Laser Security System allows to maintain security in a room. For example by shining a laser across a photo-resistor inside a box. When laser is block from the photo resistor we send an alerting message via bluetooth communication to a guarded slave micro controller. The slave micro controller, Arduino and cellular shield will work together to send a text message to alert the owner that there has been a breach.
Objectives & Introduction
This security system will be using GPIO pins on the SJ One Board to detect if the laser has been trip. This board will use TX and RX lines to connect to the RN42-XV Bluetooth Module using serial communication (UART). There are two bluetooth modules, each one is connected to a SJ One Board and will communicate with each other, in order to specify when a text message should be sent. The Arduino module will provide power to the cellular shield and retrieve the information from the slave micro controller to send the according commands to the cellular shield.
Objectives for this project:
- Research and design the schematics to connect a light detection circuit to one of the SJ One Board and showing the output by lighting an LED
- Research bluetooth communication and integrate it to the light detection circuit
- Research gsm communication
- Complete hardware design
- Test functionality of the system
- Able to receive text messages from shield and send commands through text message
- Detect and connect to other bluetooth devices
Team Members & Responsibilities
Emmanuel Gonzalez: Software Implementation and Report Writer
Irlanda Altamirano: Hardware Implementation and Report Writer
Schedule
Week# | Date | Planned Task | Actual |
---|---|---|---|
1 | 10/12-10/18 |
• Project Approval • Project Research • Purchase all required parts |
Completed:
• Project Research |
2 | 10/19-10/25 |
• Build Schematics • Order all parts • Test individual components |
Completed:
• Schematics for the overall system is done • Order all parts |
3 | 10/26-11/1 |
• Begin hardware design interfacing a laser, photo-resistor and SJ One Board • Test the hardware design |
Completed:
• Hardware design implementation started |
4 | 11/2-11/8 |
• Trouble shoot hardware design with • Test the hardware as a whole |
Completed:
• Hardware design implementation interfacing a laser, photo-resistor and SJ One Board completed |
5 | 11/9-11/15 |
• Research about Bluetooth communication • Build Bluetooth circuit |
Completed:
• Test the hardware design • Starting software interfacing previous hardware implementation • Read data sheet for Bluetooth communication |
6 | 11/16-11/22 |
• Interface Bluetooth communication with SJ One Board • Test the complete hardware interface |
Completed:
• Order another board for Bluetooth communication • Research more about Bluetooth communication |
7 | 11/23-11/29 |
• Test Bluetooth communication with SJ One Board |
Completed:
• Hardware design implementation interfacing a laser, photo-resistor, bluetooth communication and SJ One Board started |
8 | 11/30-12/6 |
• Complete the software interfaces for laser, SJ One Board and Bluetooth communication • Implement text message feature with Bluetooth communication |
Completed:
• Debugging bluetooth communication interface |
9 | 12/7-12/13 |
• Finish Debugging text message communication feature • Start writing project report • Test system design |
Completed:
• Started implementing SMS feature with bluetooth communication • Continued the project report |
10 | 12/14-12/16 |
• Complete system testing • Finish project report |
Completed:
• Debugging SMS/ bluetooth communication • Completed system testing • Created video for presentation • Finish project report |
11 | 12/17 |
• Demo Project on Thursday, December 17, 2015 |
Completed:
• Demo Project completed |
Parts List & Cost
Quantity | Item | Cost | |
---|---|---|---|
2 | SJ One Board | $80.00 | SJSU from SCE at Engr294 |
1 | Quad-band Cellular Duck Antenna SMA | $7.95 | https://www.sparkfun.com/products/675 |
2 | RN42-XV Bluetooth Module - PCB Antenna | $24.95 | https://www.sparkfun.com/products/11601 |
1 | Mini Photocell | $1.50 | https://www.sparkfun.com/products/9088 |
1 | SparkFun Cellular Shield - MG2639 | $69.95 | https://www.sparkfun.com/products/13120 |
1 | Arduino Uno R3 | $24.95 | https://www.sparkfun.com/products/11021 |
1 | LED | $0.35 | https://www.sparkfun.com/products/9590 |
1 | Resistors 8.2K, 2.7K and 1K ohms, | $7.99 | Frys- Resistor set of 610 assorted |
1 | AT Command Application | FREE | Android Play Store |
Design & Implementation
Hardware Design
Figures 1-5 show the modules needed for this project as listed in the Parts list. The security system is made up of two main two components, the laser detection component and the transmitting text messaging component/ receiving text message commands. Figure 7 is the first circuit, it includes the master SJ One Board connected to a bluetooth module by using UART communication. The master SJ One Board is also connected to the laser detection circuit. The circuit is comprised of a transistor that relies on a set amount of current to create a channel from the collector to the emitter. The photocell is used to increase and decrease the resistance, thus limiting or increasing the current flow. When there is enough light or the laser is shining on the photocell the resistance decreases allowing the current to travel to ground instead of the base of the transistor. When the laser is interrupted from shining on the photo cell that is encased in a box then this produces high resistance, and allowing the current to flow into the base of the transistor instead of going to ground. The micro controller will take this input and and output 3.3v through another gpio pin to an led to indicate the laser has been trip. Once we receive input from the photo circuit, the micro controller will transmit data (UART communication) to the bluetooth module and will send the information to the other bluetooth module which is connected to the second micro controller. The second circuit is shown in Figure 8 which shows the second SJ board. This board is connect to a bluetooth module that receives information when the laser has been interrupted. The SJ One board #2 connects to the Arduino and communicate through GPIO. When the Arduino gets an input from the second board it sends commands to the cellular shield to send a text message.
Hardware Interface
To sync our the devices and connect them via bluetooth an app called "AT command" was downloaded from the Android app store for free. First we make sure our circuits are powered on. Then we open the App and scan for nearby bluetooth devices using an AT command. Once we see the desired device name/serial number, we store the serial number on the master bluetooth module. We then send another AT command to connect to the master SJ board so that it can communicates to the slave SJ board via bluetooth. Note that one bluetooth module must be set to master, since the module default state is slave.
The command inX is used to search for nearby bluetooth devices, "in" stands for inquiry and the X represent a variable number that tells the searching bluetooth module how long it has to wait in seconds to search for other bluetooth devices.
After the searches in X seconds is complete then we connect to the second module by sending the character c.
- note again once you find the desire bluetooth module, the serial number must be store in the master bluetooth module before we can connect.
Another useful command is "h", which provides you with the list of AT commands and a description of their purpose.
After once the bluetooth modules are connected they can begin transmitting data. Allowing both components to do their intended tasks.
Master microcontroller
bool init(void){}// initialize GPIO pins for laser detection and initialize UART for bluetooth communication char printchar_UART2(char out){}// transmit data when ready bool run(void *p){} //check GPIO pins from laser circuit, if triggered light led and transmit data
Slave microcontroller
bool init(void){}// initialize GPIO pins for Arduino trigger and initialize UART for bluetooth communication char getchar_UART2(void){}// Retrieve data when ready, light on board LEDs to indicate data is obtained bool run(void *p){}// constantly check if data is obtained, trigger GPIO pin to notify Arduino data has been received, // if buffer is full, clear the buffer
Arduino
// initialize shield requirements, variables to hold phone number , text message string, pin setting, set serial communication baud rate, send power to cellular shield and verify if shield is working properly, delay system to allow sim to set up call set SMS mode protocol void loop(){}// check if pin has been set, for both cases print pin information, if pin is set call writeSMS function void writeSMS()// notify shield we are about to send a message, we can send a unique text message or predefined text message // fill buffer until delimiter character then send text message
Software Design
Implementation
The first step was to initialize the GPIO pins for the laser detection. Then we initialized the micro controller for UART communication. We created to one function for the master to transmit and another for the slave to receive. Within our run function for the master, we are continuously checking if the light has been block. If the light is blocked the master will transmit data to the slave via Bluetooth. Note that the bluetooth devices need to be initialized using AT commands. After downloading the ATCommand application from an Android app store we scan for the master bluetooth device as shown in the picture below.
We select the set option to configure and set the master bluetooth as our master device in which it will be control by this application.
One bluetooth device needs to be set to master so it can transmit to the other. Once the bluetooth devices are initialized, the master will search for any nearby devices it can communicate with. To search for bluetooth module #2 we select the advance option and then we type the command in5 to search for nearby bluetooth connection from the master. Then type the command c to connect to bluetooth module #2.
Once we see our bluetooth module #2 device we need to record its name in the master bluetooth device so it can easily pair with this device the next time we setup communication. Once the slave or bluetooth device #2 receives data that the laser has been trip, the slave will then communicate with the Arduino one board using a GPIO pin. The Arduino board initializes the cellular shield and provides power to the board. If the Arduino receives the signal from the slave microcontroller, the Arduino will send commands to the cellular shield. Then the cellular shield will then send a text message to the predefined phone number. If the Arduino does not receive the signal from the slave microcontroller, it will stay idle until it is triggered by the slave micro controller.
Testing & Technical Challenges
The following difficulties were encounter during this project but were able to successfully overcome them to delivery a functional project. Most of the time spent in this project was testing and debugging our program.
My Issue #1
At the beginning of the project we encounter some problems since we never had worked with bluetooth communication, gsm communication,and interfacing it with laser detection circuit between two microcontrollers. This was challenging but not impossible to solve this problem so from our part we conducted a lot of research before even building the first circuit in this project which was the light detection sensor circuit. So we wouldn't feel overwhelmed, we broke our project into three parts, the laser detection component, the bluetooth communication component, and gsm communication component. We made sure each component was working properly before moving onto the next component.
My Issue #2
Another problems we encounter in this project was that the cellular shield was not receiving enough power to work correctly. We tried sending commands and or send text messages but we were not receiving any feedback from the board. To solve this problem we connected an external power supply to the Arduino board and connected the voltage pin to the cellular shield board.
Conclusion
After overcoming the problems associated with this project and a lot of software debugging was performed we were able to successfully complete this project. Through out this project we learn how to implement bluetooth communication between two microcontrollers and being able to send and receive data successfully. From the hardware to software design and implementation, we learned the basics functionality for a security system. Due to time constraints, we were not able to incorporated an alarm sound. Understanding data sheets for the devices and obtaining the information needed to implemented the desire functionality from the bluetooth module, SJ one board, Arduino board, and cellular shield was crucial in order to obtain a successful outcome and create a fully functional text message security system.
Project Video
Project Demo: https://youtu.be/Z2P5bmgPy7c
Project Source Code
References
Acknowledgement
We would like to thank the following people for their contributions and support during this project:
Preetpal Kang and Dr. Haluk Ozemek
References Used
Appendix
Bluetooth Module
https://www.sparkfun.com/products/11601
LPC1759 Datasheet
http://www.nxp.com/documents/data_sheet/LPC1759_58_56_54_52_51.pdf
SJ One Board LPC1758 schematics
http://www.socialledge.com/sjsu/images/d/de/2012SJOneBoardSchematic.pdf
LPC176x/5x User manual
http://www.nxp.com/documents/user_manual/UM10360.pdf
RN42XV Bluetooth Module
http://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/RN42XV.pdf
General Purpose Transistor BC547B
http://www.farnell.com/datasheets/410427.pdf
MG2639 Cellular Module
https://cdn.sparkfun.com/datasheets/Cellular/MG2639%20Cellular%20Shield_v11.pdf
Arduino schematics
https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf