This was the creation for my open ended freshman engineering final project. We were told to build something that used electronics to improve the life of the public. It is my own design and idea, copy, improve and let me know what you have done with it in the comments. I attached a video a friend did for me to make an add for the project. I am not in the video if you were wondering.
RoomAlert was the product I made that was designed for life in the dorms but could be adapted for other situations. RoomAlert would sit above the door it was monitoring and had a switch that was flipped when the door opened and reset when the door was closed. When the switch is flicked on it sends a signal to the arduino that is the heart of this project. The arduino is connected to a GSM cellular shield that sends a text message to a pre-saved phone number of the person whose room it is. Once the user receives the text message notifying him that his room has been entered he is able to call RoomAlert and it will use a microphone with an amplifier to listen in on whatever is going on in the room.
This project requires you to have general soldering skills, understanding of arduino and some patience. It is a great project for those trying to get started with electronics and is a ton of fun, lets get started!
PS. I am entering this in the RadioShack sensors competition, your support is appreciated!
Step 1: How it Works
This is a detailed guide for why parts were chosen and what everything does and how it goes together.
The device is attached above the door to the wall and has a rocker switch that is mounted with an L bracket so that it sits above the door (see picture in extras). The rocker switch is mounted so that the rocker part is just flush with the edge of the door. The plan is that the door will swing open, activating the switch, then that will signal to the arduino. Next, the arduino will communicate with the GSM shield and tell it to send a text message to the given number. When the door swings back it will flip the rocker switch back the other way so it deactivates the switch and the arduino will then reset. While all of this is going on the arduino is constantly testing the switch to see what position it is in and testing the GSM shield to see if it is receiving a call. If the GSM receives a call it will connect the user to the input from the microphone mounted on the enclosure of RoomAlert. The GSM shield takes this signal from the mic directly and send it to the user. The impedance of the mic must be correct so I found some links that showed how to set that up. See the Hardware: Microphone step for more details. As the device takes a while to connect I also installed a small LED to signal once the device is connected.
Step 2: Gather your materials
For this project you will need several parts:
Step 3: Software
If we look at the functions our device has to perform we can outline what our code needs to do and how to write it. I will provide my code at the end but for anyone who wants to understand how it works or wants to write their own code this step is where to look. I based my code very heavily on the arduino examples that are included in the arduino IDE already under examples>GSM.
RoomAlerts first function is to be able to connect to the cellular network. To do this I copied and pasted the beginning of the GSM examples arduino gives. I added in four extra variables, remoteNum, textData, texted, and buttonState. remoteNum is an array of up to 20 characters that constitute the phone number you want roomAlert to text. It must be characters because all of the arduino and gsm's internal funtions like sendText work. textData is an array of up to 200 characters that make up the message roomAlert will send you. texted is a boolean to check whether the user has been texted already for that time the door was opened. Lastly, buttonState keeps track of if the switch is on or off (door open or closed).
In the setup() we create a pin that is an input and reads if the switch is on or off. Also, make an output pin that will light an LED once the device has connected to the network so the user knows the device is ready. The rest of setup() was copied from the example except for the last line. The final line of setup() was to light the LED once everything is ready and connected.
The loop() has the working part of the project in it and is repeated until RoomAlert is shut off. It will be checking if the switch was flipped then checking if it is receiving a call continuously one after another very quickly. If the switch is flipped it will check to see if it has texted you already (with the texted variable) and if it has not texted you and the switch is on then it will text you. If the switch is off it will reset the texted variable. Make sure to keep the delays because they debounce the switch. If deleted you will get 3-4 texts everytime it changes from on to off or back because mechanical switches flicker for a fraction of a second when they are flipped. For the calling portion this was copied from the recieveCall program in the arduino examples.
Lastly, the sendText method I created uses a couple internal methods from the GSM library. You have to start the text and give the number, give it the text data then end the text.
Step 4: Hardware: Arduino/Shield
First we should set up the arduino and shield and make sure they work and connect to the network alright.
Take your SIM card and use the information provided on it to set it up and put a little bit of money on it if it is a prepaid card. Once you have this out of the way we can start having fun!
Insert the pins of the GSM shield into the arduino and slide the SIM card into the holder and close it. Plug the serial and power cables into the arduino and open the arduino IDE. Go to open>examples>GSM>sendSMS open and upload this program. When you run it then open the serial monitor. You will (hopefully) be able to enter a number and text message and send it.
Sometimes, people have trouble getting the device to connect to the wireless network. One issue could be you are using a SIM card that doesn't support unauthorized devices (like verizon) typicaly, T-mobile and Sprint work well as well as the card that came with the GSM shield. Another issue is that it isn't connecting right where you are. Check with a phone that uses t-Mobile ect. if it gets service in that area. Try placing it closer to a window and make sure the arduino is being powered by a power supply that can deliver at least 0.7 to 1 amp.
Once you are able to get your arduino to connect it is time to build the rest of the hardware
Step 5: Hardware: The switch
One might wonder how we will make the arduino detect that a switch has been flipped. We have set a pin to read digital high or low in our software so we will use the switch to either connect the ground (low) to the pin or 5v (high) to the pin.
A great example of how to do this is on the arduino site at http://arduino.cc/en/tutorial/button. We will use this method to detect the switch.
In short, what happens is that the pin is connected to one side of the switch as well as a resistor going to ground. The other side of the switch is connected to the 5v pin. When the switch opens, the pin is connected only to the ground (through the resistor). When the switch is closed the pin is connected directly to the 5v pin. The huge ohm resistor keeps the current draw low when the switch is open though.
Solder two ~12" sections of the 18 gauge wire to the middle pin and one of the side pins on the switch. Twist the two wires together to create a thicker cable that looks neater and more compact. Route this through the enclosure sidewall (see Hardware: Enclosure for more details).
Use one of the jumper wires to connect a lead from the switch to the 5v pin. Attach a jumper wire and a lead of the 100K-ohm resistor to the other wire from the switch. The jumper wire is connected to pin 4 on the GSM shield.
Finally, solder a final jumper wire to the other end of the 100K-ohm resistor and connect that to the ground pin.
To test you have done this correctly, plug the GSM shield into the arduino, upload the sketch given in the software step and set up the switch. If you are connected to the wireless network and everything has been done correctly when you flip the switch you will receive text messages!
Step 6: Hardware: Microphone
The microphone is a little tricky. This version of the instructable will not include the amplifier but it will be included in the extras portion at the end.
We will follow the schematic illustrated. Get out your electret microphone, perf board/proto board, electrolytic capacitor and 2.2k-ohm resistor, (2) 33pF capacitors and 66 ohm/(3) 22 ohm resistor(s). First, construct the board with the mic, electrolytic cap and 2.2kOhm resistor. Solder the positive (red) lead of the mic to the board and solder the positive (longer) lead of the capacitor to the positive lead of the mic on the board. Then solder one lead of the resistor to the positive leads of the mic and capacitor. Solder a section of enamel wire to the negative lead of the capacitor, a separate length to the free lead of the resistor and another piece to the negative lead of the microphone. The wire from the resistor lead will go to 5v from the arduino. The lead from the capacitor is the positive signal and the lead from the negative of the mic is the ground. Route these leads to the second board on opposite sides of the board. Put in the first 33pF capacitor and solder the wire from the electrolytic capacitor to either of the leads of the 33pF capacitor. Then to the same lead of the 33pF capacitor solder a lead of the 66ohm or 3 22ohm resistors. To the other lead of the resistors solder a lead of the second 33pF capacitor. Finally, solder the two free leads of the 33pF capacitors together. Route a wire from the resistor-second 33pF capacitor joint and that will be the microphone positive. Route a wire from the joint between the two 33pF capacitors to the ground. The grounded wire from the electret microphone can be soldered to the grounded wire from the 33pF capacitors. The ground and positive leads must be twisted together (which is why I chose to use enameled wire). Then solder the positive lead to the micP terminal on the back of the GSM shield and the negative (ground) lead to the micN pin on the back of the GSM shield.
To test this, make sure the GSM is plugged into the arduino, the arduino has power, the arduino is connecting to the wireless network correctly and the microphone circuit has been assembled and soldered correctly. To test, dial the SIM card's number on your phone and call it. It should pick up pretty quickly and you may hear a bit of static. If you are hearing a ton of static it means you should try and wrap your enamel wires better and check your wiring and wireless connection. The mic will respond best to sharp noises like snaps but will respond to voice as well.
Step 7: Hardware: LED
The status LED was added so you know that the arduino had connected to the wireless network and was ready to use. Simply solder the cathode (shorter lead) to 220 ohm resistor and attach the other lead of the resistor to ground. Plug the LED's anode into pin 8 on the GSM shield.
Step 8: Hardware: Enclosure
The final part of building RoomAlert is mounting it in a housing. I personally put the arduino on four nylon standoffs to offset it from the bottom of the enclosure but this is purely optional. Either way you will need to drill four holes in the enclosure so that the arduino can be secured to the housing. I put a dab of paint on each of the standoffs and set the arduino down where I wanted it to mark where I should drill the screw holes. Then screw the arduino into position. A hole must be drilled in the side of the enclosure for the arduino power cable to fit in. On the top drill a small hole for the LED to poke out of. In addition, drill a small hole for the wire of the microphones to go through so it can sit outside the enclosure. Finally, drill a final hole on the side for the wires from the switch to come through.
Step 9: Final Test
You have assembled everything correctly and everything appears to be working, let's put it to the test! Connect the arduino and GSM shield, make sure the circiutry is connected properly and give the arduino power. Wait for the LED to turn on so you know you have service and are connected. Be aware this can take a while (usually a minute or two for me but you have to move around a bit to find decent service). Once you get service try flipping the switch a few times and checking to make sure you are receiving text messages. Once this is all working try calling RoomAlert and if it picks up try making noise in front of the mic then slowly get further from it to see the mic's range. If any of these aren't working your best friend will be writing new code using what I gave you and the examples arduino gives you to try and figure out the problem. A useful tool for trouble shooting is using the serial port in the arduino IDE to figure out the problem; see the arduino examples for this as most of them use it.
Step 10: Extras!
This instructable did not cover several add-ons that I have put on my RoomAlert or think would be cool to add.