Tuesday, March 13, 2018

LIGHT CONTROL VIA RASPBERRY PI



HOW CONTROL LIGHT VIA INTERNET USING RASPBERRY PI
There was no denying that the development of the Internet in the present very rapid. Even was also very vital role. Almost all of society, starting from the top, middle, until the bawahpun've been able to use the internet. You could say the Indonesian community dependence on the Internet is very high. Especially the use of a wide range of social media such as Facebook, Twitter, Instagram, Line, WhatsApp , and much more. Of course, to use all social media was in need of an internet connection. Besides being used for social media, other internet usage is as a medium for surfing the internet, browsing, streaming, uploading, downloading etc. In other words, in the current era is arguably the era "Internet Of Things "or better known by the acronym (IOT). One use of the IOT technology is a system of media control and monitoring of a wide range of electronic devices. Based on the types of electronic devices and their use is divided into two, namely sensors and actuators. Sensors provide feedback to the control system in the form of data, both digital and analog data. While the actuator requires data / commands in order to make himself working / running. Data / commands that are needed can be analog data or digital data.
In this application will be made technology Internet Of Things simple, home lighting control via a web server and can be accessed via the internet. There are 4 lights AC to be used as a prototype of ambient light that is in a house. Fourth lights will be controlled via the website . In this application using the Raspberry Pi 3 as the main controller.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/1.jpg
Figure 1. Illustration Simple Ways Systems Work

EQUIPMENT AND MATERIALS
  1. 1x DW Raspi Development Kit (Raspberry Pi 3 dan DT I/O Quad Relay)
  2. 4x Fitting Lampu
  3. 4x Light Bulbs
  4. 1x Plug AC (AC plug)
  5. 6x Konektor Male to Male
  6. enough cable

I. DW Raspi Development Kit
Dw Raspi Dev Kit is a package of learning and development of Raspberry Pi, which is composed of several modules. Here are the modules and sensors on the Dev Kit Raspi DW:
  1. Raspberry Pi 3
  2. Adaptor 5 Volt 2,5 Ampere
  3. Micro SDHC class 10 16 GB
  4. EMS Logger Pi Shield
  5. DT I/O Quad Relay Board
  6. DHT11 sensors (temperature and humidity sensors)
In this application module that will be used is the Raspberry Pi 3, 5-volt adapter, MicroSD, and DT I / O Quad Relay Board. Here is a picture of DW Raspi Development Kit.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/2.jpg
Figure 2. DW Raspi Development Kit

II. Fitting Lampu AC
Fitting the lamp AC is one of the electrical accessories are already familiar. Fitting is used as a medium or point of liaison between the light bulb and the AC Plug (plug) which is connected to the grid voltage of 220 VAC. There are a wide variety of modes of fitting the lamp AC. Figure 3 shows some of the types of variations of fitting the lamp.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/3.jpg
Figure 3. Variation Form Of Fitting Lamp AC

III. Light bulbs
The light bulb is also one of the electrical component that is not foreign to us. Of course, when talking about the light bulb must remember one hero who can be said to have illuminate this world of darkness?. O Who he? ... That's right, She is Thomas Alva Edison. It was he the first in the world to create the incandescent light bulb. For his services to the amazing technology that is now already enjoyed by all citizens of the world without exception. Light bulb technology development to date has been very sophisticated. If in ancient times the size of the lamp is relatively large and require greater power. Now the size is relatively smaller bulb with small power consumption as well, and also can produce the light intensity is big enough.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/4.jpg
Figure 4. Type and Model Bulb Lamp

Block Diagram Applications Lighting control Home Through Internet
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/5.jpg
Figure 5. Block Diagram Applications Lighting control Home Through Internet

Based on the block diagram in Figure 5 above, may explain the workings of the application to control the lights over the Internet. Starting from a light bulb, which must be known is how to keep the light bulb can be lit and turned out the light bulb will turn on when the AC voltage gain 220. In general, an electric voltage 2 phase has two lines that should be connected. To turn off and turn on the light bulb, simply disconnect and connect one of two paths. Because it requires AC power, use the module relay to connect and disconnect the pathway. Then the trigger to activate the relaytaken from Raspberry Pi GPIO. Thus we are able to control the flame bulb through the Raspberry Pi and set the pin which will be used as an output. To set the pin mapping which will be used as inputs and which will be used as output , used programming languages. In this application, the programming language used is the language " python ". Why use the language python ? One of the reason is to use the language python we can access and control the features of the raspberry pi. Which further facilitates more were contained librarieswhich is already available on the forums about the programming language Raspberry Pi using python . Then the other reason is to use programming python can be connected to the Internet (it can be connected to the page website as you wish). Figure 5 below is a schematic wiring diagram of the system being designed.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/6.jpg
Figure 6. Schematic Diagram Wiring Systems

Preparing Raspberry Pi 3
After completing the wiring of all modules and components required in the system. Next is preparing the installation of Raspberry Pi 3. Of course, we must prepare a microSD that already contains the Operating System Raspbian Jessie . Application programs to be installed is the python programming . Here are the steps for Men- download and install python on Raspberry Pi. Make sure the wifi was able to connect to the Internet.
sudo apt-get update
sudo apt-get upgrade

The above command is a command used to perform updates and upgrades to the features of OS Raspbian. This process typically takes a few minutes depending on the Internet connection used. The faster the internet connection, it will be the sooner the process of updating and upgrading . The next step is to download and install python .
sudo apt-get install python

Wait a few minutes until the process of downloading and installing complete. We can see the result of the installation of the application menu on the raspberries. Figure 7 is a view of application programming menu for IDLE python .
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/7.jpg
Gambar 7. Programming Python

Meanwhile, to be able to control the hardware / GPIO on raspberry pi, we need a library that is RPI.GPIO. Library contains commands that will be used to set the GPIO of Raspberry Pi. Whether there will be in settting as inputs or outputs in accordance with our wishes. The command used to add libraries rpi.gpio is as follows.
sudo apt-get install python-rpi.gpio

If the steps above have been running smoothly and successfully to stage the addition of library rpi.gpio, the Raspberry Pi is ready for use.

Preparing Website.
The procedure for the making of a website certainly is not foreign to the comrades who studied computer science and informatics. In general, if you want to create a website with nice amenities and also bandwidth is great to be charged. But do not worry, many providers layananan of making a website that is free. Surely facilities, capacity and bandwidth provided is also not as much and for websites that pay. However, it was enough for the novice to learn to be creative with making websites . At this time applications, we use the websitethat is free provided by one of the service providers of website creation services / hosting that is idhostinger. For how pendaftaranya can follow the steps on the following link: https://www.hostinger.co.id/forum/register . If you have finished registering and making new hosting, then the next step is to perform on the hosting arrangement to create the look of the website . This can be done by going to the menu bar Hosting - select a hosting account - click on the option to manage. As shown in Figure 8 below.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/8.jpg
Figure 8. Set Hosting Account

After the click selection of governance will emerge a new look, as shown in Figure 9. Typing " file " in the search field and select and click on " file manager ".
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/9.jpg
Figure 9. File Manager Hosting Account

Wait a while and you will see several folders. Select and click on the folder "public_html" and delete the file php that are in the folder "public_html". See Figure 10 to Figure 13 below.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/10.jpg
Figure 10. Sign public_html folder

Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/11.jpg
Figure 11. Delete File PHP

If the removal process file PHP is successful, then the next step is to upload all the files that are in the folder " website ". Folders can be downloaded at the following link: https://drive.google.com/open?id=0BzkNNhuEnaF-MFBna29oNENlcjg
Upload all files contained in the folder " forum " to " file manager " in the hosting account on the folder " public_html " as shown in Figure 12 below.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/12.jpg
Figure 12. Upload All Files In Folder Website

The process of preparation of the website has been completed. If the comrades to follow step by step to the right, then to see his website address would look something like Figure 13 below.
Description: http://digiwarestore.com/img/cms/berita/an59-kendali-lampu-internet-respberry/13.jpg
Figure 13. Display Website For Controlling Lighting Home

Running Python Programs
Copy the file with the python language program IOTraspi.py name. File this program can be obtained together from folder "site" that has been downloaded previously. Put / paste the files on your Raspberry, place it in the directory -> / home / pi. Then open the program file through the terminal Raspberry.
sudo nano IOTraspi.py

Change website address matches the address that will be used for controlling. The trick is as follows.
url = ‘alamat_website/IOTraspi.txt'

As an example we use the website address is http://iotraspberry.pe.hu then how penulisanya is
url = 'http://iotraspberry.pe.hu/IOTraspi.txt'

Once finished, save your file IOTraspi.py python program and exit from the editing process. Run the python program with the following command.
Sudo python IOTraspi.py

Make sure there are no errors during program run python. When the program has been running without error, then is open the previous web page and start your home light control through the website. Easy is not it?
Congratulations to innovate.