Friday, April 22, 2016

DIY Smart Home Automation using Android

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Smart Home Automation let the user to control the home from his or her phone and assign actions that should happen depending on time or other sensor readings such as light, temperature or sound from any device in the Home Automation network.

WHAT CAN HOME AUTOMATION DO?
  1. Increase your independence and give you greater control of your home environment.
  2. Make it easier to communicate with your family.
  3. Save you time and effort.
  4. Improve your personal safety.
  5. Reduce your heating and cooling costs.
  6. Increase your home’s energy efficiency.
  7. Alert you audibly and visually to emergency situations.
  8. Allow you to monitor your home while you are away.

Features of our project:
  1. Control upto four home appliances wirelessly (expandable based on free IO pins).
  2. Monitor status of your home like temperature inside and outside of your home,light intensity inside and outside of your home, motion (presence) on the main entrance,LPG leak in the home and status of you main door.
  3. Open/close your main door electrically and wirelessly.
  4. As the android application is password protected ,it automatically adds security to your home as it can be controlled by the user only.
  5. Automate your indoor lightening, outdoor lightening and fan/AC to switch ON/OFF automatically when the light intensity and temperature conditions exceed the programmed threshold values.(This feature, we named it “SENSOMATE”).
  6. It automatically monitor your home against LPG leaks and cases of fire.If it detects something wrong, it automatically switches off all home appliances instantly and immediately opens the door to let the LPG/fire exhaust off your home.
  7. Has a “SLEEP MODE” , once activated will switch your light off and program the motion sensor and door sensor to raise alarm if anything goes wrong.
  8. At last, as it uses Bluetooth the user can use the android phone within a range from 10-100m .
Also, there are many disabled and aged people who always depends on others for their basic necessities. This application gives them a helping hand. With this application, user can use the electrical appliances in his room without moving anywhere or without seeking anyone's help, the user himself feels a little independent.With this application the user can monitor and operate home appliances, make themselves feel secure with the help of motion sensor, give alarm to the guardian at times of emergency, check indoor and outdoor temperatures - or use this option as a digital thermometer, Enable/Disable Automatic AC control, Enable/Disable Automatic Room light control and monitor windows/doors.

[The project shown here is more a prototype,but it is fully tested and working and ready to be implemented in realtime]
[Please vote for me,if you like my work.]

Step 1: What we proposed : The solution

Home automation can allow you to make the things that you need and do in your home easier to accomplish. Perhaps you want to control your security system? Or, perhaps you want to voice automate the lights in your home so that you can get into bed and then turn the lights out. Or, perhaps you want to be able to control your sound system from any place in your home. No matter what it is you are looking to accomplish, home automation products are probably available to help you to make it happen. A typical home automation system allows one to control house hold appliances from a centralized control unit. These appliances include lights, fans, air conditioners, television sets, security cameras, electronic doors, computer systems, audio/visual equipment, etc. These appliances usually have to be specially designed to be compatible with each other and with the control unit for most commercially available home automation systems.

The project Smart Home Automation, demonstrates a system that can be integrated into a home/building’s electrical system and allows one to wirelessly control lights, fans, and turn on or off any appliance that is plugged into a wall outlet. The system can be controlled from a Bluetooth or Wi-Fi enabled device such as a mobile phone or laptop, while a microcontroller powered box act as the server. Thus the installation cost and hardware cost is kept to a minimum as most users already own the requisite hardware such as a mobile phone and desktop PC.

A Bluetooth dongle or a standard Wireless Access Point is used to provide connectivity between the server and the mobile device. The system is capable of detecting when the user enters or leaves the room by measuring the change in environmental thermal equilibrium, and can accordingly turn on or off appliances such as lights and fans. The power supply for each appliance is wired through an electromechanical relay. A number of relays are used depending on the number of appliances to be controlled. All the relays are controlled by a microcontroller. The microcontroller based host acts as the mmain server.. The server can also receive connections over the internet and can be controlled from a remote location. This opens up many possibilities. For example, one could remotely turn on the air conditioner from the office before leaving so that the room is cool before reaching home. Home automation can range in complexity from the simple gadgets and gizmos that provide control over individual components to individual home sub-systems and integrated whole house systems.

The project:
  1. Use five sensors to monitor the state of home namely temperature, light intensity,motion, LPG leak and door/window status.
  2. Use a host device that will be mounted on wall and will have connection to all your home appliances like lights, fans, etc and to all the sensors.
  3. Use “ANDROID” based smartphone, tablets as the user interface and control panel.
  4. The ANDROID client will use bluetooth to wirelessly connect to the host device.
  5. Simply logging in the android application will grant access to the user to control and automate his home wirelessly.

Step 2: BLOCK DIAGRAM

The block diagram of the project is shown if figure above. The main heart of the project that do all data processing and decision making is the microcontroller. Here it serves the purpose of data acquisition from the sensors and comparing then with the programmed values stored in the microcontroller’s EEPROM and then actuating the devices accordingly. A 16x2 character LCD is used for displaying the messages,  appliance state and sensor readings. It is directly connected to the microcontroller in 4-bit addressable mode. Whenever a new action or event is raised like fire alarm, LPG leak, etc it is displayed on the LCD too. Next we have the Bluetooth UART module connected to the serial port of the microcontroller. It act as an access point for the android client on the another side and logically it act as complete serial cable replacement for the serial port. The data is exchanged serially between the two devices. A LINK status pin to the microcontroller from the Bluetooth UART tells it that the android client is successfully connected to the host. Next, to control two light one inside and other outside the home , a fan/AC and a television we have four relays connected to the microcontroller via the NPN transistor based buffer circuit. The relays consume a lot current while being activated and the microcontroller on any pin can source only 20mA of current so a buffer circuit is utmost indispensable between the relay and the controller.

There are five types of sensors used in the project those are being directly interfaced to the microcontroller. To sense the light intensity we use two LDR sensors that is light dependent resistors interfaced to the ADC input of the microcontroller. To sense the temperature we used two solid state semiconductor temperature sensors from analog devices also interfaced to the ADC input of the microcontroller. To sense the LPG leak in the home we used the MQ-5 LPG sensor and it is interface to the ADC input of the microcontroller. After them, we used a hook switch to sense the door whether it is opened or closed. This sensor is connected to the digital input of the microcontroller pulled up externally. To sense the presence and motion we used the PIR (Pyroelectric InfraRed) sensor that has a digital output and it is also connected to the digital input of the microcontroller pulled up externally. The main door is driven by the geared DC motor and as it has to close and open the door, it has to be moved bi-direcionally. To do so, we used the NPN transistor based H-bridge bidirectional motor driver circuit interfaced to the digital output of the microcontroller. The microcontroller can digitally control the motion and direction of the motor to open and close the door. A software feedback is implemented between the motor and the door hook sensor output so that when the door reaches its max position and is being shut the motor stops driving the motor to prevent any damage.

Step 3: The Circuit Diagram

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The circuit diagram of the project is shown above in figure above. The starting from the power supply section, we have the 9V AC input from the secondary output of the transformer. This is the fed to the bridge rectification section that converts AC supply into DC supply. This is done by four 1N4007, 1 A diodes in bridge configuration. Then on the DC output of this section a large capacitor (1000uF, 16V)  and another small 100nF capacitor is there to filter the DC supply and remove off all AC components from it. This is because here we are operating pre digital circuitry that fails to operate on unregulated and unfiltered supply. After the DC supply is being filtered as it is unregulated is turned into a regulated 5V DC supply using LM7805 regulator. Again after that a small 100nF capacitor is there to filter the regulated DC supply. A regulated 3.3 volt supply is also derived from another regulator that is the UA78M33 whose input is fed from the regulated 5V output of the LM7805 voltage regulator. Regulated 5 volt supply is needed to drive the microcontroller, relays and all the sensors, while a regulated 3.3 volt is required by the Bluetooth UART module to operate. After that the regulated supply is fed to all the sensors ,relays and the microcontroller.

There are five types of sensors used in the project those are being directly interfaced to the microcontroller. To sense the light intensity we use two LDR sensors that is light dependent resistors interfaced to the ADC input of the microcontroller. One pin of the LDR is connected to Vcc via a 330K resistor and other tied to ground. This creates a potential difference in between of the circuit and is fed to pin A.3 and A.2 of the microcontroller respectively. To sense the temperature we used two solid state semiconductor temperature sensors from analog devices also interfaced to the ADC input of the microcontroller. The two pins are connected to the power supply to power the sensors and the third pin is the output pin is connected to the ADC7 and ADC6 channel of the microcontroller. To sense the LPG leak in the home we used the MQ-5 LPG sensor and it is interface to the ADC5 channel input of the microcontroller. When an LPG leak is detected the output of the LPG sensor decrease gradually and that is being sensed by the ADC of the microcontroller. After them, we used a hook switch to sense the door whether it is opened or closed. This sensor is connected to the digital input pin D.7 of the microcontroller pulled up externally.Whe the door is closed, the hook switch is closed and the output is logic low as it bypasses the ground. When the door is open, the hool switch is also open and it bypasses logic1 throught 10k resistor to the output. To sense the presence and motion we used the PIR (Pyroelectric InfraRed) sensor that has a digital output and it is also connected to the digital input (pinA.4) of the microcontroller pulled up externally. When a motion is detected ,the output goes high for a few seconds and comes back to low in case of absence of motion. The main door is driven by the geared DC motor and as it has to close and open the door, it has to be moved bi-direcionally. To do so, we used the four BC107 NPN transistor based H-bridge bidirectional motor driver circuit interfaced to the digital output of the microcontroller. The microcontroller can digitally control the motion and direction of the motor to open and close the door. To display messages and sensor values a 16x2 character LCD is used in 4 bit mode to portB of the microcontroller.

The H-bridge circuit is used to drive a DC motor in both the directions. It can also use relays to function but here we used the BJT based one. It comprises of four BC107 NPN transistors as shown in figure 2. The two transistor T1 and T2 are in series and those T3 and T4 are also in series. The base of all four transistors are protected y current limiting resistors R1-R4. The prevent damaging the transistors. The base signals of T1 and T4 are the same and that of T3 and T2 are also the same. The operation is simple that when Sig1 is logic 1 and Sig 2 is logic 0, it will turn ON T1 and T4 and will turn the motor in one direction same if we reverse the input logics, the motor will go in reverse direction. All four transistors are used as simple switches here.

Step 4: 5 PCB FOR THE PROJECT

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The PCB for the project is designed in EAGLE layout designer. The schematic is designed in the schematic editor and the board is designed in the board editor. The simple TONER TRANSFER METHOD is used here to develop PCB at home.

Step 5: Microcontroller code and algorithm used !!

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 The algorithm that is driving the code on the microcontroller is a multi-tasking algorithm. It has three basic functions, first is the main function to read all sensors and  actuate the actuators according to the programmed threshold values. Next is the timely updating of the LCD display and the transmission of encoded string serially to the android client if the android client is present. The last task is to check the input serial buffer for commands from the android client and process them accordingly.
When the microcontroller is powered up it reads the eeprom for recovery of all programmed sensomate values and device states that whether which device was ON/OFF the last time the power failed. Then after recovery, it read all the sensor readings and process them accordingly in meaningfull values.  After that the microcontroller checks the sensor readings against the programmed sensomate values and turns ON/OFF the appliances accordingly. The checking of fire occurance and LPG leak is done here in this main loop only. If there is a sign of fire or LPG leak, the microcontroller automatically switches off all the appliances and open the door to exhaust the gases and reduce emergency cricality. The sleep mode is also processed here in this loop. If the sleep mode is activated and motion is detected or someone open the door, the alarm fires and alert the user.
In the second loop, the microcontroller runs timer0 in interrupt mode and approx every 1.5 seconds it updates the LCD for sensor values and device states. The presence of the Bluetooth link is also displayed here. Also the microcontroller sends the encoded system status in a string serially to the bluetooth UART if the link is present. It is done every 0.8 second approximately. This loop is repeated infinitely as that of the main loop.

The third section programs the serial receive complete interrupt and thus whenever a serial command is received from the android client, it processes it here and actuate the command. This is again an infinite procedure and microcontroller keeps on sensing the arrival of new command.

The transmission and reception of commands to and from the android client is done wholesomely in ASCII code.

Step 6: The Android Application

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 The application for the android smartphone is wriiten completely in BASIC4ANDROID. BASIC4ANDROID is a BASIC high level language. Basic4android is a simple yet powerful development environment that targets Android devices.

Basic4android language is similar to Visual Basic language with additional support for objects.Basic4android compiled applications are native Android applications, there are no extra runtimes or dependencies. Unlike other IDEs Basic4android is 100% focused on Android development. Basic4android includes a powerful GUI designer with built-in support for multiple screens and orientations. No XML writing is required. You can develop and debug with the Android emulator or with a real device (USB connected or over the local network). Basic4android has a rich set of libraries that make it easy to develop advanced applications.

The android application so designed is fully applicable of controlling your home. There are a total of six screens including the screen containing the authors name. The application is a little bit voice acknowledged. Whenever you click on the help menus, it tells you about the particular with the voice acknowledgemnt too.

FIG 1 This screen displays a boot animation on startup when you click the Smarthome application icon. Along with the animation, an audio message and welcome can be heared in the background.

FIG 2 This is the manual appliance control screen. Here you can manually turn ON/OFF each appliance individually or can simultaneously switch all ON/OFF in one go.
The particular device so controlled manually will disable its sensomate feature automatically. The button label shown in blue shows the status of the device.

FIG 3 This is the sensors monitoring window. From here you can see all the sensor readings and also save them in a text file in the ROOT/smarthome folder of your android smartphone. You can activate/deactivate the sleep mode from here only.

FIG 4 With this window ,you can check the status of your door whether it is open/close. You can also open or close the door from here.

FIG 5,6 From this Sensomate (Sense and automate) window, you can program the threshold values for your two lights and fan. You can also program your motion sensor to raise an alarm if it detects a motion.

FIG 7 This is the settings window. From here you can turn Bluetooth ON/OFF manually. You can manually connect to the android host from the paired list. You can change the login password here and program the threshold value for the fire alarm to raise.

FIG 8 This screen displays the author involved in developing the application.

The android app currently supports 320x240 resolution screens,but with a simple designer code script it can be modified to suit any screen size.

HD TV ANTENNA AT HOME



























TV Antennas have been around for many years - and people have tried all sorts of unsightly things to "fix" them or make them work better - anything from attaching a metal clothes hangar to aluminum foil! I realized it doesn't work and I don't want to waste my money on more of these faulty antennas. Sometimes the best way to fix something is to Do It Yourself!!!

I decided to get rid of cable television many months ago. My local cable company convinced me to pay $10 a month for local channels - it seemed alright. Antennas seemed to be a thing of the past - didn't even think about trying to use one. So, a few months went by and the lovely cable company raised my local channel price to $35 a month; ridiculous for a few channels. I got rid of it and purchased an antenna. The first one hardly got a channel - and it had horrible reception. Wasted money on a second one - which I used for a while. But, if my cat would walk near the window, the channels wouldn't work. I'd have to move the thing constantly to try to get reception - even then it would go out many times. I put aluminum foil all over it and looked crazy and horrendous - and that didn't help. I really wanted to watch Masterchef!

So, I researched all over the web and I found some info on how to make a modern-looking HDTV antenna out of cardboard and aluminum foil. I mentioned it to my dad and he laughed at first - but after he heard about how mine turned out, he wants me to make him one! I read a ton of comments from people who had made this type of antenna, and they were raving about how it was better than their high-end $70 one! So, I must give big thanks and credit to the guy who created this design here - thank you so much for sharing this with the world! You can also get the template there as well. The instructions were great, but I am not good with electronics and the fact that I was able to do this - means it is simple! I hope my guide here and pictures will help those who are like me, and need things broken down even more. I tried to take lots of clear pictures.

Before we start, I just want to say that after plugging this in, without even placing it up high or in any certain direction or special location - I got more channels than I've ever received on that TV. I have more channels than what I had when I paid the cable company for them! They are all crystal clear - I love it! Also, don't forget to rescan for channels after hooking this up - that also increased the number of channels I received.



Step 1: Materials Needed for HDTV Antenna



















Materials:
  • A few feet of cardboard
  • Cardboard cutting Materials - scissors and box-cutter work well
  • Aluminum Foil
  • Glue (I used wood glue - it's super strong)
  • Drill
  • two screws with nuts and washers
  • 75 to 300 Ohm UHF/VHF Matching Transformer (about $5 online or $6 at Radio Shack) - here is a popular one on Amazon: 75 to 300 Ohm UHF/VHF Matching Transformer
  • 4 or 6 foot coaxial cable (any size is fine as long as it reaches) - if you don't have one, here's one on Amazon: Coaxial Cable (4 Feet)
  • *Optional: paint, markers or special paper to decorate the front of it
Pattern:
You can download the pattern for the cardboard and aluminum foil pieces here - at the designer's site. Thanks again to the designer for making that available! We really appreciate it! Keep reading to follow my own step-by-step process for making this! And, thanks to all the commenters for your insight and extra ideas!
Holly Mann is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.

Step 2: Cut out Main Piece for HDTV Antenna

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
First you will need to cut out a piece of cardboard that is 13 x 14 inches. There is no pattern for this one. After cutting it out, then you'll want to attach aluminum foil to the back of it. I used my wood glue sparingly and attached the foil and smoothed it out. Then, flipped it over and painted it. If you want to decorate the front with markers or construction paper, feel free to do that. I then set it aside to let it dry.

If you haven't printed out your pattern yet, please do so.

Step 3: Cut out Pieces for Antenna

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 First cut out your pattern pieces. Then take the pattern for the cardboard and lay it onto the cardboard. You may want to secure it down with a couple pieces of tape. Then, trace the pattern and cut it out. I used my box cutters to cut it out. You need two cardboard pieces cut out which contain the main longer piece and two wings that are attached. You should also cut out two of the mounting bracket pieces.

After cutting out the cardboard pieces, then you'll need to do the same with the foil. Use a scissors, not box cutters for this as they tend to cause ripping. You don't want to tear the foil at all.

At this point you should have two main cardboard pieces with the wings on them, two foil pieces which look similar to the cardboard ones and two mounting brackets. There is also a pattern piece for a stand if you want to use it you can.

Step 4: Shaping the Wings

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 If you notice on the pattern pieces for the wings, you will see that there are dashed lines which represent score marks. Try to fold the pattern inward and mark with a pencil onto your carboard wings where these lines are. Then, carefully and slowly take your box cutters and cut into the cardboard (but not all the way). Be careful! Once you do all four score marks, then flip the cardboard over and you can shape the wings properly. See image for details on how to do that.

After shaping it the way you want it, then add a little glue to the scored area to keep it secure. The sides of each wing should make an angle of approximately 90 degrees to each other. They're likely to spread out a little though - so to secure it at the correct angle, you should use some glue and hold it to dry. Hot glue would be good for this.

Step 5: Glue Foil to Back of Pieces

Now you'll want to carefully glue the main foil pieces with the wings on them, to the back of the cardboard winged pieces. Please note that the foil will not cover all of the long middle cardboard piece - as it is smaller than the cardboard piece. It will be flush with the side that is closest to the wings. Try to make the foil lay flat and smooth it out as much as possible. It's best to use a thin layer of glue. Set it aside to let it dry for a little while.

Step 6: Painting and Mounting Brackets

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
At this point, I painted the mounting brackets. Then, I checked if the main piece which is 13 x 14 inches was dry. Once it was dry, I then set it in front of me so that it was 13 inches long (from left to right) and 14 inches tall. I then used the pattern to cut out the areas where the brackets would go. I traced this area and then carefully used the box cutters to cut them out.

Next, I painted the other two main pieces which had the wings on the sides. I let that sit for a while to dry. Then, I took the mounting brackets and placed them in the slots. Please see images. I basically turned the mounting bracket sideways so I could get it into the hole in the main piece, then straightened it out. I made sure to keep it at the top of the rectangular hole and it stuck out quite far in the front of the main piece. If the slits in the sides of the mounting brackets are too small and the fit is too tight, feel free to cut them a little larger so it fits nicely. You can then add a few drops of glue to the sides of it and to the area where the box is folded outward holding it up. This just makes it even more secure.

Once everything is solid and dry, you can then attach the main pieces to the body.

Step 7: The Wiring for the Antenna

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
First, attach the two main side pieces with the wings to the mounting brackets at the slots. If you need to make the slots larger to make it fit well, you can do that. It's a good idea to add a couple drops of glue to secure it where the mounting bracket meets the main pieces. Then let it dry.

Lastly, the wiring is actually very simple. You'll see on the pattern piece that there is a circle on the pattern to show the center of the long cardboard piece that goes along the middle of the antenna. The circle is about 1/8 to 1/4 of an inch in from the side. Use your pattern to mark that spot on your two main winged pieces. Then, use a drill to make two holes through those spots. Then the screws will need to be put through those holes. Then, take out your transformer which has the coax plug on one side and twin lead on the other. Take the twin lead wires - place washers on the back side of where the screws were put through the cardboard, then attach one of the wires from the transformer and tighten it on with a bolt. Do the same for the other side with the screw. You'll now have the transformer hanging there - and ready to be plugged in!

Take it over to your TV and plug in your coaxial cable to the other end of the transformer. Take the other end of the coax and plug it into your TV antenna spot. That's it!!! You are done!

This antenna is amazing and completely surpassed all my expensive store-bought ones! If you have any questions, please feel free to ask! This project saved me a lot of money and I no longer have to deal with the old antenna problems and annoyances. I had a lot of issues with my antenna(s) and now I know I can make more of these (and this can be modified) for my other TVs in the house. Let me know how yours turn out too!

LinkWithin

Followers