PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI TUGAS AKHIR
PENGENDALI LAMPU DAN PINTU GARASI DENGAN BLUETOOTH BERBASIS MIKROKONTROLER Diajukan untuk memenuhi salah satu syarat memperoleh gelar Sarjana Teknik pada Program Studi Teknik Elektro
disusun oleh : DWI CAHYA MARYANTO NIM : 115114022 PROGRAM STUDI TEKNIK ELEKTRO JURUSAN TEKNIK ELEKTRO FAKULTAS SAINS DAN TEKNOLOGI UNIVERSITAS SANATA DHARMA YOGYAKARTA 2016
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI FINAL PROJECT
LAMP AND GARAGE DOOR CONTROL USING BLUETOOTH BASED ON MICROCONTROLLER In partial fulfilment of the requirements for the degree of Sarjana Teknik Electrical Engineering Study Program
DWI CAHYA MARYANTO NIM : 115114022
ELECTRICAL ENGINEERING STUDY PROGRAM ELECTRICAL ENGINEERING DEPARTMENT FACULTY OF SCIENCE AND TECHNOLOGY SANATA DHARMA UNIVERSITY YOGYAKARTA 2016
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI HALAMAN PERSETUruAN TUGAS AKHIR
PENGENDALI LAMPU DAN PINTU GARASI DMNGAN BLUE
#
BERBASIS
ffi.Er*+\ di,,fud,r,, -*
flB fuF r*
ffioJIIj**
Pembimbing
Tanggal
lll
:
2f
- t - 2nt4
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI HALAMAN PENGESAHAN TUGAS AKHIR
PEI\GENDALT LAMPU T}AN PINTU GARASI
DEI{GAN BLUETOOTH BIRBASIS
MIKROKONTROLER disusun Oleh
:
DWI CAHYA MARYANTO
NIM : 115114022 Telah dipertahankan di depan panitia penguji pada tanggal .!3.-^..!..:. .IP\G dan dinyatakan memenuhi syarat Susunan Panitia Penguji
:
Nama Lengkap Kefua
Petrus Setyo Prabowo, S.T., M.T.
Sekretaris
Ir. Tjendro, M,Kom
Anggota
Djoko Untoro Suwarno, S.Si., M.T.
Yogyakart u, ..??.. .1.1 .Y.'.f.i....20 tas Sains dan Teknologi Ltas Sanata Dharma
li
{
li
..u
\t*??I ))
1.1.'dlr
ingsih Prima Rosa, S.Si., M.Sc.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
PERNYATAAN KEASLIAN KARYA "Saya menyatakan dengan sesungguhnya bahwa tugas akhir ini tidak memuat karya ataubagian karya orang lain,
kecuali yang telah disebutkan dalam kutipan dan daftar pustaka sebagaimana laYaknYa karya
ilmiah"
Yogyakart u,
.l:.! -201L
Dwi Cahya Maryanto
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
HALAMAN PERSEMBAHAN DAN MOTO HIDUP
MOTTO BUKAN ESOK, LUSA ATAU BAHKAN TAHUN DEPAN , DARI SEKARANGLAH HARUS DIMULAI.
DWI CAHYA MARYANTO
Karya ini kupersembahkan untuk…….. Tuhan Yesus Kristus, Pembimbing dan Pemberi Harapan ku, Keluarga Tercinta, Teman-teman yang luar biasa TE 2011, Dan semua pihak yang telah terlibat dalam proses penulisan ini
vi
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
HALAMAN PERNYATAAN PERSETUJUAN PUBLIKASI KARYA ILMIAH UNTUK KEPENTINGAN AKADEMIS Yang bertanda tangan di bawah ini, saya mahasiswa Universitas Sanata Dharma Nama
:
:
DWI CAHYA MARYANTO
Mahasiswa : 115114022 Demi pengembangan ilmu pengetahuan, saya memberikan kepada Perpustakaan Nomor
Universitas Sanata Dharma karya ilmiah saya yang berjudul
:
PENGENDALI LANIPU DAN PINTU GARASI DENGAN BLUETOOTH BERBASIS MII(ROKONTROLER Beserta perangkat yang diperlukan (bila ada). Dengan demikian, saya telah memberikan
kepada Perpustakaan Universitas Sanata Dharma hak untuk menyimpan, mengalihkan dalam bentuk media lain, mengelolanya dalam bentuk pangkalan daia, mendistribusikan secara terbatas, dan mempublikasikannya
akademis tanpa perlu meminta
di internet atau media lain untuk kepentingan
ijin dari saya maupun
memberikan royalti kepada saya
selama tetap mencantumkan nama saya sebagai penulis.
Demikian pernyataan ini saya buat dengan sebenarnya.
Yo gyakart u,..V..:...1
:.1-o-{!.
DWI CAHYA MARYANTO
vl1
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
INTISARI Dalam perkembangan zaman yang pesat, perkembangan teknologi juga berkembang sangat pesat. Teknologi yang digunakan sudah aplikatif dan bisa digunakan secara mudah untuk kepentingan manusia. Contohnya adalah teknologi Bluetooth. Teknologi Bluetooth ini dapat digunakan sebagai teknologi pengiriman data tanpa kabel dalam jarak tertentu. Sebagai mahasiswa elektro yang bertanggung jawab akan keilmuanya terhadap masyarakat, terutama dalam bidang control. Berfikir untuk menggabungkan keilmuanya dengan teknologi Bluetooth untuk mempermudah masyarakat dalam pengendalian alat-alat yang sederhana, dibentuklah sistem kontrol yang dapat mengontrol lampu dan pintu garasi menggunakan Bluetooth. Prinsip kerja dari sistem ini adalah sebagai berikut. Dengan menggunakan handphone data akan dikirim ke modul Bluetooth dan nantinya akan diteruskan ke mikrokontroler. Data yang dikirim yaitu buka dan tutup pada pintu garasi serta hidup dan mati pada lampu. Data yang sudah dikirim kemudian diterjemahkan oleh mikrokontroler untuk mengatur lampu dan pintu garasi. Setelah perintah dijalankan oleh lampu atau pintu garasi, akan ada feedback dari mikrokontroler ke module Bluetooth. Data feedback kemudian dikirim kembali ke handphone yang nantinya akan diolah oleh Android sebagai data indikator feedback. Hasil akhir dari penelitian ini adalah dapat dihasilkanya sistem pengontrolan menggunakan handphone yang dihubungkan ke mikrokontroler untuk mengontrol pintu garasi dan lampu.
Kata kunci: pengiriman dan penerimaan data, teknologi Bluetooth, mikrokontroler, kontrol pintu garasi dan lampu, feedback data.
viii
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
ABSTRACT In the modern era, technology development is growing rapidly. The technology is now applicable and can be used easily for the benefit of humans. For example is the Bluetooth technology. Bluetooth technology can be used as a wireless data transmission technology within a certain distance. As an electrical engineering student is responsible for his knowledge for the people, especially in control. Combining the knowledge with Bluetooth technology to facilitated the public in controlling tools, formed a system controller that can control lights and garage door using Bluetooth. The system’s principle will be explained in here. By using mobile phone, the data will be sent to the Bluetooth module and will be forwarded to the microcontroller. Data will be use to open and close the garage door as well as turn on and turn off on the lights. Then, it will be translated by the microcontroller to control the lights and garage doors. Once the command is executed by the lights or the garage door, then there will be a feedback from the microcontroller to the Bluetooth module. Feedback data is sent back to the mobile phone which will be processed by the Android as an indicator feedback data. The final result of this research is it can control a system using a cell phone connected to microcontroller to control garage door and light. Keywords: sending and receiving data, bluetooth technology, microcontroller, garage door and lighting control, feedback data.
ix
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
KATA PENGANTAR Puji dan syukur kepada Tuhan Yang Maha Esa yang telah memberikan kenikmatan berupa kesehatan jasmani dan rohani sehingga penulis dapat menyelesaikan tugas akhir dengan lancar dari awal hingga diakhiri dengan munculnya laporan tugas akhir dengan judul “PENGENDALI LAMPU DAN PINTU GARASI DENGAN BLUETOOTH BERBASIS MIKROKONTROLER”. Dalam pembuatan laporan tugas akhir dari awal hingga akhir tentunya ada bantuan dari beberapa pihak sehingga laporan tugas akhir yang disusun oleh penulis sesuai dengan ketentuan yang ada. Dengan adanya bantuan dari beberapa pihak, penulis dapat menyelesaikan laporan tugas akhir tersebut, penulis mengucapkan terima kasih kepada beberapa pihak diantaranya adalah sebagai berikut : 1. Tuhan Yang Maha Esa yang telah memberikan kenikmatan berupa kesehatan jasmani dan rohani. 2. Kedua orang tua dan saudara penulis yang telah mendukung dan memberikan doa restu. 3. Bapak Petrus Setyo Prabowo, S.T., M.T., sebagai Ka. Prodi Teknik Elektro Universitas Sanata Dharma Yogyakarta. 4. Bapak Ir.Tjendro, M.Kom., sebagai Dosen Pembimbing dengan penuh perhatian dan pengertianya serta rela meluangkan waktunya unutk membimbing hingga akhir 5. Ibu Ir. Theresia Prima Ari Setiyani, M.T., sebagai Dosen Pembimbing Akademik Prodi Teknik Elektro Fakultas Sains dan Teknologi Universitas Sanata Dharma. 6. Teman-teman TE 2011 yang telah banyak membantu baik lahir maupun batin. 7. Semua pihak yang telah memberikan bantuan dalam penyusunan Laporan tugas akhir ini.
Dalam penyusunan laporan tugas akhir ini tentunya terdapat kekurangan dan kelemahan serta jauh dari kata sempuna. Karena kesempurnaan hanya milik Tuhan semata. Oleh karena itu penulis menerima masukan berupa kritik dan saran dengan harapan menjadikan penulis lebih baik lagi.
x
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Semoga Laporan tugas akhir ini dapat diterima dengan baik oleh semua pihak. Dan
semua kekurangan yang ada dapat dimakiurni. Semoga Laporan tugas akhir
ini dapat
mernberikan manfaat kepada penulis dan pen-rbaca
Yogyakarla,
q' 1 - 2olL
Dwi Cahya Maryanto
x1
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
DAFTAR ISI HALAMAN JUDUL............................................................................................................. i HALAMAN PERSETUJUAN ........................................................................................... iii HALAMAN PENGESAHAN ............................................................................................ iv PERNYATAAN KEASLIAN KARYA.............................................................................. v HALAMAN PERSEMBAHAN DAN MOTTO HIDUP ................................................. vi HALAMAN PERNYATAAN PERSETUJUAN PUBLIKASI KARYA ILMIAH UNTUK KEPENTINGAN AKADEMIS......................................... vii INTISARI .......................................................................................................................... viii ABSTRACT.......................................................................................................................... ix KATA PENGANTAR ......................................................................................................... x DAFTAR ISI ...................................................................................................................... xii DAFTAR GAMBAR ......................................................................................................... xv DAFTAR TABEL ........................................................................................................... xviii
BAB I : PENDAHULUAN 1.1
Judul ............................................................................................................................. 1
1.2
Latar Belakang ............................................................................................................. 1
1.3
Tujuan dan Manfaat .................................................................................................... 2
1.4
Batasan Masalah........................................................................................................... 2
1.5
Metodologi Penelitian .................................................................................................. 3
BAB II : DASAR TEORI 2.1
Android ........................................................................................................................ 4 2.1.1 Ice Cream Sandwich(Android 4.0-4.0.4)............................................................ 4
2.2
Bluetooth ...................................................................................................................... 4 2.2.1 Bluetooth Android .............................................................................................. 4 2.2.2 Modul Bluetooth HC-05 ..................................................................................... 5
2.3
ATmega 8535............................................................................................................... 6 2.3.1 USART................................................................................................................ 7 2.3.2 Phase Correct PWM.......................................................................................... 11
xii
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 2.3.3 Timer/Counter Control Register A.................................................................... 11 2.3.4 Timer/Counter Control Register B.................................................................... 12 2.4
Driver Motor .............................................................................................................. 13 2.4.1 L298.................................................................................................................. 13
2.5
Sensor Cahaya............................................................................................................ 14 2.5.1 Light Dependent Resistor.................................................................................. 14
2.6
Rangkaian Saklar ....................................................................................................... 14 2.6.1 Limit Switch ...................................................................................................... 14 2.6.2 Modul Relay ..................................................................................................... 14
2.7
Resistor Pull Up ......................................................................................................... 15
BAB III : PERANCANGAN 3.1
Pemodelan Sistem Secara Keseluruhan ..................................................................... 16
3.2
Rangkaian Perangkat Keras ....................................................................................... 17 3.2.1 Module Bluetooth dengan ATmega 8535 ......................................................... 17 3.2.2 Lampu dan Sensor Lampu ................................................................................ 17 3.2.3 Driver dan Motor DC ........................................................................................ 18 3.2.4 Rangkaian Saklar .............................................................................................. 18
3.3
Perancangan Perangkat Lunak ................................................................................... 19 3.3.1 GUI ................................................................................................................... 19 3.3.2 Pengaktifan Bluetooth ...................................................................................... 19 3.3.3 Flow Chat Android pada Handphone............................................................... 20 3.3.4 Flow Chat Mikrokontroler................................................................................ 21 3.3.5 Flow Chat Sub Rutin Aktifkan Lampu............................................................. 22 3.3.6 Flow Chat Sub Rutin Aktifkan Pintu Garasi .................................................... 22
BAB IV : HASIL DAN PEMBAHASAN 4.1
Hasil Implementasi Alat............................................................................................. 24
4.2
Hasil Perancangan Perangkat Keras........................................................................... 25
4.3
Hasil Perancangan Alat dan Sistem ........................................................................... 26 4.3.1 Letak limit switch .............................................................................................. 26 4.3.2 Penggunaan Modul HC-05................................................................................ 28 4.3.3 Pemilihan Arduino Menggantikan ATmega 8535 ............................................ 29
xiii
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 4.4
Hasil Perancangan Menggunakan Arduino................................................................ 31 4.4.1 Pengujian Motor................................................................................................ 31 4.4.2 Pengujian Lampu .............................................................................................. 31 4.4.3 Pengujian Sensor............................................................................................... 32 4.4.3.1 Pengujian Limit Switch................................................................................ 32 4.4.3.2 Pengujian LDR............................................................................................ 33
4.5
Pengujian Sistem........................................................................................................ 33 4.5.1 Connect ............................................................................................................. 33 4.5.2 Garasi ................................................................................................................ 39 4.5.3 Lampu ............................................................................................................... 42 4.5.4 Pengujian Feedback Error ............................................................................... 46
4.6
Analisis Percobaan ..................................................................................................... 47
BAB V : KESIMPULAN DAN SARAN 5.1
Kesimpulan ................................................................................................................ 49
5.2
Saran........................................................................................................................... 49
DAFTAR PUSTAKA ........................................................................................................ 50
xiv
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
DAFTAR GAMBAR Gambar 1.1 Prototipe garasi .................................................................................................. 3 Gambar 2.1 HC-O5 ............................................................................................................... 5 Gambar 2.2 Koneksi HC-05 .................................................................................................. 5 Gambar 2.3 ATmega 8535 .................................................................................................... 6 Gambar 2.4 UDR................................................................................................................... 7 Gambar 2.5 UCSRA ............................................................................................................. 7 Gambar 2.6 USCRB .............................................................................................................. 8 Gambar 2.7 UCSRC .............................................................................................................. 9 Gambar 2.8 UBRRH dan UBRRL ...................................................................................... 10 Gambar 2.9 Phase correct PWM ......................................................................................... 11 Gambar 2.10 TCCR1A ........................................................................................................ 11 Gambar 2.11 TCCR1B ........................................................................................................ 12 Gambar 2.12 Modul L298 ................................................................................................... 13 Gambar 2.13 LDR ............................................................................................................... 14 Gambar 2.14 Limit switch.................................................................................................... 14 Gambar 2.15 Modul relay.................................................................................................... 15 Gambar 2.16 Rangkaian pull up LDR dan limit switch....................................................... 15 Gambar 3.1 Pemodelan lengkap.......................................................................................... 16 Gambar 3.2 Modul Bluetooth dan mikrokontroler ATmega 8535...................................... 17 Gambar 3.3 Sensor lampu ................................................................................................... 17 Gambar 3.4 Driver motor dan motor dc ............................................................................ 18 Gambar 3.5 Rangkaian saklar.............................................................................................. 18 Gambar 3.6 GUI garasi........................................................................................................ 19 Gambar 3.7 Flow Chart Handphone ................................................................................... 20 Gambar 3.8 Flow chart di sitem penerima .......................................................................... 21 Gambar 3.9 Flow chart sub rutin lampu ............................................................................. 22 Gambar 3.10 Flow Chart sub rutin pintu garasi.................................................................. 22 Gambar 4.1 Alat secara keseluruhan ................................................................................... 24 Gambar 4.2 GUI(Graphic User Interface) .......................................................................... 24 Gambar 4.3 Rangkaian limit switch atas ............................................................................. 25
xv
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Gambar 4.4 Rangkaian limit switch bawah ......................................................................... 25 Gambar 4.5 Rangkaian LDR ............................................................................................... 25 Gambar 4.6 Module Bluetooth ............................................................................................ 26 Gambar 4.7 Rangkaian L298............................................................................................... 26 Gambar 4.8 Model penempatan limit switch pertama ......................................................... 27 Gambar 4.9 Limit switch dengan tuas yang diperpanjang ................................................... 27 Gambar 4.10 Model penempatan limit switch kedua .......................................................... 27 Gambar 4.11 Model penempatan limit switch ketiga .......................................................... 28 Gambar 4.12 Model penempatan limit switch keempat ...................................................... 28 Gambar 4.13 Program Pengendali motor dc searah jarum jam........................................... 31 Gambar 4.14 Program Pengenadali motor dc berlawana arah jarum jam ........................... 31 Gambar 4.15 Program pengendali lampu ............................................................................ 31 Gambar 4.16 Serial monitor untuk limit switch tidak ditekan............................................. 32 Gambar 4.17 Serial monitor untuk limit switch sudah ditekan ........................................... 32 Gambar 4.18 Serial monitor LDR dengan cahaya............................................................... 33 Gambar 4.19 Serial monitor LDR tanpa cahaya.................................................................. 33 Gambar 4.20 List program connected ................................................................................. 34 Gambar 4.21 List fungsi SendData()................................................................................... 35 Gambar 4.22 List program Arduino .................................................................................... 35 Gambar 4.23 List program cek_awal()................................................................................ 36 Gambar 4.24 List fungsi terimaData()................................................................................. 37 Gambar 4.25 GUI feedback dari connect ............................................................................ 39 Gambar 4.26 List program tombol buka ............................................................................. 39 Gambar 4.27 List fungsi buka_pintu() ................................................................................ 40 Gambar 4.28 GUI feedback indikator buka......................................................................... 41 Gambar 4.29 List tombol tutup ........................................................................................... 41 Gambar 4.30 List fungsi tutup_pintu() ................................................................................ 41 Gambar 4.31 GUI feedback indikator tutup ........................................................................ 42 Gambar 4.32 List progam hidup.......................................................................................... 43 Gambar 4.33 List fungsi hidup_lampu() ............................................................................. 43 Gambar 4.34 GUI feedback indikator hidup ....................................................................... 44 Gambar 4.35 List program tombol mati .............................................................................. 44 Gambar 4.36 List fungsi mati_lampu() ............................................................................... 45
xvi
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Gambar 4.37 GUI feedback indikator mati ......................................................................... 45 Gambar 4.38 GUI feedback indikator error pintu garasi .................................................... 46 Gambar 4.39 GUI feedback indikator error pintu lampu.................................................... 46
xvii
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
DAFTAR TABEL Tabel 2.1 Port D bit 7 – bit 0 ................................................................................................. 7 Table 2.2 UPM bits setting .................................................................................................... 9 Table 2.3 UCSZ bits setting ................................................................................................ 10 Table 2.4 UCPOL bit setting ............................................................................................... 10 Tabel 2.5 Phase correct PWM setting ................................................................................. 12 Tabel 2.6 Waveform generation bit..................................................................................... 12 Table 2.7 Clock select bit .................................................................................................... 13 Tabel 4.1 Pengiriman Android ke ATmega 8535................................................................ 29 Tabel 4.2 Pengiriman dari ATmega 8535 ke Android ........................................................ 29 Tabel 4.3 Pengiriman dari Android ke Arduino Uno .......................................................... 30 Tabel 4.4 Pengiriman dari Arduino Uno ke Android .......................................................... 30 Tabel 4.5 Hasil pengujian limit switch ................................................................................ 32 Tabel 4.6 Hasil pengujian LDR ........................................................................................... 33
xviii
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
BAB 1 PENDAHULUAN
1.1.
Judul Pengendali Lampu dan Pintu Garasi dengan Bluetooth Berbasis Mikrokontroler
1.2.
Latar Belakang Perkembangan teknologi yang terjadi di Indonesia sangatlah pesat. Banyak teknologi-
teknologi yang maju dan digunakan diberbagai kalangan. Perkembangan teknologi ini apabila disikapi dengan serius dan secara teliti mengikutinya maka dalam perkembangan teknologi yang terjadi di Indonesaia akan membawa kepada kemajuan jaman. Salah satu teknologi yang banyak digunakan adalah teknologi Bluetooth. Teknologi Bluetooth ini sudah menjadi sebuah teknologi yang mudah dan efisien bagi manusia, dimana teknologi Bluetooth dapat mengirim atau menerima data yang nantinya bisa diolah oleh device. Sampai sekarang teknologi Bluetooth menjadi teknologi komunikasi data yang berguna dan banyak dimanfaatkan [1] . Disamping perkembangan teknologi di Indonesia yang sangat pesat, sebagai seorang mahasiswa teknik elektro yang banyak bergelut pada bidang kontrol mempunyai tanggung jawab pada masyarakat mengenai keilmuan yang dimilikinya. Tetapi banyak juga dari mahasiswa teknik elektro yang tidak bisa mengaplikasiakan keilmuanya yang mereka milik kedalam alatalat sederhana yang ada di sekitarnya. Sebenarnya keilmuan yang didapat dalam bidang kontrol sudah dapat digunakan pada alat-alat yang sering dijumpai yaitu pada lampu. Salah satu contoh yang bisa digunakan adalah mematikan lampu ketika siang hari [2]. Dari hal kecil itu keilmuan mengenai kontrol sudah dapat diaplikasikan. Ada juga untuk membantu mempermudah masyarakat dalam menjalani kehidupan mereka, contoh sederhana adalah mempermudah untuk membuka dan menutup pintu garasi pada rumah mereka. Dari teknologi Bluetooth dan keilmuan mengenai kontrol yang sudah penulis jelaskan. Penulis akan membuat sistem yang dapat membantu memecahkan masalah tersebut. Alat-alat yang akan digunakan adalah sekema untuk lampu rumah dan pintu 1
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
2
garasi. Penunjukan lampu dan pintu garasi oleh penulis dikarena penulis melihat bahwa keilmuan mengenai kontrol dapat diaplikasikan terhadap kedua benda tersebut. Penulis menggabungkan teknologi dengan alat-alat yang biasanya digunakan agar menuju kepada rumah pintar[3]. Nantinya penghuni hanya perlu menggunakan GUI (Graphical User Interface) pada handphone untuk menghidupkan dan mematikan lampu, membuka dan menutup pintu garasi. Dalam pelaksanaanya dapat melalui device yang berkaitan dengan Bluetooth dan untuk pengendalinya menggunakan mikrokontroler. Mikrokontroler yang digunakan adalah ATmega 8535 karena memiliki memory yang sudah dianggap cukup oleh penulis dan banyak dijumpai di pasaran. Penulis akan membuat prototipe dari garasi yang akan dikontrol.
1.3.
Tujuan dan Manfaat Pada perancangan sistem ini dengan tujuan untuk menghasilkan sistem kontrol
menggunakan piranti Bluetooth dan mikrokontroler yang dapat mengontrol lampu dan pintu garasi. Maanfaat dari skripsi ini untuk adalah : 1. Dapat memahami mengenai cara kerja dari sistem yang penulis buat. 2. Menjadi acuan atau rujukan apabila ingin membuat sistem yang lebih besar lagi. 3. Menjadi bahan pertimbangan apabila membuat sistem yang hampir sama dengan sistem yang akan dibuat.
1.4.
Batasan Masalah Pada penelitian sistem yang akan dibuat, maka penulis memberi batasan sebagai berikut :
1. Sistem hanya dapat mengatur lampu dan pintu garasi saja. 2. OS Android yang digunakan adalah Android Jelly Bean 4.3 3. Sebagai penerima menggunakan modul Bluetooth HC-05. 4. Sebagai pengontrolnya menggunakan mikrokontroler ATmega 8535. 5. Untuk alat yang dikontrol menggunakan lampu AC 220V dan motor DC 12V. 6. Sensor cahaya yang digunakan adalah LDR (Light Dependent Resistor), driver Motor L298N, modul relay, dan rangkaian saklar sebanyak dua buah limit switch untuk pintu garasinya. 7. Untuk user interface-nya menggunakan smartphone Android.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
3
8. Pemodelan rumah yang digunakan berbentuk persegi panjang dengan ukuran panjang x lebar adalah 40 cm x 30 cm. Berikut ini adalah gambar dari pemodelan garasi.
30cm
40 cm
Gambar 1.1 Prototipe garasi
1.5.
Metodologi Penelitian Dalam perancangan penelitian yang dilakukan oleh penulis, penulis melakukan langkah –
langkah sebagai berikut: 1. Mencari teori-teori mengenai Bluetooth, mikrokontroler ATmega 8535, serta memahami bagaimana sistem komunikasinya. 2. Mencari masukan-masukan tentang penulisan dengan judul yang saling berkaitan dengan sistem yang akan penulis buat. 3. Merancang sistem kontroler dan pembuatan program yang menghubungkan pengguna dengan kontrolernya . 4. Melakukan pengujian setiap alat yang dirancang.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
BAB II DASAR TEORI 2.1.
Android
2.1.1. Ice Cream Sandwich (Android 4.0–4.0.4) Ice Cream Sandwich atau biasa disebut ICS pertama kali dirilis pada bulan Oktober 2011. OS Android ICS tampil dengan UI yang sangat modern dan lebih friendly dibandingkan pendahulunya. Perangkat pertama yang didukung oleh ICS adalah Samsung Galaxy Nexus yang hadir dengan layar 720p [4].
2.2.
Bluetooth
2.2.1. Bluetooth Android [5] Pada dasarnya di dalam Android sudah terdapat fungsi untuk mengaktifkan Bluetooth dan memonitoringnya. Fungsi dari Bluetooth Android API (Application programing interface) adalah untuk pengaturan Bluetooth, menemukan perangkat yang baik dipasangkan atau tersedia di daerah setempat, yang menghubungkan perangkat, dan mentransfer data antara perangkat. Semua API sudah tersedia di dalam Android packages. Berikut ini adalah beberapa kelas dari Bluetooth Android : 1. Bluetooth Adapter Bluetooth adapter digunakan untuk mengidetifikasi, menemukan perangkat, pemasangan perangkat Bluetooth lainnya. Bluetooth adapter merupakan pintu masuk pertama untuk device. 2. Bluetooth Device Perangkat yang digunakan untuk mendapatkan informasi tentang perangkat seperti nama, alamat, kelas, dan negara. 3. Bluetooth Socket Merupakan koneksi yang memungkinkan aplikasi untuk bertukar data dengan perangkat Bluetooth lain dalam bentuk stream data.
4
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
5
4. Bluetooth Server Socket Berfungsi untuk mendeteksi permintaan koneksi yang sudah ada pada Bluetooth socket. 5. Bluetooth Class Digunakan untuk menunjukan jenis dari perangkat.
2.2.2. Modul Bluetooth HC-05 Modul Bluetooth merupakan perangkat yang digunakan sebagai Bluetooth serial interface. Modul Bluetooth atau yang sering disebut modul BT, pada dasarnya mempunyai dua model yaitu master device dan slave device. Nama device setelah nomer yang genap menunjukan master atau slave dan itu tidak dapat diganti. Contohnya : Master device: Slave device:
HC-04-M, M=master HC-04-S, S=slave
Tetapi apabila keluarnya adalah nomor ganjil HC-03, HC-05 untuk mengatur slave dan masternya cukup dengan mengubah pada AT Command [6]. Komunikasi antara dua Bluetooth modul dapat terjadi paling tidak terdapat kondisi sebagai berikut. 1. Komunikasi harus berasal dari master dengan slave, apabila keduanya adalah master atau slave maka komunikasi tidak akan terjalin. 2. Password anatara dua modul Bluetooth harus benar.
Gambar 2.1 HC-O5
Gambar 2.2 Koneksi HC-05 [6]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
6
Modul BT HC-05 merupakan modul Bluetooth yang penggunaan untuk master dan slave dapat diubah tergantung dengan AT Command. Proses pairing dari perangkat master tidak hanya dapat berkomunikasi dengan Bluetooth yang spesifik namun dapat mencari dan pairing dengan slave secara otomatis [6].
2.3.
ATmega 8535 Mikrokontroler adalah sebuah chip yang berfungsi sebagai pengontrol rangkaian
elektronik dan umunya dapat menyimpan program di dalamnya. Mikrokontroler umumnya terdiri dari CPU (Central Processing Unit), memori, I/O tertentu dan unit pendukung seperti Analog-to-Digital Converter (ADC) yang sudah terintegrasi di dalamnya [7].
Gambar 2.3 ATmega 8535 Penjelasan fungsi setiap port pada mikrokontroler 1. VCC merupakan port untuk digital supply voltage dengan masukan 5V. 2. GND merupakan port untuk ground. 3. Port A (PA7-PA0) berfungsi sebagai input analog ke ADC. Port A juga berfungsi sebagai delapan bit bi-directional I/0 port. 4. Port B (PB7-PB0) brfungsi sebagai delapan bit bi-directional I/0 port dan di setiap pin kakinya juga mempunyai fungsi tersendiri. 5. Port C (PC7-PC0) brfungsi sebagai delapan bit bi-directional I/0 port dan di setiap pin. 6. Port D (PD7-PD0) brfungsi sebagai delapan bit bi-directional I/0 port dan di setiap pin kakinya juga mempunyai fungsi tersendiri.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
7
Tabel 2.1 Port D bit 7 – bit 0 [8]
7.
RESET digunakan untuk mereset mikrokontroler.
8.
XTAL1 untuk masukan yang menuju ke penguat osilator inverting dan internal clock.
9.
XTAL2 output dari penguat osilator inverting.
10. AVCC port tegangan supply untuk port A dan untuk ADC. 11. AREF port refrensi analog untuk ADC.
2.3.1
USART Universal Synchronus and Asynchronus serial Receiver and Transmitter
(USART) merupakan komunikasi yang memiliki fleksibilitas tinggi, yang dapat digunakan untuk melakukan transfer data baik antar mikrokontroler maupun dengan modul-modul eksternal. Berikut ini adalah penjelasan mengenai register yang ada pada USART [8]. 1. USART I/O Data Register–UDR
Gambar 2.4 UDR [8] USART Transmit Data Buffer Register dan USART Receive Data Buffer Register menggunakan I/O yang sama atau yang lebih disebut dengan USART Data Register atau UDR.Transmit Data Buffer Register (TXB) menjadi arah data yang di tulis menuju lokasi register UDR. Pembacaanya data pada Receive Data Buffer Register (RXB).
2. USART Control and Status Register A-UCSRA
Gambar 2.5 UCSRA [8]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
8
Penjelasan setiap bitnya adalah sebagai berikut: Bit 7-RXC: USART Receive Complete Bit ini set ketika ada data yang tak terbaca di buffer penerima dan bersih ketika buffer penerima kosong. Bit 6-TXC: USART Transmit Complete Bit ini set ketika seluruh frame dalam Transmit shift register telah bergeser dan tidak ada data yang baru muncul di buffer penerima. Bit 5-UDRE: USART Data Register Empty Bit ini Menunjukan jika buffer pengirim siap untuk menerima data baru. Bit 4-FE: Frame Error Bit ini terset jika karakter berikutnya dalam buffer penerima mendapatkan error. Bit 3-DOR: Data Over Run Bit ini diset ketika kondisi data overun terdeteksi. Bit 2-PE: Parity Error Bit ini di set ketika karaketer selanjutnya dalam buffer penerima terdapat sebuah parity error dalam penerimaan. Bit1-U2X: Double The USART Transmission Speed Bit ini hanya mempunya efek pada operasi asinkron. Bit 0-MPCM: Multi-Processor Comunication Mode Bit ini memungkinkan untuk multi-processor communication mode.
3. USART Control and Status Register B-UCSRB
Gambar 2.6 USCRB [8] Penjelasan setiap bitnya adalah sebagai berikut: Bit 7- RXCIE: RX Complete Interrupt Enable Penulisan bit ini pada salah satu interrupt yang dapat dipakai pada bendera RXC. Bit 6- TXCIE: TX Complete Interrupt Enable Penulisan bit ini pada salah satu interrupt yang dapat dipakai pada bendera TRX. Bit 5- UDRIE: USART Data Register Empty Interrupt Enable Penulisan bit ini pada salah satu interrupt yang terdapat pada bendera UDRE.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
9
Bit 4- RXEN: Receiver Enable Penulisan bit ini pada salah satu enable di penerimaan USART. Bit 3- TXEN: Transmitter Enable Penulisan bit ini pada salah satu enable di pengirim USART. Bit 2- UCSZ2: Character Size Bit ini untuk menyiapkan nilai pada data bits di dalam penerima dan pengirim. Bit 1- RXB8: Receive Data Bit 8 Bit ini untuk data ke sembilan pada penerimaan karakter saat beroprasi dengan serial frames sembilan data bits. Bit 0- TXB8: Transmit Data Bit 8 Bit ini untuk data ke sembilan pada pengirim karakter saat beroprasi dengan serial frames sembilan data bits.
4. USART Control and Status Register C-UCSRC
Gambar 2.7 UCSRC [8] Penjelasan setiap bitnya adalah sebagai berikut: Bit 7- URSEL: Register Select Bit ini memilih antara UBRRH atau UCSRC. Bit 6-UMSEL: USART Mode Select. Bit ini memilih antara asinkron UMSEL = 0 dan sinkron UMSEL= 1. Bit 5:4 –UPM 1:0 Parity Mode Bit ini menentukan tipe dari piranti dan pengecekan. Table 2.2 UPM bits setting [8]
Bit 3-USBS : Stop Bit Select Bit ini memilih angka untuk bit berhenti yang dimasukan oleh pengirim. USBS = 0 maka stop bit =1-bit dan USBS = 1 maka stop bit =2-bit. Bit 2:1-UCSZ1:0 : Character Size
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Menetukan ukuran karakter dalam penerima dan pengirim. Table 2.3 UCSZ bits setting [8]
Bit 0-UCPOL: Clock Polarity Bit ini digunakan pada mode sinkron saja. Table 2.4 UCPOL bit setting [8]
5. USART Baud Rate Register – UBRRL dan UBRRH
Gambar 2.8 UBRRH dan UBRRL [8] Penjelasan setiap bitnya adalah sebagai berikut. Bit 15-URSEL: Register Select Bit ini memilih akses antara UBRRH atau UCSRC Bit 14:12-Reserved Bits Bit ini harus ditulis nol ketika memilih UBRRH. Bit 11:0-USART Baud Rate Register Merupakan 12-bit register yang berpengaruh pada baud rate USART
10
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
11
2.3.2. Phase Correct PWM
Gambar 2.9 Phase correct PWM [8] PWM (Pulse Width Modulation) berfungsi untuk mengatur lebar sisi positif dan negatif pulsa kontrol pada frekuensi kerja yang tetap. Perhitungan dari Timer1 mode phase correct PWM adalah sebagai berikut [9]. Foc1a= Fosc/(2*N*TOP) Foc1b= Fosc/(2*N*TOP) D=(OCR1X / TOP) * 100% Dengan, Foc1a = frekuensi output OC1A Foc1b = frekuensi output OC1B Fosc = frekuensi clock kristal yang digunakan D = duty cycle TOP = nilai maksimum counter (TCN1). TOP mempunyai tiga buah nilai untuk mode tersebut yaitu 8 bit (FF), 9 bit (1FF), 10 bit (3FF).
2.3.3. Timer/Counter1 Control Register A
Gambar 2.10 TCCR1A [8] Penjelasan setiap bitnya adalah sebagai berikut. Bit 7:6–COM1A1:0 Compare Output Mode for Channel A Bit 5:4–COM1B1:0 Compare Output Mode for Channel B Tergantung dengan mode yang diinginkan, mode tersebut adalah Phase Correct PWM.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Tabel 2.5 Phase correct PWM setting [8]
Bit 3–FOC1A:Force Output Compare for Channel A Bit 2–FOC1B:Force Output Compare for Channel B Bit ini harus di-set ke nol apabila dalam mode PWM. Bit 1:0–WGM 11:0 :Waveform Generation Mode Tabel 2.6 Waveform generation bit [8]
2.3.4 .
Timer/Counter1 Control Register B
Gambar 2.11 TCCR1B [8] Penjelasan setiap bitnya adalah sebagai berikut. Bit7 – ICNC1:Input Capture Noise Canceler
12
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
13
Bit ini bernilai satu apabila mengaktifkan input capture noise canceler yang mengakibatkan mengubah output dari input capture pin. Bit 6 – ICES1:Input Capture Edge Select Bit ini untuk men-trigger-kan captuere yang genap pada input capture pin . Bit 5- Reserved Bit Bit ini harus bernilai nol ketika dalam mengatur TCCR1B. Bit 4:3 – WGM13:2 : Waveform Generation Mode Bit 2:0 – CS12:0 : Clock Select Table 2.7 Clock select bit [8]
2.4.
Driver Motor
2.4.1. Modul L298 Modul L298N merupakan modul driver untuk motor dc, servo, dan juga motor stepper. Sistem kerja dari modul L298N dapat digunakan sebagai pembalik putaran atau dapat dikatakan sebagai H-bridge [10].
Gambar 2.12 Modul L298 [10] Penggunaan L298 membutuhkan PWM untuk mengatur kecepatan motor yang akan dipasang.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 2.5.
14
Sensor Cahaya
2.5.1. Light Dependent Resistor (LDR) Jenis resistor yang nilai hambatan atau nilai resistansinya tergantung pada intensitas cahaya yang diterima. Nilai hambatan LDR akan menurun pada saat cahaya terang dan nilai hambatannya akan menjadi tinggi jika dalam kondisi gelap. Dengan kata lain, fungsi LDR (Light Dependent Resistor) adalah untuk menghantarkan arus listrik jika menerima sejumlah intensitas cahaya (Kondisi Terang) dan menghambat arus listrik dalam kondisi gelap [11].
Gambar 2.13 LDR [11]
2.6.
Rangkaian Saklar
2.6.1. Limit Switch Limit switch merupakan jenis saklar yang dilengkapi dengan tuas yang berfungsi menggantikan tombol. Prinsip kerja limit switch sama seperti saklar push on yaitu hanya akan menghubung pada saat tuasnya ditekan pada batas penekanan tertentu yang telah ditentukan dan akan memutus saat saat tuas tidak ditekan. Limit switch termasuk dalam kategori sensor mekanis yaitu sensor yang akan memberikan perubahan elektrik saat terjadi perubahan mekanik pada sensor tersebut. Penerapan dari limit switch adalah sebagai sensor posisi suatu benda (objek) yang bergerak [12].
Gambar 2.14 Limit switch
2.6.2.
Modul relay Modul relay berisi 2 relay yang masing-masing dapat bekerja sendiri seperti relay
pada umumnya. Modul ini bekerja dengan masukan logika rendah.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Gambar 2.15 Modul relay
2.7.
Resistor Pull UP 5V
5V
R1
D1
R2
R1
KE MIKROKONTROLER KE MIKROKONTROLER
30k
30K 1k
LED
LDR1
1.0
LDR GND
GND GND
Gambar 2.16 Rangkaian pull up LDR dan limit switch Rumus yang digunakan untuk menentukan nilai R pada LDR dan limit Switch. 𝑉𝑐𝑐−𝑉 𝑜𝐿
Rmin=
𝐼𝑜𝐿 𝑉𝑐𝑐−𝑉 𝑜𝐻
Rmax= Dengan, Rmin= Resistor Minimum Rmax=Resistor Maksimum VoL=Tegangan Keluaran Rendah VoH=Tegangan Keluaran Tinggi Vcc= Tegangan Sumber Iol= Arus Keluaran Rendah IoH=Arus Keluaran Tinggi
𝐼𝑜𝐻
(2.1) (2.2)
15
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
BAB III PERANCANGAN
3.1.
Pemodelan Sistem Secara Keseluruhan
Android
Modul
Handphone
Bluetooth
Mikrokontroler
Lampu Pintu Garasi
Gambar 3.1 Pemodelan lengkap Alur dari pemodelan sistem secara garis besar adalah sebagai berikut. Sistem yang digunakan adalah closed loop dengan memberikan feedback yang dikirim ke handphone untuk
mengecek sistem
berjalan
dengan
baik.
Langkah pertama
user harus
menyambungkan antara Bluetooth pada handphone dengan modul Bluetooth. Apabila sudah tersambung maka user dapat menggunakan tampilan GUI (Graphic User Interface) untuk memilih alat yang akan dikendalikan. Data yang dikirim dari Bluetooth pada handphone akan diterima oleh modul Bluetooth yang nantinya akan diolah pada mikrokontroler. Pengolahan pada mikrokontroler digunakan untuk mengontrol alat yang diperintahkan. Alat yang dikendalikan adalah lampu, pintu garasi. Alat tersebut juga mempunyai pengontrolan kondisi yang nantinya akan digunakan sebagai feedback jika alat sudah melakukan perintah dengan benar. Tampilan feedback akan ditampilkan pada GUI Handphone.
16
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 3.2.
17
Rangkaian Perangkat Keras
3.2.1. Modul Bluetooth dengan Mikrokontroler ATmega 8535
Gambar 3.2 Modul Bluetooth dan mikrokontroler ATmega 8535 Alur dari pemodelan sistem modul Bluetooth dengan mikrokontroler ATmega 8535 adalah sebagai berikut. Modul Bluetooth digunakan untuk menerima data dari handphone kemudian meneruskannya ke mikrokontroler. Modul Bluetooth ini juga digunakan untuk mengirim kembali feedback dari mikrokontroler ke handphone. Mikrokontroler berfungsi untuk menjalankan perintah yang didapat dan pengecekannya, kemudian akan dikirim menjadi feedback. Port RX pada modul Bluetooth disambungkan pada PD0 karena merupakan pin yang bisa digunakan sebagai receiver pada USART, sedangkan port TX pada modul Bluetooth disambungkan pada PD1 karena biasa digunakan untuk transmitter pada mikrokontroler.
3.2.2. Lampu dan Sensor Lampu keluaran dari sensor cahya yang masuk ke mikrokontroler adalah PA1. 5V
D1
R2
R1
KE MIKROKONTROLER 30K
1k
LED
LDR1
1.0
LDR GND
GND
Gambar 3.3 Sensor lampu Dari datasheet, persamaan 2.1, dan persamaan 2.2 untuk mencari nilai resistor pull up pada sensor lampu, maka diperoleh nilai resistor sebagai berikut.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 𝑉𝑐𝑐−𝑉 𝑜𝐿
R2min=
𝐼𝑜𝐿 𝑉𝑐𝑐−𝑉 𝑜𝐻
R2max=
𝐼𝑜𝐻
=
5𝑣−0,2𝑣 40 𝑚𝐴
=
= 120Ω
5𝑣−4,5𝑣 1 µ𝐴
18
= 500k Ω
Dari nilai Rmin dan Rmax yang sudah diperoleh akan digunakan R2= 30 kΩ
3.2.3. Driver dan Motor DC Rangkaian driver motor yang digunakan adalah L298N. Input satu dan dua pada modul L298N dihubungkan ke PB0 dan PB1 pada mikrokontroler. Masukan untuk enable 1 dihubungkan ke PD4 pada mikrokontroler dikarenakan pada PD4 merupakan OCR1A. Motor dc yang digunakan pada pintu garasi adalah M1 5V
PB0 PB1
PD4
5 7 10 12 6 11 1 15
12 V
9
4
VCC
VS
U1 M1
IN1 IN2 IN3 IN4 ENA ENB
OUT1 OUT2 OUT3
SENSA SENSB
OUT4
2 3 13 14
GND 8
L298
Gambar 3.4 Driver motor dan motor dc
3.2.4. Rangkaian Saklar Pada penelelitian ini penulis akan menggunakan rancangan pada gambar 3.5 sebanyak 2 rangkaian. Pada PC0 dan PC1 di mikrokotroler merupakan keluaran dari limit switch bawah dan atas pada pintu garasi. 5 V
R3 KE MIKROKONTROLER 30K
GND
Gambar 3.5 Rangkaian saklar Dari datasheet, persamaan 2.1, dan persamaan 2.2 untuk mencari nilai resistor pull up pada rangkaian saklar, maka diperoleh nilai resistor sebagai berikut. 𝑉𝑐𝑐−𝑉 𝑜𝐿
R3min=
𝐼𝑜𝐿
=
5𝑣−0,2𝑣 40 𝑚𝐴
= 120Ω
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 𝑉𝑐𝑐−𝑉 𝑜𝐻
R3max=
𝐼𝑜𝐻
=
5𝑣−4,5𝑣 1 µ𝐴
19
= 500k Ω
Dari nilai Rmin dan Rmax yang sudah diperoleh akan digunakan R3= 30 kΩ
3.3.
Perancangan Perangkat Lunak
3.3.1. GUI
Gambar 3.6 GUI garasi Dalam sistem ini yang dikontrol adalah pintu garasi dan lampu. Pada dasarnya user akan diminta memilih perintah langsung dengan menekan pada GUI di handphone yang sudah dibuat. Indikator menyala hijau apabila dalam keadaan menyala untuk lampu dan terbuka untuk pintu garasi, bila menyala merah maka keadaan mati untuk lampu dan keadaan tertutup untuk pintu garasi.
3.3.2.
Pengaktifan Bluetooth Merupakan langkah-langkah untuk melakukan pengaktifan Bluetooth atau
penggabungan Bluetooth dengan alat sebelum sistem dilakukan. Berikut ini Langkah-langkah yang digunakan untuk pengaktifan Bluetooth 1. Pengaktifan Bluetooth dengan mengaktifkan Bluetooth pada handphone yang digunakan. 2. Mencari nama Bluetooth penerima yang akan digunakan <”Search”>.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
20
3. Lakukan penyambungan antara handphone dengan penerima yang disebut pairing. 4. Apabila Bluetooth handphone sudah tersambung dengan modul Bluetooth < “OK”>, dan bila sambungan gagal <”Koneksi Gagal“>. 5. Penampilan GUI akan muncul ketika Bluetooth sudah tersambung . 6. Setelah Penampilan GUI, maka sistem sudah bisa dijalankan.
3.3.3.
Flow Chart Android pada Handphone
Gambar 3.7 Flow chart Android pada handphone Flow chart Android pada handphone terdapat pengirim dan penerima sekaligus. Setelah user menekan perintah yang diinginkan maka terjadi pengiriman data ke modul Bluetooth. Setelah pengiriman data ke modul Bluetooth sudah dilakukan, maka sistem akan melihat apakah sudah ada feedback yang masuk pada sistem. Apabila belum ada feedback dari kontrol maka program hanya menjalankan sampai pada pengiriman data saja. Ketika program mendapaktkan feedback maka akan melakukan pengecekan sebelum masuk pada indikator yang menjadi feedback-nya.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
3.3.4.
21
Flow Chart Mikrokontroler
Gambar 3.8 Flow chart di sistem penerima Pada receiver data yang sudah dikirim oleh handphone akan diterima oleh modul Bluetooth. Dari modul Bluetooth itu akan dilanjutkan ke mikrokontroler sebagai kontrolnya. Dari mikrokontroler akan disambungkan langsung ke alat-alat yang digunakan seperti lampu dan pintu garasi. Data yang diterima pertama kali akan dicek apakah untuk kontrol lampu atau pintu garasi, dan jika tidak ada data maka akan mengecek kondisi. Apabila data yang diterima merupakakan data untuk mengontrol lampu maka akan memproses sub rutin aktifkan lampu, bila bukan maka merupakan data untuk mengontrol pintu garasi dan akan memproses aktifkan pintu garasi. Setelah program dijalankan akan ada pengecekan kondisi alat. Jika alat sudah bekerja sesuai dengan data yang dikirimkan maka akan langsung dikirim kembali sebagai feedback, apabila alat tidak sesuai dengan data yang dikirim akan terjadi looping dimana kembali lagi ke proses pengecekan keaktifan lampu atau pintu garasi.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 1.3.5.
22
Flow Chart Sub Rutin Aktifkan Lampu
Gambar 3.9 Flow chart sub rutin lampu Dalam prototipe nantinya akan menggunakan sebuah lampu AC 220 volt. Sistem yang akan dijalankan adalah alat akan menerima data dari kontoler yang nantinya akan diteruskan dan dideteksi keadaannya apakan menyala atau mati.
3.3.6.
Flow Chart Sub Rutin Aktifkan Pintu Garasi
Gambar 3.10 Flow Chart sub rutin pintu garasi
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
23
Pada flow chart pintu garasi pendeteksian alat yang digunakan adalah limit switch. Limit switch ini akan menentukan arah putaran dari motor dc yang menentukan kondisi alat tersebut. Motor akan berputar searah jarum jam (putar ke bawah) dilakukan sampai limit switch bawah tertekan. Dalam kondisi tersebut adalah sistem penutupan pintu garasi. Motor akan berputar berlawanan arah jarum jam (putar ke Atas) dilakukan sampai limit switch atas terkena. Nantinya pada program akan ditambahkan waktu lamanya perputaran motor. Flow chart ini juga menunjukan program yang akan diolah apabila terjadi pembukaan paksa pada pintu garasi. Flow chart program akan menunjukan feedback kepada user apabila pintu garasi yang tidak tertutup sempurna, bisa dikatakan dalam kondisi setengah buka.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
BAB IV HASIL DAN PEMBAHASAN
4.1.
Hasil Implementasi Alat
Gambar 4.1 Alat secara keseluruhan Gambar 4.1 merupakan gambar alat yang dirancang secara keseluruhan. Alat yang dibuat terdiri dari dua bagian yang dapat dikontrol, yaitu motor dc 12 volt sebagai penggerak pintu garasi dan lampu 220 volt. Sensor yang digunakan adalah limit switch sebanyak dua buah yaitu untuk limit switch bawah dan limit switch atas pada pintu garasi, LDR digunakan untuk mengecek kondisi pada lampu. Feedback yang dihasilkan dari sensor nantinya akan dikirim ke GUI seperti gambar 4.2.
Gambar 4.2 GUI(Graphic User Interface)
24
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
25
Pada tombol “connect” akan langsung mendapatkan feedback dari kondisi awal pada alat. Feedback yang didapat akan menyalakan indikator pada GUI sesuai perintah yang user minta. Apabila terjadi kesalahan juga akan ditampilkan pada indikator di GUI.
4.2.
Hasil Perancangan Perangkat Keras
Gnd
Pin mikrokontrolel
VCC
Gambar 4.3 Rangkaian limit switch atas. Pada gambar 4.3 sebelum limit switch tidak ditekan maka yang akan masuk ke mikrokontroler adalah 5,021 volt, apabila limit switch ditekan tegangan akan menuju ke ground dan yang akan masuk ke mikrokontroler adalah 0 volt.
Pin mikronontroler
Gnd
VCC
Gambar 4.4 Rangkaian limit switch bawah. Gambar 4.4 bekerja serupa dengan limit switch atas dan digunakan untuk batas bawah alat bekerja. Gnd Pin mikrokontroler
VCC
Gambar 4.5 Rangkaian LDR
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
26
Rangkaian LDR terkena cahaya maka hambatannya adalah 0,8907 kΩ, jika LDR tidak terkena cahaya maka hambatan adalah 16,798 kΩ.
VCC
Gnd
TX mikrokontroler RX mikrokontroler
Gambar 4.6 Module Bluetooth Gambar 4.6 adalah modul Bluetooth yang digunakan untuk mengirim dan menerima data, tegangan yang digunakan adalah 5 volt. Kaki RX disambungkan ke pin TX pada mikrokontroler, sedangkna kaki TX disambungkan ke pin RX pada mikrokontroler. Motor dc
Pin mikrokontroler
Gnd 12 volt
vcc Pin mikrokontroler Pin mikrokontroler
Gnd Motor dc
Gambar 4.7 Rangkaian L298 Pada gambar 4.7 kaki 3 dan kaki 2 digunakan sebagai output. Pengaturan pwm pada kaki 6 dan dengan sumber yang masuk pada kaki 4 adalah 12 volt sesuai dengan tegangan yang dibutuhkan oleh motor dc. Rangkaian L298 digunakan sebgai pembalik putaran dengan cara merubah masukan pada kaki 5 dan kaki 7.
4.3.
Hasil Perancangan Alat dan Sistem
4.3.1. Letak Limit Switch Dalam pengerjaan alat yang dilakukan terdapat beberapa model penempatan limit switch sehingga mendapatkan hasil yang lebih optimal. Penempatan limit switch pada awal perakitan alat seperti pada gambar 4.8.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
27
Gambar 4.8 Model penempatan limit switch pertama Kekurangan penempatan limit switch pertama adalah ketika pintu ditutup dan dibuka, tidak dapat mengenai limit switch karena spacer tidak bisa menekan limit switch secara sempurna. Kemudian pada limit switch bawah diganti dengan memanjangkan tuas seperti gambar 4.9.
Gambar 4.9 Limit switch dengan tuas yang diperpanjang Pemanjangan limit switch berfungsi seperti pesawat sederhana berupa tuas. Semakin panjang lengan kuasa, maka akan semakin besar keuntungan mekanisnya karena gaya yang dibutuhkan untuk menekan limit switch kecil. Maka model limit switch dengan tuas yang lebih panjang digunakan untuk menggantikan limit switch bawah seperti gambar 4.10.
Gambar 4.10 Model penempatan limit switch kedua Pada pemodelan kedua untuk limit switch bawah dapat tertekan sempurna. Tetapi ketika limit switch tertekan spacer, berat dari spacer membuat tuas panjang yang disambungkan ke limit switch menjadi patah karena tidak bisa menahan berat dari spacer terlalu lama. Dibuatlah pemodelan penempatan limit switch yang ketiga seperti gambar 4.11.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
28
Gambar 4.11 Model penempatan limit switch ketiga Dengan penambahan balok karet untuk menahan limit switch yang tertekan spacer pada saat tertutup dan penambahan balok karet pada bagian atas digunakan untuk menahan spacer agar tidak melebihi batas dari limit switch atas. Namun ketika spacer menekan limit switch atas, motor tidak langsung berhenti. Masih ada sisa putaran yang membuat limit switch atas tidak bisa dibaca ketika pengkoneksian kondisi awal. Dibuatlah model penempatan limit switch keempat seperti gambar 4.12.
Gambar 4.12 Model penempatan limit switch keempat Pemodelan penempatan limit switch keempat ini adalah pemodelan yang digunakan untuk alat. Tuas pada limit switch atas dibuat lebih panjang seperti pada limit switch bawah dan peletakan limit switch atas lebih dikebawahkan. Fungsinya adalah ketika limit switch atas tertekan maka sisa putaran dari motor masih dapat menekan limit switch sehingga ketika pengecekan kondisi awal, limit switch atas bisa terbaca.
4.3.2. Penggunaan Modul HC-05 Modul HC-05 adalah modul Bluetooth yang digunakan untuk berkomunikasi antara mikrokontroler dengan android. Modul HC-05 mempunyai AT Command yang digunakan untuk mengubah atau mengecek status pada modul HC-05. Dalam pengerjaan alat ada beberapa AT Command yang dicoba. Contohnya adalah perintah “AT” untuk mengecek
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
29
module Bluetooth telah terkoneksi dengan respone “OK”. Selain itu ada juga perintah “AT+VERSION?” digunakan untuk melihat versi dari Bluetooth itu. Untuk mengetahui nama module Bluetooth menggunakan perintah “AT+NAME?” dan untuk mengetahui sandi dari module Bluetooth menggunakan perintah “AT+PSWD?”. Saat pengerjaan alat juga dicoba perintah untuk mengubah master dan slave Bluetooth yaitu menggunakan perintah “AT+ROLE”. Perintah “AT+ORGL” digunakan untuk mengembalikan modul Bluetooth ke setatus awalnya. Perintah “AT+RESET” digunakan untuk reset modul Bluetooth.
4.3.3. Pemilihan Arduino Menggantikan ATmega 8535 Pada pengujian mendapatkan kendala saat pengiriman dari ATmega 8535 ke Android. Selain itu data yang diterima dari Android oleh ATmega 8535 tidak sesuai dengan desimal ASCII yang dikirimkan oleh Android. Berikut ini adalah data yang diterima oleh ATmega 8535 dan data yang diterima oleh Android ditunjukan pada tabel 4.1 dan tabel 4.2. Tabel 4.1 Pengiriman Android ke ATmega8535. Data yang dikirim dari android
ASCII yang ASCII yang seharusnya diterima ATmega diterima(desimal) 8535 (desimal) a 216 97 b 217 98 c 217 99 d 218 100 e 218 101 f 219 102 Tabel 4.2 Pengiriman dari ATmega 8535 ke Android.
Data yang dikirim dari ATmega 8535
Data (desimal) yang Data yang diterima dikirim dari oleh Android ATmega 8535 a 97 b 98 c 99 d 100 e 101 f 102 Perbedaan data yang ada dimungkinkan karena pengiriman paket data yang dilakukan oleh Android tidak bisa dibaca sempurna oleh ATmega 8535. Pengiriman paket data dari
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
30
ATmega 8535 ke Android juga tidak sesuai dengan paket data yang dibutuhkan oleh Android, maka dari itu data tidak bisa dibaca oleh Android. Dengan mencoba mikrokontroler yang lain yaitu Arduino Uno. Pemilihan Arduino ini dikarenakan pada program Arduino mempunyai fungsi-fungsi yang bisa langsung digunakan untuk berkomunikasi dengan mobul Bluetooth. pengiriman dan penerimaan data yang dilakukan antara Arduino dan Android dapat dijalankan dengan benar. Berikut ini adalah data yang dikirim oleh Android dan diterima oleh Arduino Uno dan data yang dikirim Arduino Uno diterima oleh Android ditunjukan pada tabel 4.3 dan tebel 4.4. Tabel 4.3 Pengiriman dari Android ke Arduino Uno Data yang dikirim dari Data yang diterima oleh Android(character) Arduino(character) a a b b c c d d e e f f Tabel 4.4 Pengiriman dari Arduino Uno ke Android Data yang dikirim dari Data yang diterima oleh Arduino Uno(character) Android(character) a a b b c c d d e e f f Seperti pada tabel 4.3 dan tabel 4.4 data yang diterima oleh Arduino Uno ditampilkan pada serial monitor, sedangkan data yang diterima oleh Android ditampilkan langsung pada handphone. Data yang didapat oleh Arduino Uno diproses untuk mengontrol pintu garasi dan lampu 220 volt. Feedback yang didapat dari limit switch dan LDR akan dikirim ke Android.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 4.4.
31
Hasil Perancangan Menggunakan Arduino
4.4.1. Pengujian Motor
Gambar 4.13 Program Pengendali motor dc searah jarum jam Gambar 4.13 merupakan program pengendali motor dc. Pin 6 pada Arduino Uno disambungkan ke kaki 5 pada L298 dan pin 7 pada Arduino Uno disambungkan ke kaki 7 pada L298. Dengan memberi logika tinggi pada pin 7 dan logika rendah pada pin 6 akan menghasilakn putaran searah jarum jam di motor dc.
Gambar 4.14 Program pengenadali motor dc berlawana arah jarum jam Gambar 4.14 merupaka program pembailk putaran. Jika pin 7 diberi logika rendah dan pin 6 diberi logika tinggi maka akan menghasilkan putaran yang berlawanan arah jarum jam.
4.4.2. Pengujian Lampu
Gambar 4.15 Program pengendali lampu Nyala matinya lampu diatur menggunakan relay. NO (normally open ) akan menutup apabila pin In1 diberi logika rendah. Pin ln1 disambungkan pada pin 8 Arduino Uno. Sehingga untuk mengaktifkan relay diberi program seperti pada gambar 4.15.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
32
4.4.3. Pengujian Sensor Pengujian pada perancangan ini ditampilkan pada serial monitor dan besarnya tegangan yang diperoleh. Pengujian yang dilakukan melibatkan limit switch dan LDR. Hasil pengujian akan ditampilkan pada tabel 4.5 dan tabel 4.6.
4.4.3.1. Pengujian Limit switch Kaki C pada limit switch disambungkan di pin 6 pada Arduino Uno, kaki NO disambungkan ke ground. Apabila limit switch tidak ditekan, data yang masuk ke Arduino akan ditampilkan pada serial monitor seperti gambar 4.16.
Gambar 4.16 Serial monitor untuk limit switch tidak ditekan Apabila limit switch sudah ditekan maka data yang masuk ke Arduino logika rendah dan ditampilkan pada serial monitor seperti gambar 4.17.
Gambar 4.17 Serial monitor untuk limit switch sudah ditekan Dari hasil tersebut nilai yang dihasilkan dari percobaan limit switch sesuai dengan perancangan. Tabel 4.5 menunjukan hasil tegangan dan serial monitornya : Tabel 4.5 Hasil pengujian limit switch keadaan dari limit switch Tegangan atas dan bawah (volt) Tidak terkena 5,021 Terkena 0
Dibaca serial monitor 1 0
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
33
4.4.3.2 pengujian LDR Berdasarkan perancangan apabila LDR diberikan cahaya maka LDR akan memberikan logika rendah ke pin 2 pada Arduino Uno. Logika rendah pada Arduino Uno ditampilkan pada serial monitor seperti gambar 4.18.
Gambar 4.18 Serial monitor LDR dengan cahaya Jika LDR tidak diberi cahaya maka memberikan logika tinggi ke pin 2 pada Arduino Uno. Hasil ditampilkan pada serial monitor seperti gambar 4.19.
Gambar 4.19 Serial monitor LDR tanpa cahaya Dari pengujian dengan dan tanpa cahaya didapatkan bahwa kluaran LDR sesuai dengan perancangan. Tabel 4.6 menunjukan hasil dari tegangan dan serial monitornya. Tabel 4.6 Hasil pengujian LDR Keadaan dalam pengujian pada LDR Tidak terkena cahaya Terkena cahaya
4.5.
Tegangan (volt) 3,045 0,155
Serial monitor 1 0
Pengujian Sistem
4.5.1. connected Ketika tombol connect ditekan maka akan mencari nama Bluetooth yang sesuai pada program. Sesudah nama Bluetooth sesuai dengan nama Bluetooth pada program maka yang selanjutnya adalah mepersiapkan UUID yang digunakan untuk bisa mengolah data menggunakan modul Bluetooth. UUID yang digunakan adalah UUID universal yang bisa digunakan oleh modul Bluetootth lainya seperti gambar 4.20.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 179. 180. 181. 182. 183. 184. 185.
caca5.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub
Set
pairedDevices = mBluetoothAdapter.getBondedDevices(); 186. if(pairedDevices.size() > 0) 187. { 188. for(BluetoothDevice device : pairedDevices) 189. { 190. if(device.getName().equals("HC-05")) //Note, you will 191. //need to change this to match the name of your device 192. { 193. mmDevice = device; 194. Toast.makeText(getApplicationContext(), "Connected", Toast.LENGTH_SHORT).show(); 195. 196. break; 197. } 198. } 199. } 200. //* UUID universal yang digunakan 201. UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); 202. //Standard SerialPortService ID 203. 204. try { 205. mmSocket = mmDevice.createRfcommSocketToServiceRecord(uuid); 206. } catch (IOException e) { 207. // TODO Auto-generated catch block 208. e.printStackTrace(); 209. } 210. 211. try { 212. mmSocket.connect(); 213. } catch (IOException e) { 214. // TODO Auto-generated catch block 215. e.printStackTrace(); 216. } 217. 218. try { 219. mmOutputStream = mmSocket.getOutputStream(); 220. } catch (IOException e) { 221. // TODO Auto-generated catch block 222. e.printStackTrace(); 223. }
224. Gambar 4.20 List program connected
34
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
225. 226.
35
try { mmInputStream = mmSocket.getInputStream();
227. 228.
} catch (IOException e) { // TODO Auto-generated catch block
229. 230. 231. 232. 233. 234. 235. 236. 237. 238. 239. 240.
e.printStackTrace(); } //beginListenForData(); send="e"; // data yang dikirim dalam char try { SendData(send); terimaData(); } catch (IOException e) { //TODO Auto-generated catch block e.printStackTrace(); } Toast.makeText(getApplicationContext(), "data di terima", Toast.LENGTH_SHORT).show(); 241. } 242. });
243. Gambar 4.20 List program connected (lanjutan) Setelah UUID dipersiapkan, langkah selanjutnya adalah menjalankan program SendData(). Isi dari fungsi SendData() dapat dilihat pada gambar 4.21. 49. //* mengirim data dari android 50. void SendData(String data)throws IOException{ 51. mmOutputStream.write(data.getBytes()); 52. mmOutputStream.flush(); 53. }
Gambar 4.21 List fungsi SendData() Di dalam fungsi SendData digunakan untuk mengirim data dari Android ke Arduino Uno. Pada program connected data “e”(dalam bentuk char) dikirimkan dari Android ke Arduino Uno. Data tersebut diterima dan diproses oleh Arduino Uno. Pada Arduino terdapat listing program seperti gambar 4.22. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47.
if (kata==101) // cek awal ) // decimal ASCI ‘e’ { cek_awal(); kata=0; //delay(3000); } else if (kata==97) // decimal ASCI ‘a’ { buka_pintu(); }
Gambar 4.22 List program Arduino
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60.
36
else if (kata==98) ) // decimal ASCI ‘b’ { tutup_pintu(); } else if (kata==99) ) // decimal ASCI ‘c’ { hidup_lampu(); } else if(kata==100) ) // decimal ASCI ‘d’ { matikan_lampu(); } }
Gambar 4.22 List program Arduino(lanjutan) Data “e” yang diterima oleh Arduino Uno kemudian diterjemahkan menjadi desimal ASCI dan masuk pada fungsi cek_awal(). Isi dari fungsi cek_awal() adalah seperti gambar 4.23. 62. void cek_awal() 63. { 64. lam=digitalRead(2); 65. gar1=digitalRead(3);//LSA 66. gar2=digitalRead(4);//LSB 67. if (lam==1)//mati lampu 68. { 69. lampu="L0"; 70. } 71. else if (lam==0)//hidup lampu 72. { 73. lampu="L1"; 74. } 75. if ((gar1==1)&&(gar2==0))//tutup pintu 76. { 77. garasi="G0"; 78. } 79. else if ((gar1==0)&&(gar2==1))//buka pintu 80. { 81. garasi="G1"; 82. } 83. else if((gar1==1)&&(gar2==1)) 84. { 85. garasi="G2"; 86. } 87. BTSerial.print(lampu); // data yang dikirim untuk tombol hidup dan mati lampu 88. BTSerial.print(garasi); // data yang dikirim untuk tombol buka dan tutup 89. BTSerial.write("\r\n"); 90. kata=0; 91. delay(1000); 92. }
Gambar 4.23 List program cek_awal().
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
37
Di dalam fungsi cek_awal() terdapat perintah untuk mengecek setiap sensornya. Untuk hasil dari sensor LDR disimpan pada variabel ‘lampu’, sedangkan untuk pintu garasi disimpan dengan variabel ‘garasi’. Kemudian data dikirimkan ke Android satu paket dengan “\r\n”. Data yang dikirim dari Arduino Uno akan diterima oleh Android dan diolah pada fungsi terimaData(). Berikut fungsi terimaData() seperti gambar 4.24. 55. void terimaData() 56. { 57. final Handler handler = new Handler(); 58. final byte delimiter = 10; 59. stopWorker = false; 60. readBufferPosition = 0; 61. readBuffer = new byte[1024]; 62. workerThread = new Thread(new Runnable() { 63. public void run() { 64. while(!Thread.currentThread().isInterrupted() && !stopWorker) { 65. try 66. { 67. int bytesAvailable = mmInputStream.available(); 68. if(bytesAvailable > 0) 69. { 70. byte[] packetBytes = new byte[bytesAvailable]; 71. mmInputStream.read(packetBytes); 72. for(int i=0;i
Gambar 4.24 List fungsi terimaData()
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158.
159.
else if(lampu1=='0'){ caca3.setBackgroundColor(Color.RED); caca4.setBackgroundColor(Color.GRAY); } if(garasi1=='1'){ caca.setBackgroundColor(Color.GREEN); caca2.setBackgroundColor(Color.GRAY); } else if(garasi1=='0'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GRAY); } else if(garasi1=='2'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GREEN); } if(apa1=='a'){ caca.setBackgroundColor(Color.GREEN); caca2.setBackgroundColor(Color.GRAY);} else if(apa1=='b'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GRAY); } else if(apa1=='c'){ caca4.setBackgroundColor(Color.GREEN); caca3.setBackgroundColor(Color.GRAY); } else if(apa1=='d'){ caca3.setBackgroundColor(Color.RED); caca4.setBackgroundColor(Color.GRAY); } else if (apa1=='f'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GREEN); } else if (apa1=='g'){ caca3.setBackgroundColor(Color.RED); caca4.setBackgroundColor(Color.GREEN); } } }); } else { readBuffer[readBufferPosition++] = b; } } } } catch (IOException ex) { stopWorker = true; } } } }); workerThread.start(); }
Gambar 4.24 List terimaData() (lanjutan)
38
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
39
Pada fungsi terimaData() digunakan untuk menerima paket data yang dikirim oleh Android dan nantinya akan dijadikan indikator feedback sesuai dengan paket data yang diterima. Feedback akan dimunculkan seperti gambar 4.25.
Gambar 4.25 GUI feedback dari connect
4.5.2. Garasi Sistem ini berkaitan dengan 2 tombol yaitu tombol buka dan tombol tutup. Tombol buka akan mengirimkan data ‘a’(dalam bentuk char) ke Arduino Uno seperti pada gambar 4.26. 244. caca.setOnClickListener(new OnClickListener() { 245. @Override 246. public void onClick(View v) { 247. 248. send = "a"; // data yang dikirim dalam bentuk char 249. try { 250. 251. SendData(send); 252. Toast.makeText(getApplicationContext(), "a", Toast.LENGTH_SHORT).show(); 253. terimaData(); 254. } catch (IOException e) { 255. // TODO Auto-generated catch block 256. e.printStackTrace(); 257. 258. } 259. } 260. });
Gambar 4.26 List program tombol buka
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
40
Nilai ‘a’ akan dikirimkan ke Arduino Uno menggunakan fungsi SendData() seperti gambar 4.21. Setelah data diterima oleh Arduino Uno, maka data tersebut akan diolah sesuai dengan desimal ASCI pada gambar 4.22. Proses yang kemudian dilakukan adalah memanggil fungsi buka_pintu() seperti gambar 4.27. 94. void buka_pintu() 95. { 96. int a=0; 97. unsigned long i=0; 98. gar1=digitalRead(3);//LSA 99. //gar2=digitalRead(4);//LSB 100. gar3=7; 101. gar4=6; 102. pwm=5; 103. digitalWrite(gar3,HIGH); 104. digitalWrite(gar4,LOW); 105. analogWrite(pwm,225); 106. while((gar1!=0)&&(a==0)) 107. { 108. gar1=digitalRead(3); 109. i++; 110. if(i==800000){a=1;} 111. } 112. digitalWrite(gar3,LOW); 113. digitalWrite(gar4,LOW); 114. analogWrite(pwm,0); 115. if (a==1) 116. { 117. BTSerial.write("fxxx\r\n"); // paket data untuk feedback error 118. kata=0; 119. delay(200); 120. a=0; 121. } 122. else 123. { 124. BTSerial.write("axxx\r\n"); // paket data untuk feedback buka 125. kata=0; 126. delay(200); 127. } 128. }
Gambar 4.27 List fungsi buka_pintu() Dalam fungsi buka_pintu() motor dc bekerja berlawanan arah jarum jam. Apabila limit switch atas tertekan maka akan mengirimkan paket data yang natinya akan diolah pada fungsi terimaData() di Android sebagai feedback indikator seperti gambar 4.24. Feedback indikator yang muncul seperti gambar 4.28.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
41
Gambar 4.28 GUI feedback indikator buka Jika tombol tutup akan mengirimkan ‘b’(dalam bentuk char) seperti gambar 4.29 yang selanjutnya akan dikirim dengan fungsi SendData seperti gambar 4.21. 262. 263. 264. 265. 266. 267. 268. 269. 270. 271. 272. 273. 274. 275. 276.
caca2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub send="b";// data yang dikirim dalam bentuk char try { SendData(send); terimaData(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } });
Gambar 4.29 List tombol tutup Arduino akan mengolah data dan diterjemahkan menjadi desimal ASCI seperti gambar 4.22. Setelah data diolah masuk dalam fungsi tutup_pintu() seperti gambar 4.30. 130. void tutup_pintu() 131. { 132. int a=0; 133. unsigned long i=0; 134. gar2=digitalRead(4);//LSB 135. gar4=6; 136. gar3=7; 137. pwm=5; 138. digitalWrite(gar4,HIGH); 139. digitalWrite(gar3,LOW); 140. analogWrite(pwm,225);
Gambar 4.30 List fungsi tutup_pintu()
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
42
141. while((gar2!=0)&&(a==0)) 142. { 143. gar2=digitalRead(4); 144. i++; 145. if (i==800000){a=1;} 146. } 147. digitalWrite(gar4,LOW); 148. digitalWrite(gar3,LOW); 149. analogWrite(pwm,0); 150. if (a==1) 151. { 152. BTSerial.write("fxxx\r\n"); // paket data feedback error yang dikirim 153. kata=0; 154. delay(200); 155. a=0; 156. } 157. else 158. { 159. BTSerial.write("bxxx\r\n"); // paket data feedback indikator tutup 160. kata=0; 161. delay(200); 162. } 163. }
Gambar 4.30 List fungsi tutup_pintu()(lanjutan) Dalam fungsi tutup_pintu() motor akan bekerja searah jarum jam. Jika limit switch bawah terkena maka akan mengirimkan paket data yang nantinya diolah di fungsi terimaData() pada Android seperti pada gambar 4.24. Feedback indikator ini akan muncul seperti gambar 4.31.
Gambar 4.31 GUI feedback indikator tutup
4.5.3. Lampu Pengontrolan lampu mengunakan 2 tombol pada GUI yaitu tombol hidup dan mati. Apabila tombol hidup ditekan maka mengolah program seperti gambar 4.32.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
292. 293. 294. 295. 296. 297. 298. 299. 300. 301. 302. 303. 304. 305. 306.
43
caca4.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub send="c"; // data yanag dikirim dalam bentuk char try { SendData(send); terimaData(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); }}
Gambar 4.32 List progam hidup Data yang dikirim adalah ‘c’(dalam bentuk char). Fungsi yang digunakan untuk mengirim adalah fungsi SendData() seperti gambar 4.21. Data tersebut diterjemahkan menjadi desimal ASCI oleh Arduino Uno kemudian diolah pada program seperti gamabr 4.22. Pemanggilan fungsi hidup_lampu() seperti gambar 4.33 1. void hidup_lampu() 2. { 3. unsigned long i=0; 4. int a=0; 5. lam1=8; 6. lam=digitalRead(2); 7. Serial.println(lam); 8. digitalWrite(lam1,LOW); 9. while((lam!=0)&&(a==0)) 10. { 11. lam=digitalRead(2); 12. i++; 13. if (i==800000){a=1;} 14. } 15. if (a==1) 16. { 17. BTSerial.write("gxxx\r\n"); // feedback jika error terjadi 18. kata=0; 19. delay(200); 20. a=0; 21. } 22. else { 23. BTSerial.write("cxxx\r\n"); // paket data yg dikirim unutk indikator feedback hidup 24. kata=0; 25. delay(200); 26. } 27. }
Gambar 4.33 List fungsi hidup_lampu()
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
44
Fungsi hidup_lampu() digunakan untuk mengaktifkan relay. Setelah LDR terkena cahaya akan mengirimkan paket data yang diolah pada fungsi terimaData() pada Android seperti gambar 4.24. Feedback yang muncul dapat dilihat seperti gambar 4.34.
Gambar 4.34 GUI feedback indikator hidup Pada tombol mati maka akan dikirim data ‘d’(dalam bentuk char) seperti gambar 4.35. 278. 279. 280. 281. 282. 283. 284. 285. 286. 287. 288. 289. 290.
caca3.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub send="d"; // data yang dikirim dalam bentuk char try { SendData(send); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } });
Gambar 4.35 List program tombol mati Data tersebut kemudian dikirim menggunakan fungsi SendData() seperti gambar 4.21. Data yang diterima oleh Arduino Uno diterjemahkan menjadi desimal ASCI-nya dan dimasukan dalam program seperti gambar 4.22. data yang diterima kemudian masuk dalam fungsi mati_lampu() pada Arduino Uno seperti gambar 4.36.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
45
193. void matikan_lampu() 194. { 195. unsigned long i=0; 196. int a=0; 197. lam1=8; 198. lam=digitalRead(2); 199. Serial.println(lam); 200. digitalWrite(lam1,HIGH); 201. while((lam!=1)&&(a==0)){ 202. lam=digitalRead(2); 203. i++; 204. if (i==800000){a=1;} 205. } 206. if (a==1) 207. { 208. BTSerial.write("gxxx\r\n"); // data kesalahan yang dikirim 209. kata=0; 210. delay(200); 211. a=0; 212. } 213. else 214. { 215. BTSerial.write("dxxx\r\n"); // data untuk feedback mati 216. kata=0; 217. delay(200); 218. } 219. }
Gambar 4.36 List fungsi mati_lampu() Fungsi mati_lampu() digunakan untuk mematikan relay. Apabila LDR tidak mendapat cahaya maka mengirimkan paket data yang nantinya akan diolah di fungsi terimaData() seperti gambar 4.24. Feedback indikator dapat dilihat seperti gambar 4.37.
Gambar 4.37 GUI feedback indikator mati
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
46
4.5.4. Pengujian Feedback Error Seperti pada perancangan, akan ditambahkan progam untuk mengatasi apabila ada keadaan tidak terduga pada alat. Keadaan tidak terduga yang dimaksud adalah keadaan dimana pintu garsi tidak tertutup dengan sempurna dan apabila lampu yang digunakan telah rusak. Feddback error pada pintu garasi terjadi apabila ketika menjalankan fungsi buka_pintu() seperti gambar 4.27 limit switch atas maupun bawah tidak tertekanena. Seperti fungsi buka_pintu() pada gambar 4.27 dan tutup_pintu() pada gambar 4.30 maka akan mengirimkan paket data ke Android. Nantinya di Android akan diproses pada fungsi terimaData() seperti gambar 4.24 dan dibaca sebagai feedback error. Indikator feedbacknya ditunjukan seperti gambar 4.38.
Gambar 4.38 GUI feedback indikator error pintu garasi Untuk feedback error yang terjadi pada lampu apabila ketika menjalankan fungsi hidup_lampu() seperti gambar 4.33 namun LDR tidak mendapatkan cahaya maka akan mengirimkan data ke Android. Data itu disebut juga sebagai data dari feedback error. Indikator yang ditampilkan feedback seperti gambar 4.39.
Gambar 4.39 GUI feedback indikator error lampu
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 4.6.
47
Analisis Percobaan Pengambilan data dilakukan dengan cara mencoba setiap tombol pada GUI secara
acak sebayak 10 kali setiap koneksinya. Percobaan dilakukan sebanyak 5 kali koneksi antara Android dengan Arduino. Data yang diambil berdasarkan waktu setelah melakukan perintah yaitu 1 detik, 2 detik dan 3 detik seperti lampiran 1.1. Pengambilan data yang dilakukan 1 detik setelah melakukan perintah didapatkan sebanyak 50 data dengan jumlah data yang salah adalah 8 data. Berikut ini perhitungan keberhasilan alat dari data 1 detik setelah melakukan perintah. 𝑡𝑜𝑡𝑎𝑙 𝑗𝑢𝑚𝑙𝑎ℎ 𝑑𝑎𝑡𝑎−𝑑𝑎𝑡𝑎 𝑒𝑟𝑜𝑟 𝑡𝑜𝑡𝑎𝑙 𝑗𝑢𝑚𝑙𝑎ℎ 𝑑𝑎𝑡𝑎
𝑋 100% =
50−8 50
𝑥 100%= 84 %
Pengambilan data kedua dengan menunggu 2 detik setelah perintah dilakukan. Data yang didapatkan sebanyak 50 data dan data yang salah sebanyak 5 data. Dengan perhitungan keberhasilan alat sebagai berikut. 𝑡𝑜𝑡𝑎𝑙 𝑗𝑢𝑚𝑙𝑎ℎ 𝑑𝑎𝑡𝑎−𝑑𝑎𝑡𝑎 𝑒𝑟𝑜𝑟 𝑡𝑜𝑡𝑎𝑙 𝑗𝑢𝑚𝑙𝑎ℎ 𝑑𝑎𝑡𝑎
𝑋 100% =
50−5 50
𝑥 100%= 90 %
Pengambilan data terakhir dengan menunggu 3 detik setelah melakukan perintah. Data yang didapatkan sebanyak 50 data dengan data yang salah sebanyak 3 data. Dengan keberhasilan alat sebagai berikut. 𝑡𝑜𝑡𝑎𝑙 𝑗𝑢𝑚𝑙𝑎ℎ 𝑑𝑎𝑡𝑎−𝑑𝑎𝑡𝑎 𝑒𝑟𝑜𝑟 𝑡𝑜𝑡𝑎𝑙 𝑗𝑢𝑚𝑙𝑎ℎ 𝑑𝑎𝑡𝑎
𝑋 100% =
50−3 50
𝑥 100%= 94 %
Kesalahan yang didapatkan dalam pengujian adalah saat pengiriman data mati pada lampu. Data dapat terkirim dari Android dan dapat dikontrol oleh Arduino. Tetapi data yang diterima oleh Android tidak selalu sama dengan data yang dikirimkan oleh Arduino. Pengiriman paket data tidak dibaca sempurna oleh Android. Dari data percobaan pengujian limit switch untuk nilai logika tinggi adalah 5,021 volt dan logika rendah yang dipakai adalah 0 volt. Hal ini disebabkan ketika limit switch ditekan maka normaly open akan menyambung ke ground, tegangan yang mengalir ke Arduino adalah 0 volt. Ketika limit switch tidak tertekan maka tegangan yang masuk pada Arduino adalah 5,021 volt. Percobaan LDR untuk mendapatkan nilai logika tinggi tegangan yang dihasilkan tidak terkena cahaya adalah 3,045 volt dan logika rendah LDR apabila terkena cahaya dengan tegangan yang masuk kedalam Arduino adalah 0,155 volt. Hal ini disebabkan ketika LDR
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
48
terkena cahaya hambatan yang dihasilkan adalah 0,8907 kΩ. Ketika LDR tidak diberi cahaya maka akan menghasilkan hambatan 16,798 kΩ. Ketika melakukan perintah data yang dikirim akan dimunculkan pada GUI. GUI juga akan menampilkan data yang dikirim oleh mikrokontroler. Setelah data yang diterima oleh Android muncul, maka lebih baik menunggu 2 sampai 3 detik untuk melakukan perintah selanjutnya. Hal tersebut berfungsi untuk pengiriman dan penerimaan data dapat dijalankan secara maksimal. Selain itu dapat juga mengurangi kesalahan program yang terjadi apabila perintah yang dijalankan terlalu cepat.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
BAB V KESIMPULAN DAN SARAN
5.1 Kesimpulan Berdasarkan hasil dari proses penelitian dapat diambil kesimpulan sebagai berikut : 1. Proses penelitian telah berhasil menghasilkan sebuah sistem menggunakan Bluetooth sebagai alat untuk pengiriman dan penerimaan data yang digunakan mengontrol pintu garasi dan lampu. 2. Keberhasilan dari sistem yang sudah dibuat paling bagus dengan menunggu 3 detik setelah melakukan perintah dengan persentase keberhasilan 94%. 3. Mikrokontroler yang digunakan adalah Arduino Uno karena pada Arduino mempunyai library yang aplikatif. 4. Posisi letak limit switch paling optimal adalah dengan model penempatan limit switch keempat.
5.2 Saran Untuk menghasilkan penelitian yang lebih baik, diberikan saran-saran yang berguna bagi pembaca antara lain : 1. Memperhatikan proses pengiriman data antara mikrokontroler dengan Android, karena terkadang data yang dikirimkan tidak seuai dengan data yang diterima. 2. Sistem dapat digunakan dalam skala yang lebih besar lagi. 3. Dimungkinkan penambahan fitur-fitur aplikatif dalam Android yang dapat mengontrol tidak hanya pintu garasi dan lampu saja.
49
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI DAFTAR PUSTAKA
[1]
Berita Teknologi, 2012, Data dan Fakta Tentang Teknologi Bluetooth, http://www.beritateknologi.com/data-dan-fakta-tentang-teknologi-bluetooth/ diakses tanggal 2 april 2015.
[2]
Artikel Lingkungan Hidup, _____, 12 Langkah Sederhana Menghemat Energy http://www.artikellingkunganhidup.com/12-langkah-sederhana-menghematenergi.html diakses tanggal 2 april 2015.
[3]
Borneo News, 2015, Pintu Jendela Terbuka Rumah Dimasuki Pencuri, http://borneonews.co.id/berita/13073-pintu-jendela-terbuka-rumah-dimasuki-pencuri diakses 2 april 2015.
[4]
Wagino, 2014, Lagi, Mobil Bak Terbuka Digondol Pencuri, http://cilacapmedia.com/index.php/hukum-a-kriminal/2569-lagi-mobil-bak-terbukadigondol-pencuri.html diakses tanggal 2 april 2015.
[5]
Purnama, Galuh Yudha, 2007, Pengendali Putaran Arah Rumah Pada Pemodelan Rumah Pintar, Falkutas Teknik Univeritas Sanata Dharma, Yogyakarta.
[6]
Aingindra, 2013, Android-Adalah-Pengertian-Android-Sistem Oprasi http://www.aingindra.com/android-adalah-pengertian-android-sistem-operasi.html, diakses 8 april 2015.
[7]
Plimbi Editor, 2015, Inilah TransformaiI dan Sejarah Android dari Masa ke Masa http://www.plimbi.com/news/157282/sejarah-android, diakses tanggal 10 april 2015
[8]
JavaTpoin, _____, Android Architecure, http://www.javatpoint.com/androidsoftware-stack, diakses tanggal 15 april 2015.
[9]
Wijaya, Krisna Ketut, 2014, Dev Series : 5 Sumber Untuk Belajar Perkembangan Aplikasi http://id.techinasia.com/developer-series-sumber-belajar-pengembanganaplikasi-android/, diakses tanggal 15 april 2015.
[10] Parikh, Bijal, _____, Bluetooth Protocol (Part 2): Types, Data Exchange, Security, http://www.engineersgarage.com/articles/bluetooth-protocol-types-security, diakses tanggal 15 april 2015.
50
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
51
[11] Android Developers, _____, Bluetooth, http://developer.android.com/guide/topics/connectivity/bluetooth.htm, diakses tanggal 15 april 2015. [12] [13]
_____, 2006, Data Sheet Bluetooth Module, Linvor Blue T. Elektronika Dasar, 2012, Pengertian Dan Kelebihan Mikrokontroler, http://elektronikadasar.web.id/artikel-elektronika/pengertian-dan-kelebihan-mikrokontroler/, diakses tanggal 18 april 2015.
[14] [15]
_____, 2003, Data Sheet Microcontroler At 8535, Atmel. Elektro Kontrol, 2011, Membuat Sinyal PWM Mengunakan Timer AVR, http://elektrokontrol.blogspot.com/2011/06/membuat-sinyal-pwm-menggunakan-timer.html, diakses tangal 20 april 2015.
[16]
_____, 2002, Data Sheet L293, L293d Quardruple Half-H Divers, Texsas Instrumen.
[17]
Kho, Dikson, 2014, Pengertian LDR dan Cara Mengukurnya, http://teknikelektronika.com/pengertian-ldr-light-dependent-resistor-cara-mengukur-ldr/, diakses tanggal 20 april 2015.
[18]
Elektronika Dasar, 2012, Limit Saklar Dan Saklar Push On, http://elektronikadasar.web.id/komponen/limit-switch-dan-saklar-push-on/ , diakses tanggal 21 april 2015.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
LAMPIRAN
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
LAMPIRAN 1.1 DATA PERCOBAAN
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
L1
Data percobaan 1 KONDISI Hidup Mati Tutup Hidup Buka Mati Tutup Hidup Mati Feedback Error
1 detik T c d b c a d b c d b
2 detik R c b c a b c f
T c d b c a d b c d b
3 detik R c b c a d b c d f
T c d b c a d b c d b
R c d b c a d b c d f
Cek awal R = L0G1 T=e KONDISI Buka Tutup Buka Hidup Mati Tutup Hidup Buka Mati Hidup Cek awal R = L0G0 T=e
1 detik T a b a c d b c a d c
2 detik R a b a c b c a d c
T a b a c d b c a d c
3 detik R a b a c d b c a c
T a b a c d b c a d c
R a b a c d b c a d c
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI KONDISI Tutup Hidup Mati Buka Tutup Buka Hidup Mati Hidup Mati
1 detik T b c d a b a c d c d
2 detik R b c d a b a c c d
T b c d a b a c d c d
R a c d c b a d b c f
T a c d c b a d b c b
L2
3 detik R b c d a b a c c d
T b c d a b a c d c d
R a c c b a b c f
T a c d c b a d b c b
R b c a b a c d c d
Cek awal R =L0G1 T=e KONDISI Buka Hidup Mati Hidup Tutup Buka Mati Tutup Hidup Feedback Error Cek awal R = L0G0 T=e
1 detik T a c d c b a d b c b
2 detik
3 detik R a c c b a d b c f
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
KONDISI Mati Buka Tutup Hidup Buka Mati Hidup Mati Tutup Feedback Error Cek awal R = L1G0 T=e
1 detik T d a b c a d c d b c
2 detik R d a b c a c b f
T d a b c a d c d b c
L3
3 detik R d a b c a d c d b f
T d a b c a d c d b c
R d a b c a c d b f
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
LAMPIRAN LISTING PROGRAM ARDUINO
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Program Arduino 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51.
#include <SoftwareSerial.h> SoftwareSerial BTSerial(10, 11); // RX | TX int kata, lam, gar1, gar2, gar3, gar4, lam1, pwm; String lampu; String garasi; void setup() { //* inisialisasi pin kata=0; pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode pinMode(2,INPUT);//LDR pinMode(3,INPUT);//LSA pinMode(4,INPUT);//LSB pinMode(5,OUTPUT);//pwm pinMode(6,OUTPUT);//ccw pinMode(7,OUTPUT);//cw pinMode(8,OUTPUT);//lampu //digitalWrite(7, HIGH); digitalWrite(9, HIGH); Serial.begin(9600); Serial.println("Enter AT commands:"); BTSerial.begin(9600); // HC-05 default speed in AT command more digitalWrite(8,HIGH); digitalWrite(7,LOW); digitalWrite(6,LOW); } void loop() { // Keep reading from HC-05 and send to Arduino Serial Monitor if (BTSerial.available()) { //Serial.write(BTSerial.read()); kata=BTSerial.read(); Serial.write(kata); } if (kata==101) // cek awal ) // decimal ASCI ‘e’ { cek_awal(); kata=0; //delay(3000); } else if (kata==97) // decimal ASCI ‘a’ { buka_pintu(); } else if (kata==98) ) // decimal ASCI ‘b’ { tutup_pintu(); }
L4
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
52. else if (kata==99) ) // decimal ASCI ‘c’ 53. { 54. hidup_lampu(); 55. } 56. else if(kata==100) ) // decimal ASCI ‘d’ 57. { 58. matikan_lampu(); 59. } 60. } 61. //* program yang digunakan unutk mengecek keadaan awal 62. void cek_awal() 63. { 64. lam=digitalRead(2); 65. gar1=digitalRead(3);//LSA 66. gar2=digitalRead(4);//LSB 67. if (lam==1)//mati lampu 68. { 69. lampu="L0"; 70. } 71. else if (lam==0)//hidup lampu 72. { 73. lampu="L1"; 74. } 75. if ((gar1==1)&&(gar2==0))//tutup pintu 76. { 77. garasi="G0"; 78. } 79. else if ((gar1==0)&&(gar2==1))//buka pintu 80. { 81. garasi="G1"; 82. } 83. else if((gar1==1)&&(gar2==1)) 84. { 85. garasi="G2"; 86. } 87. BTSerial.print(lampu); // data yang dikirim untuk tombol hidup dan mati lampu 88. BTSerial.print(garasi); // data yang dikirim untuk tombol buka dan tutup 89. BTSerial.write("\r\n"); 90. kata=0; 91. delay(1000); 92. } 93. //* program untuk membuka pintu garasi 94. void buka_pintu() 95. { 96. int a=0; 97. unsigned long i=0; 98. gar1=digitalRead(3);//LSA 99. //gar2=digitalRead(4);//LSB 100. gar3=7; 101. gar4=6; 102. pwm=5; 103. digitalWrite(gar3,HIGH); 104. digitalWrite(gar4,LOW);
L5
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
105. analogWrite(pwm,225); 106. while((gar1!=0)&&(a==0)) 107. { 108. gar1=digitalRead(3); 109. i++; 110. if(i==800000){a=1;} 111. } 112. digitalWrite(gar3,LOW); 113. digitalWrite(gar4,LOW); 114. analogWrite(pwm,0); 115. if (a==1) 116. { 117. BTSerial.write("fxxx\r\n"); // paket data untuk feedback error 118. kata=0; 119. delay(200); 120. a=0; 121. } 122. else 123. { 124. BTSerial.write("axxx\r\n"); // paket data untuk feedback buka 125. kata=0; 126. delay(200); 127. } 128. } 129. //* menjalankan perintah unutk menutup pintu garasi 130. void tutup_pintu() 131. { 132. int a=0; 133. unsigned long i=0; 134. gar2=digitalRead(4);//LSB 135. gar4=6; 136. gar3=7; 137. pwm=5; 138. digitalWrite(gar4,HIGH); 139. digitalWrite(gar3,LOW); 140. analogWrite(pwm,225); 141. while((gar2!=0)&&(a==0)) 142. { 143. gar2=digitalRead(4); 144. i++; 145. if (i==800000){a=1;} 146. } 147. digitalWrite(gar4,LOW); 148. digitalWrite(gar3,LOW); 149. analogWrite(pwm,0); 150. if (a==1) 151. { 152. BTSerial.write("fxxx\r\n"); // paket data feedback error yang dikirim 153. kata=0; 154. delay(200); 155. a=0; 156. } 157. else
L6
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
158. { 159. BTSerial.write("bxxx\r\n"); // paket data feedback indikator tutup 160. kata=0; 161. delay(200); 162. } 163. } 164. //*menjalanka perintah untuk menghidupkan lampu 165. void hidup_lampu() 166. { 167. unsigned long i=0; 168. int a=0; 169. lam1=8; 170. lam=digitalRead(2); 171. Serial.println(lam); 172. digitalWrite(lam1,LOW); 173. while((lam!=0)&&(a==0)) 174. { 175. lam=digitalRead(2); 176. i++; 177. if (i==800000){a=1;} 178. } 179. if (a==1) 180. { 181. BTSerial.write("gxxx\r\n"); // feedback jika eror terjadi 182. kata=0; 183. delay(200); 184. a=0; 185. } 186. else { 187. BTSerial.write("cxxx\r\n"); // paket data yg dikirim unutk indikator feedback hidup 188. kata=0; 189. delay(200); 190. } 191. } 192. //* program untuk mematikan lampu 193. void matikan_lampu() 194. { 195. unsigned long i=0; 196. int a=0; 197. lam1=8; 198. lam=digitalRead(2); 199. Serial.println(lam); 200. digitalWrite(lam1,HIGH); 201. while((lam!=1)&&(a==0)){ 202. lam=digitalRead(2); 203. i++; 204. if (i==800000){a=1;} 205. } 206. if (a==1) 207. { 208. BTSerial.write("gxxx\r\n"); // data kesalahan yang dikirim 209. kata=0; 210. delay(200);
L7
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
211. a=0; 212. } 213. else 214. { 215. BTSerial.write("dxxx\r\n"); // data untuk feedback mati 216. kata=0; 217. delay(200); 218. } 219. }
L8
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
LAMPIRAN LISTING PROGRAM ANDROID
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Program Android
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51.
//* inisialisasi awal package com.example.halo; import java.util.Set; import android.R.string; import android.annotation.SuppressLint; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; import java.util.UUID; import java.io.InputStream; import java.io.OutputStream; import android.bluetooth.BluetoothSocket; import android.content.Intent; import java.io.IOException; public class MainActivity extends Activity { int A=0; int B=0; int C=0; int D=0; int readBufferPosition; byte[] readBuffer; Thread workerThread; Handler bluetoothIn; final int handlerState = 0; //used to identify handler message private StringBuilder recDataString = new StringBuilder(); protected BluetoothDevice localBluetoothDevice; protected BluetoothDevice mmDevice; protected boolean btdev; volatile boolean stopWorker; protected BluetoothAdapter mBluetoothAdapter; private String send; private BluetoothSocket mmSocket; private InputStream mmInputStream; private OutputStream mmOutputStream; private static final String TAG = "BlueComm"; public String kalimat; public String apa; //* mengirim data dari android void SendData(String data)throws IOException{ mmOutputStream.write(data.getBytes()); mmOutputStream.flush();
L9
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 52. } 53. 54. //* terima data dari mikrokontroler 55. void terimaData() 56. { 57. final Handler handler = new Handler(); 58. final byte delimiter = 10; 59. stopWorker = false; 60. readBufferPosition = 0; 61. readBuffer = new byte[1024]; 62. workerThread = new Thread(new Runnable() { 63. public void run() { 64. while(!Thread.currentThread().isInterrupted() && !stopWorker) { 65. try 66. { 67. int bytesAvailable = mmInputStream.available(); 68. if(bytesAvailable > 0) 69. { 70. byte[] packetBytes = new byte[bytesAvailable]; 71. mmInputStream.read(packetBytes); 72. for(int i=0;i
L10
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159.
caca.setBackgroundColor(Color.GREEN); caca2.setBackgroundColor(Color.GRAY); } else if(garasi1=='0'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GRAY); } else if(garasi1=='2'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GREEN); } if(apa1=='a'){ caca.setBackgroundColor(Color.GREEN); caca2.setBackgroundColor(Color.GRAY);} else if(apa1=='b'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GRAY); } else if(apa1=='c'){ caca4.setBackgroundColor(Color.GREEN); caca3.setBackgroundColor(Color.GRAY); } else if(apa1=='d'){ caca3.setBackgroundColor(Color.RED); caca4.setBackgroundColor(Color.GRAY); } else if (apa1=='f'){ caca2.setBackgroundColor(Color.RED); caca.setBackgroundColor(Color.GREEN); } else if (apa1=='g'){ caca3.setBackgroundColor(Color.RED); caca4.setBackgroundColor(Color.GREEN); } } }); } else { readBuffer[readBufferPosition++] = b; } } } } catch (IOException ex) { stopWorker = true; } } } }); workerThread.start(); }
L11
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 160. 161. @SuppressLint("HandlerLeak") 162. @Override 163. protected void onCreate(Bundle savedInstanceState) { 164. super.onCreate(savedInstanceState); 165. setContentView(R.layout.activity_main); 166. final Button caca=(Button)findViewById(R.id.button1); 167. final Button caca2=(Button)findViewById(R.id.button2); 168. final Button caca3=(Button)findViewById(R.id.button3); 169. final Button caca4=(Button)findViewById(R.id.button4); 170. final Button caca5=(Button)findViewById(R.id.connect); 171. mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 172. if(!mBluetoothAdapter.isEnabled()) 173. { 174. Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); 175. startActivityForResult(enableBluetooth, 0); 176. } 177. 178. //*tombol koneksi 179. caca5.setOnClickListener(new OnClickListener() { 180. 181. @Override 182. public void onClick(View v) { 183. // TODO Auto-generated method stub 184. 185. Set pairedDevices = mBluetoothAdapter.getBondedDevices(); 186. if(pairedDevices.size() > 0) 187. { 188. for(BluetoothDevice device : pairedDevices) 189. { 190. if(device.getName().equals("HC-05")) //Note, you will 191. //need to change this to match the name of your device 192. { 193. mmDevice = device; 194. Toast.makeText(getApplicationContext(), "Connected", Toast.LENGTH_SHORT).show(); 195. 196. break; 197. } 198. } 199. } 200. //* UUID universal yang digunakan 201. UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); 202. //Standard SerialPortService ID 203. 204. try { 205. mmSocket = mmDevice.createRfcommSocketToServiceRecord(uuid); 206. } catch (IOException e) { 207. // TODO Auto-generated catch block 208. e.printStackTrace(); 209. } 210.
L12
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223. 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234. 235. 236. 237. 238. 239. 240.
try { mmSocket.connect(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { mmOutputStream = mmSocket.getOutputStream(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try {
mmInputStream = mmSocket.getInputStream(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //beginListenForData(); send="e"; // data yang dikirim dalam char try { SendData(send); terimaData(); } catch (IOException e) { //TODO Auto-generated catch block e.printStackTrace(); } Toast.makeText(getApplicationContext(), "data di terima", Toast.LENGTH_SHORT).show(); 241. } 242. }); 243. //* isi dari tombol buka 244. caca.setOnClickListener(new OnClickListener() { 245. @Override 246. public void onClick(View v) { 247. 248. send = "a"; // data yang dikirim dalam bentuk char 249. try { 250. 251. SendData(send); 252. Toast.makeText(getApplicationContext(), "a", Toast.LENGTH_SHORT).show(); 253. terimaData(); 254. } catch (IOException e) { 255. // TODO Auto-generated catch block 256. e.printStackTrace(); 257. 258. } 259. } 260. }); 261. //* isi tombol tutup 262. caca2.setOnClickListener(new OnClickListener() {
L13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI 263. @Override 264. public void onClick(View v) { 265. // TODO Auto-generated method stub 266. 267. send="b";// data yang dikirim dalam bentuk char 268. try { 269. SendData(send); 270. terimaData(); 271. } catch (IOException e) { 272. // TODO Auto-generated catch block 273. e.printStackTrace(); 274. } 275. } 276. }); 277. //*isi dari tombol mati 278. caca3.setOnClickListener(new OnClickListener() { 279. public void onClick(View v) { 280. // TODO Auto-generated method stub 281. 282. send="d"; // data yang dikirim dalam bentuk char 283. try { 284. SendData(send); 285. } catch (IOException e) { 286. // TODO Auto-generated catch block 287. e.printStackTrace(); 288. } 289. } 290. }); 291. //* isi dari tombol hidup 292. caca4.setOnClickListener(new OnClickListener() { 293. public void onClick(View v) { 294. // TODO Auto-generated method stub 295. send="c"; // data yanag dikirim dalam bentuk char 296. try { 297. SendData(send); 298. terimaData(); 299. } catch (IOException e) { 300. // TODO Auto-generated catch block 301. e.printStackTrace(); 302. } 303. } 304. }); 305. 306. }} 307.
L14
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Program Xml android <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="buka" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="162dp" android:layout_toRightOf="@+id/button1" android:text="hidup" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/button4" android:layout_alignBottom="@+id/button4" android:layout_toRightOf="@+id/button4" android:text="mati" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/button4" android:layout_alignParentTop="true" android:text="tutup" /> <Button android:id="@+id/connect" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="22dp" android:text="connect" />
L15
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
LAMPIRAN DATASHEET
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
L298
DUAL FULL-BRIDGE DRIVER
.. .. .
OPERATING SUPPLY VOLTAGE UP TO 46 V TOTAL DC CURRENT UP TO 4 A LOW SATURATION VOLTAGE OVERTEMPERATURE PROTECTION LOGICAL ”0” INPUT VOLTAGE UP TO 1.5 V (HIGH NOISE IMMUNITY)
DESCRIPTION The L298 is an integrated monolithic circuit in a 15lead Multiwatt and PowerSO20 packages. It is a high voltage, high current dual full-bridge driver designed to accept standardTTL logic levels and drive inductive loads such as relays, solenoids, DC and stepping motors. Two enableinputs are provided to enableor disable the deviceindependentlyof the input signals. The emitters of the lower transistors of each bridge are connected together and the corresponding external terminal can be used for the con-
Multiw att15
PowerSO20
O RDERING NUMBERS : L298N (Multiwatt Vert.) L298HN (Multiwatt Horiz.) L298P (PowerSO20)
nectionof an externalsensing resistor. Anadditional supply input is provided so that the logic works at a lower voltage.
BLOCK DIAGRAM
Jenuary 2000
1/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 ABSOLUTE MAXIMUM RATINGS Symb ol
Parameter
Value
Unit
VS
Power Supply
50
V
V SS
Logic Supply Voltage
7
V
–0.3 to 7
V
3 2.5 2
A A A
VI,Ven IO
Vsens
Input and Enable Voltage Peak Output Current (each Channel) – Non Repetitive (t = 100µs) –Repetitive (80% on –20% off; ton = 10ms) –DC Operation Sensing Voltage
–1 to 2.3
V
25
W
Junction Operating Temperature
–25 to 130
°C
Storage and Junction Temperature
–40 to 150
°C
P tot
Total Power Dissipation (Tcase = 75°C)
Top Tstg, Tj
PIN CONNECTIONS (top view)
Multiwatt15
15
CURRENT SENSING B
14
OUTPUT 4
13
OUTPUT 3
12
INPUT 4
11
ENABLE B
10
INPUT 3
9
LOGIC SUPPLY VOLTAGE VSS
8
GND
7
INPUT 2
6
ENABLE A
5
INPUT 1
4
SUPPLY VOLTAGE VS
3
OUTPUT 2
2
OUTPUT 1
1
CURRENT SENSING A
TAB CONNECTED TO PIN 8
D95IN240A
GND
1
20
GND
Sense A
2
19
Sense B
N.C.
3
18
N.C.
17
Out 4
16
Out 3
Out 1
4
Out 2
5
VS
6
15
Input 4
Input 1
7
14
Enable B
Enable A
8
13
Input 3
Input 2
9
12
VSS
10
11
GND
GND
PowerSO20
D95IN239
THERMAL DATA Symb ol
Po werSO20
Mu ltiwatt15
Unit
Rth j-case
Thermal Resistance Junction-case
Parameter Max.
–
3
°C/W
Rth j-amb
Thermal Resistance Junction-ambient
Max.
13 (*)
35
°C/W
(*) Mounted on aluminum substrate
2/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 PIN FUNCTIONS (refer to the block diagram) MW.15
Po werSO
Name
1;15
2;19
Sense A; Sense B
Between this pin and ground is connected the sense resistor to control the current of the load.
Fun ction
2;3
4;5
Out 1; Out 2
Outputs of the Bridge A; the current that flows through the load connected between these two pins is monitored at pin 1.
4
6
VS
Supply Voltage for the Power Output Stages. A non-inductive 100nF capacitor must be connected between this pin and ground.
5;7
7;9
Input 1; Input 2
6;11
8;14
Enable A; Enable B
TTL Compatible Inputs of the Bridge A.
8
1,10,11,20
GND
Ground.
9
12
VSS
Supply Voltage for the Logic Blocks. A100nF capacitor must be connected between this pin and ground.
10; 12
13;15
Input 3; Input 4
13; 14
16;17
Out 3; Out 4
–
3;18
N.C.
TTL Compatible Enable Input: the L state disables the bridge A (enable A) and/or the bridge B (enable B).
TTL Compatible Inputs of the Bridge B. Outputs of the Bridge B. The current that flows through the load connected between these two pins is monitored at pin 15. Not Connected
ELECTRICAL CHARACTERISTICS (VS = 42V; VSS = 5V, Tj = 25°C; unless otherwise specified) Symbol
Parameter
VS
Supply Voltage (pin 4)
VSS
Logic Supply Voltage (pin 9)
Test Co nditions Operative Condition
Min . 4.5
Ven = H; IL = 0
Typ .
VIH +2.5
Unit
46
V
5
7
V
13 50
22 70
mA mA
4
mA
24 7
36 12
mA mA
6
mA
1.5
V
IS
Quiescent Supply Current (pin 4)
ISS
Quiescent Current from VSS (pin 9) Ven = H; IL = 0
V iL
Input Low Voltage (pins 5, 7, 10, 12)
–0.3
ViH
Input High Voltage (pins 5, 7, 10, 12)
2.3
VSS
V
IiL
Low Voltage Input Current (pins 5, 7, 10, 12)
Vi = L
–10
µA
IiH
High Voltage Input Current (pins 5, 7, 10, 12)
Vi = H ≤ VSS –0.6V
100
µA
Ven = L
Vi = L Vi = H
Max.
Vi = X
Ven = L
Vi = L Vi = H Vi = X
30
Ven = L
Enable Low Voltage (pins 6, 11)
–0.3
1.5
V
Ven = H
Enable High Voltage (pins 6, 11)
2.3
VSS
V
Ien = L
Low Voltage Enable Current (pins 6, 11)
Ven = L
–10
µA
Ien = H
High Voltage Enable Current (pins 6, 11)
Ven = H ≤ VSS –0.6V
30
100
µA
0.95
1.35 2
1.7 2.7
V V
1.2 1.7
1.6 2.3
V V
VCEsat (H) Source Saturation Voltage
IL = 1A IL = 2A
VCEsat (L) Sink Saturation Voltage
IL = 1A IL = 2A
(5) (5)
0.85
IL = 1A IL = 2A
(5) (5)
1.80
3.2 4.9
V V
–1 (1)
2
V
VCEsat
Total Drop
Vsens
Sensing Voltage (pins 1, 15)
3/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 ELECTRICAL CHARACTERISTICS (continued) Symbol
Parameter
Test Co nditions
Min .
Typ .
Max.
Unit
T1 (Vi)
Source Current Turn-off Delay
0.5 V i to 0.9 I L
(2); (4)
1.5
µs
T2 (Vi)
Source Current Fall Time
0.9 IL to 0.1 IL
(2); (4)
0.2
µs
T3 (Vi)
Source Current Turn-on Delay
0.5 V i to 0.1 I L
(2); (4)
2
µs
T4 (Vi)
Source Current Rise Time
0.1 IL to 0.9 IL
(2); (4)
0.7
µs
T5 (Vi)
Sink Current Turn-off Delay
0.5 V i to 0.9 I L
(3); (4)
0.7
µs
T6 (Vi)
Sink Current Fall Time
0.9 IL to 0.1 IL
(3); (4)
0.25
µs
T7 (Vi)
Sink Current Turn-on Delay
0.5 V i to 0.9 I L
(3); (4)
1.6
µs
T8 (Vi)
Sink Current Rise Time
0.1 IL to 0.9 IL
(3); (4)
0.2
µs
Commutation Frequency
IL = 2A
T1 (Ven)
fc (Vi)
Source Current Turn-off Delay
0.5 V en to 0.9 IL
25
T2 (Ven)
Source Current Fall Time
0.9 IL to 0.1 IL
T3 (Ven)
Source Current Turn-on Delay
0.5 V en to 0.1 IL
T4 (Ven)
Source Current Rise Time
0.1 IL to 0.9 IL
T5 (Ven)
Sink Current Turn-off Delay
0.5 V en to 0.9 IL
(2); (4) (2); (4) (2); (4) (2); (4)
T6 (Ven)
Sink Current Fall Time
0.9 IL to 0.1 IL
T7 (Ven)
Sink Current Turn-on Delay
0.5 V en to 0.9 IL
T8 (Ven)
Sink Current Rise Time
0.1 IL to 0.9 IL
(3); (4) (3); (4) (3); (4) (3); (4)
40
µs
1
µs
0.3
µs
0.4
µs
2.2
µs
0.35
µs
0.25
µs
0.1
µs
1) 1)Sensing voltage can be –1 V for t ≤ 50 µsec; in steady state V sens min ≥ – 0.5 V. 2) See fig. 2. 3) See fig. 4. 4) The load must be a pure resistor.
Figure 1 : Typical Saturation Voltage vs. Output Current.
Figure 2 : Switching Times Test Circuits.
Note : For INPUT Switching, set EN = H For ENABLESwitching, set IN = H
4/13
KHz
3
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 Figure 3 : Source Current Delay Times vs. Input or Enable Switching.
Figure 4 : Switching Times Test Circuits.
Note : For INPUT Switching, set EN = H For ENABLE Switching, set IN = L
5/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 Figure 5 : Sink Current Delay Times vs. Input 0 V Enable Switching.
Figure 6 : Bidirectional DC Motor Control.
In pu ts Ven = H
Ven = L L = Low
6/13
Fu nctio n
C=H;D=L
Forward
C =L; D= H
Reverse
C=D
Fast Motor Stop
C=X;D=X
Free Running Motor Stop
H = High
X = Don’t care
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 Figure 7 : For higher currents, outputs can be paralleled. Take care to parallel channel 1 with channel 4 and channel 2 with channel 3.
APPLICATION INFORMATION (Refer to the block diagram) 1.1. POWER OUTPUT STAGE Each input must be connected to the source of the driving signals by means of a very short path. TheL298integratestwo poweroutputstages(A ; B). The power output stage is a bridge configuration Turn-On and Turn-Off : Before to Turn-ON the Supand its outputs can drive an inductive load in comply Voltageand beforeto Turnit OFF, the Enableinmon or differenzialmode, dependingon the state of put must be driven to the Low state. the inputs. The current that flows through the load 3. APPLICATIONS comes out from the bridge at the sense output : an Fig 6 shows a bidirectional DC motor control Scheexternal resistor (RSA ; RSB.) allows to detect the inmatic Diagram for which only one bridge is needed. tensity of this current. The external bridge of diodes D1 to D4 is made by 1.2. INPUT STAGE four fast recovery elements (trr ≤ 200 nsec) that Each bridge is driven by means of four gates the inmust be chosen of a VF as low as possible at the put of which are In1 ; In2 ; EnA and In3 ; In4 ; EnB. worst case of the load current. The In inputs set the bridge state when The En input The sense outputvoltage can be used to control the is high ; a lowstate of the En inputinhibitsthe bridge. current amplitude by chopping the inputs, or to proAll the inputs are TTL compatible. vide overcurrent protection by switching low the enable input. 2. SUGGESTIONS The brake function (Fast motor stop) requires that A non inductive capacitor, usually of 100 nF, must the Absolute Maximum Rating of 2 Amps must be foreseen between both Vs and Vss, to ground, never be overcome. as near as possible to GND pin. When the large capacitor of the power supply is too far from the IC, a When the repetitive peak current needed from the second smaller one must be foreseen near the load is higher than 2 Amps, a paralleled configuraL298. tion can be chosen (See Fig.7). The sense resistor, not of a wire wound type, must An external bridge of diodes are required when inbe grounded near the negative pole of Vs that must ductive loads are driven and when the inputs of the be near the GND pin of the I.C. IC are chopped; Shottkydiodeswould bepreferred. 7/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 This solution can drive until 3 Amps In DC operation and until 3.5 Amps of a repetitive peak current. OnFig 8 it is shownthe driving ofa twophasebipolar stepper motor ; the needed signals to drive the inputs of the L298 are generated, in this example, from the IC L297. Fig 9 shows an example of P.C.B. designed for the application of Fig 8.
Fig 10 shows a second two phase bipolar stepper motor control circuit where the current is controlled by the I.C. L6506.
Figure 8 : Two Phase Bipolar Stepper Motor Circuit. This circuit drives bipolar stepper motors with winding currents up to 2 A. The diodes are fast 2 A types.
RS1 = RS2 = 0.5 Ω D1 to D8 = 2 A Fast diodes
8/13
{
VF ≤ 1.2 V @ I = 2 A trr ≤ 200 ns
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 Figure 9 : Suggested Printed Circuit Board Layout for the Circuit of fig. 8 (1:1 scale).
Figure 10 : Two Phase Bipolar Stepper Motor Control Circuit by Using the Current Controller L6506.
RR and Rsense depend from the load current
9/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 mm
DIM. MIN.
TYP.
inch MAX.
MIN.
TYP.
MAX.
A
5
0.197
B
2.65
0.104
C
1.6
D
0.063
1
0.039
E
0.49
0.55
0.019
F
0.66
0.75
0.026
G
1.02
1.27
1.52
0.040
0.050
0.060
G1
17.53
17.78
18.03
0.690
0.700
0.710
H1
19.6
0.022 0.030
0.772
H2
20.2
0.795
L
21.9
22.2
22.5
0.862
0.874
0.886
L1
21.7
22.1
22.5
0.854
0.870
0.886
L2
17.65
18.1
0.695
L3
17.25
17.5
17.75
0.679
0.689
0.699
L4
10.3
10.7
10.9
0.406
0.421
0.429
L7
2.65
2.9
0.104
0.713
0.114
M
4.25
4.55
4.85
0.167
0.179
0.191
M1
4.63
5.08
5.53
0.182
0.200
0.218
S
1.9
2.6
0.075
S1
1.9
2.6
0.075
0.102
Dia1
3.65
3.85
0.144
0.152
10/13
OUTLINE AND MECHANICAL DATA
0.102
Multiwatt15 V
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298 mm
DIM. MIN.
TYP.
inch MAX.
MIN.
TYP.
MAX.
A
5
0.197
B
2.65
0.104
C
1.6
0.063
E
0.49
0.55
0.019
0.022
F
0.66
0.75
0.026
0.030
G
1.14
1.27
1.4
0.045
0.050
0.055
G1
17.57
17.78
17.91
0.692
0.700
0.705
H1
19.6
0.772
H2
20.2
0.795
L
20.57
0.810
L1
18.03
0.710
L2
2.54
0.100
L3
17.25
17.5
17.75
0.679
0.689
0.699
L4
10.3
10.7
10.9
0.406
0.421
0.429
L5
5.28
L6
OUTLINE AND MECHANICAL DATA
0.208 0.094
2.38
L7
2.65
2.9
0.104
0.114
S
1.9
2.6
0.075
0.102
S1
1.9
2.6
0.075
0.102
Dia1
3.65
3.85
0.144
0.152
Multiwatt15 H
11/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298
DIM. A a1 a2 a3 b c D (1) D1 E e e3 E1 (1) E2 E3 G H h L N S T
MIN.
mm TYP.
0.1 0 0.4 0.23 15.8 9.4 13.9
MAX. 3.6 0.3 3.3 0.1 0.53 0.32 16 9.8 14.5
MIN. 0.004 0.000 0.016 0.009 0.622 0.370 0.547
1.27 11.43 10.9
inch TYP.
0.050 0.450 11.1 0.429 2.9 6.2 0.228 0.1 0.000 15.9 0.610 1.1 1.1 0.031 10° (max.) 8° (max.)
5.8 0 15.5 0.8
OUTLINE AND MECHANICAL DATA
MAX. 0.142 0.012 0.130 0.004 0.021 0.013 0.630 0.386 0.570
10
0.437 0.114 0.244 0.004 0.626 0.043 0.043
JEDEC MO-166
0.394
PowerSO20
(1) ”D and F” do not include mold flash or protrusions. - Mold flash or protrusions shall not exceed 0.15 mm (0.006”). - Critical dimensions: ”E”, ”G” and ”a3”
N
R
N a2 b
A
e
DETAIL A
c a1
DETAIL B
E
e3 H
DETAIL A
lead
D
slug
a3 DETAIL B 20
11
0.35 Gage Plane
-C-
S
SEATING PLANE
L
G
E2
E1
BOTTOM VIEW
T E3 1
h x 45
12/13
10
PSO20MEC
C
(COPLANARITY)
D1
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI L298
Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specification mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without express written approval of STMicroelectronics. The ST logo is a registered trademark of STMicroelectronics 2000 STMicroelectronics – Printed in Italy – All Rights Reserved STMicroelectronics GROUP OF COMPANIES Australia - Brazil - China - Finland - France - Germany - Hong Kong - India - Italy - Japan - Malaysia - Malta - Morocco Singapore - Spain - Sweden - Switzerland - United Kingdom - U.S.A. http://www.st.com
13/13
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
HC Serial Bluetooth Products User Instructional Manual 1 Introduction HC serial Bluetooth products consist of Bluetooth serial interface module and Bluetooth adapter, such as: (1) Bluetooth serial interface module: Industrial level:
HC-03, HC-04(HC-04-M, HC-04-S)
Civil level:
HC-05, HC-06(HC-06-M, HC-06-S) HC-05-D, HC-06-D (with baseboard, for test and evaluation)
(2) Bluetooth adapter: HC-M4 HC-M6 This document mainly introduces Bluetooth serial module. Bluetooth serial module is used for converting serial port to Bluetooth. These modules have two modes: master and slaver device. The device named after even number is defined to be master or slaver when out of factory and can’t be changed to the other mode. But for the device named after odd number, users can set the work mode (master or slaver) of the device by AT commands. HC-04 specifically includes: Master device:
HC-04-M, M=master
Slave device:
HC-04-S, S=slaver
The default situation of HC-04 is slave mode. If you need master mode, please state it clearly or place an order for HC-O4-M directly.The naming rule of HC-06 is same. When HC-03 and HC-05 are out of factory, one part of parameters are set for activating the device. The work mode is not set, since user can set the mode of HC-03, HC-05 as they want. The main function of Bluetooth serial module is replacing the serial port line, such as: 1. There are two MCUs want to communicate with each other. One connects to Bluetooth master device while the other one connects to slave device. Their connection can be built once the pair is made. This Bluetooth connection is equivalently liked to a serial port line connection including RXD, TXD
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
signals. And they can use the Bluetooth serial module to communicate with each other. 2. When MCU has Bluetooth salve module, it can communicate with Bluetooth adapter of computers and smart phones. Then there is a virtual communicable serial port line between MCU and computer or smart phone. 3. The Bluetooth devices in the market mostly are salve devices, such as Bluetooth printer, Bluetooth GPS. So, we can use master module to make pair and communicate with them. Bluetooth Serial module’s operation doesn’t need drive, and can communicate with the other Bluetooth device who has the serial. But communication between two Bluetooth modules requires at least two conditions: (1) The communication must be between master and slave. (2) The password must be correct. However, the two conditions are not sufficient conditions. There are also some other conditions basing on different device model. Detailed information is provided in the following chapters. In the following chapters, we will repeatedly refer to Linvor’s (Formerly known as Guangzhou HC Information Technology Co., Ltd.) material and photos.
2 Selection of the Module The Bluetooth serial module named even number is compatible with each other; The salve module is also compatible with each other. In other word, the function of HC-04 and HC-06, HC-03 and HC-05 are mutually compatible with each other. HC-04 and HC-06 are former version that user can’t reset the work mode (master or slave). And only a few AT commands and functions can be used, like reset the name of Bluetooth (only the slaver), reset the password, reset the baud rate and check the version number. The command set of HC-03 and HC-05 are more flexible than HC-04 and HC-06’s. Generally, the Bluetooth of HC-03/HC-05 is recommended for the user. Here are the main factory parameters of HC-05 and HC-06. Pay attention to the differences: HC-05
HC-06
Master and slave mode can be switched
Master and slave mode can’t be switched
Bluetooth name: HC-05
Bluetooth name: linvor
Password:1234
Password:1234
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Master role: have no function to remember the last paired salve device. It can be made paired to any slave
device.
In
other
words,
just
set Master role: have paired memory to remember
AT+CMODE=1 when out of factory. If you want last slave device and only make pair with that HC-05 to remember the last paired slave device device unless KEY (PIN26) is triggered by high address like HC-06, you can set AT+CMODE=0 level. The default connected PIN26 is low level. after paired with the other device. Please refer the command set of HC-05 for the details. Pairing: The master device can not only make pair with
the
specified
Bluetooth
address,
like
cell-phone, computer adapter, slave device, but Pairing: Master device search and make pair with also can search and make pair with the slave the slave device automatically. device automatically.
Typical method:
On some specific conditions,
Typical method: On some specific conditions, master and slave device can make pair with each master device and slave device can make pair with other automatically. each other automatically. (This is the default method.) Multi-device communication: There is only point Multi-device communication: There is only point to point communication for modules, but the to point communication for modules, but the adapter can communicate with multi-modules.
adapter can communicate with multi-modules.
AT Mode 1: After power on, it can enter the AT mode by triggering PIN34 with high level. Then the baud rate for setting AT command is equal to the baud rate in communication, for example: AT Mode: Before paired, it is at the AT mode. 9600. After paired it’s at transparent communication. AT mode 2: First set the PIN34 as high level, or while on powering the module set the PIN34 to be high level, the Baud rate used here is 38400 bps. Notice: All AT commands can be operated only
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
when the PIN34 is at high level. Only part of the AT commands can be used if PIN34 doesn’t keep the high level after entering to the AT mode. Through this kind of designing, set permissions for the module is left to the user’s external control circuit, that makes the application of HC-05 is very flexible. During the process of communication, the module can enter to AT mode by setting PIN34 to be high level. By releasing PIN34, the module can go back During the communication mode, the module to communication mode in which user can inquire can’t enter to the AT mode. some information dynamically. For example, to inquire the pairing is finished or not. Default
communication
baud
rate:
9600, Default
communication
baud
rate:
4800-1.3M are settable.
1200-1.3M are settable.
KEY: PIN34, for entering to the AT mode.
KEY: PIN26, for master abandons memory.
9600,
LED1: PIN31, indicator of Bluetooth mode. Slow flicker (1Hz) represents entering to the AT mode2, while fast flicker(2Hz) represents entering to the LED: The flicker frequency of slave device is AT mode1 or during the communication pairing. 102ms. If master device already has the memory Double flicker per second represents pairing is of slave device, the flicker frequency during the finished, the module is communicable.
pairing is 110ms/s. If not, or master has emptied
LED2: PIN32, before pairing is at low level, after the memory, then the flicker frequency is 750m/s. the pairing is at high level.
After pairing, no matter it’s a master or slave
The using method of master and slaver’s indicator device, the LED PIN is at high level. is the same.
Notice: The LED PIN connects to LED+ PIN.
Notice: The PIN of LED1 and LED2 are connected with LED+. Consumption: During the pairing, the current is Consumption: During the pairing, the current is
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
fluctuant in the range of 30-40mA. The mean fluctuant in the range of 30-40 m. The mean current is about 25mA. After paring, no matter current is about 25mA. After paring, no matter processing communication or not, the current is processing communication or not, the current is 8mA. There is no sleep mode. This parameter is 8mA. There is no sleep mode. This parameter is same for all the Bluetooth modules.
same for all the Bluetooth modules.
Reset: PIN11, active if it’s input low level. It can Reset: PIN11, active if it’s input low level. It can be suspended in using.
be suspended in using.
Level: Civil
Level: Civil
The table above that includes main parameters of two serial modules is a reference for user selection. HC-03/HC-05 serial product is recommended.
3. Information of Package The PIN definitions of HC-03, HC-04, HC-05 and HC-06 are kind of different, but the package size is the same: 28mm * 15mm * 2.35mm. The following figure 1 is a picture of HC-06 and its main PINs. Figure 2 is a picture of HC-05 and its main PINs. Figure 3 is a comparative picture with one coin. Figure 4 is their package size information. When user designs the circuit, you can visit the website of Guangzhou HC Information Technology Co., Ltd. (www.wavesen.com) to download the package library of protle version.
Figure 1
HC-06
Figure 2
HC-05
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Figure 3 Comparative picture with one coin
Figure 4 Package size information
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
4. The Using and Testing Method of HC-06 for the First Time This chapter will introduce the using method of HC-06 in detail. User can test the module according to this chapter when he or she uses the module at the first time. PINs description: PIN1
UART_TXD , TTL/CMOS level, UART Data output
PIN2
UART_RXD, TTL/COMS level, s UART Data input RESET, the reset PIN of module, inputting low level can reset the module,
PIN11 when the module is in using, this PIN can connect to air. VCC, voltage supply for logic, the standard voltage is 3.3V, and can work PIN12 at 3.0-4.2V PIN13
GND
PIN22
GND LED, working mode indicator Slave device: Before paired, this PIN outputs the period of 102ms square wave. After paired, this PIN outputs high level. Master device: On the condition of having no memory of pairing with a
PIN24 slave device, this PIN outputs the period of 110ms square wave. On the condition of having the memory of pairing with a slave device, this PIN outputs the period of 750ms square wave. After paired, this PIN outputs high level. For master device, this PIN is used for emptying information about pairing. After emptying, master device will search slaver randomly, then PIN26 remember the address of the new got slave device. In the next power on, master device will only search this address.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
(1) The circuit 1 (connect the module to 3.3V serial port of MCU) is showed by figure 5.
Figure 5 The circuit 1
In principle, HC-06 can work when UART_TXD, UART_RXD, VCC and GND are connected. However, for better testing results, connecting LED and KEY are recommended (when testing the master). Where, the 3.3V TXD of MCU connects to HC-06’s UART_RXD, the 3.3V RXD of MCU connects to HC-06’s UART_TXD, and 3.3V power and GND should be connected. Then the minimum system is finished. Note that, the PIN2:UART_RXD of Bluetooth module has no pull-up resistor. If the MCU TXD doesn’t have pull-up function, then user should add a pull-up resistor to the UART_RXD. It may be easy to be ignored. If there are two MCU which connect to master and slave device respectively, then before paired(LED will flicker) user can send AT commands by serial port when the system is power on. Please refer to HC-04 and HC-06’s data sheet for detailed commands. In the last chapter, the command set will be introduced. Please pay attention to that the command of HC-04/HC-06 doesn’t have terminator. For example, consider the call command, sending out AT is already enough, need not add the CRLF (carriage return line feed). If the LED is constant lighting, it indicates the pairing is finished. The two MCUs can communicate with each other by serial port. User can think there is a serial port line between two MCUs.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
(2) The circuit 2 (connect the module to 5V serial port of MCU) is showed by figure 6. Figure 6 is the block diagram of Bluetooth baseboard. This kind of circuit can amplify Bluetooth module’s operating voltage to 3.1-6.5V. In this diagram, the J1 port can not only be connected with MCU system of 3.3V and 5V, but also can be connected with computer serial port.
Figure 6 The circuit 2
(3) AT command test Before paired, the mode of HC-04 and HC-06 are AT mode. On the condition of 9600N81, OK will be received when user send the two letters AT. Please refer to the last chapter of datasheet for other commands of HC-06. Please pay attention to that sending out AT is already enough, need not add the CRLF (carriage return line feed). The command set of Version V1.4 doesn’t include parity. The version V1.5 and its later version have parity function. Moreover, there are three more commands of V1.5 than V1.4. They are: No parity (default)
AT+PN
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Odd parity
AT+PO
Even parity
AT+PE
Do not let the sending frequency of AT command of HC-06 exceed 1Hz, because the command of HC-06 end or not is determined by the time interval.
(4) Pairing with adapter User can refer to the download center of the company’s website for “The Introduction of IVT” that introduces the Bluetooth module makes pair with computer adapter. That document taking HC-06-D for example introduces how the serial module makes pair with the adapter. That method is like to make pair with cell-phone. But the difference is that cell-phone need a third-party communication software to help. It’s liked the kind of PC serial helper of and the hyper terminal. A software named “PDA serial helper” provided by our company is suitable for WM system. It has been proven that this serial module is supported by many smart phone systems’ Bluetooth, such as, sybian, android, windows mobile and etc.
(5) Pairing introduction HC-06 master device has no memory before the first use. If the password is correct, the mater device will make pair with the slave device automatically in the first use. In the following use, the master device will remember the Bluetooth address of the last paired device and search it. The searching won’t stop until the device is found. If master device’s PIN26 is input high level, the device will lose the memory. In that occasion, it’ll search the proper slave device like the first use. Based on this function, the master device can be set to make pair with the specified address or any address by user.
(6) Reset new password introduction User can set a new password for the HC-06 through AT+PINxxxx command. But the new password will become active after discharged all the energy of the module. If the module still has any energy, the old one is still active. In the test, for discharging all the system energy and activating the new password, we can connect the power supply PIN with GND about 20 seconds after the power is cut off. Generally, shutting down the device for 30 minutes also can discharge the energy, if there is no peripheral circuit helps discharge energy. User should make the proper way according to the specific situation.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
(7) Name introduction If the device has no name, it’s better that user doesn’t try to change the master device name. The name should be limited in 20 characters. Summary: The character of HC-06: 1 not many command 2 easy for application 3 low price. It’s good for some specific application. HC-04 is very similar with HC-06. Their only one difference is HC-04 is for industry, HC-06 is for civil. Except this, they don’t have difference. The following reference about HC-04 and HC-06 can be downloaded from company website www.wavesen.com: HC-06 datasheet .pdf
(the command set introduction is included)
HC-04 datasheet .pdf
(the command set introduction is included)
IVT BlueSoleil-2.6
(IVT Bluetooth drive test version)
Bluetooth FAQ.pdf HC-04-D(HD-06-D)datasheet(English).pdf HC-06-AT command software (test version)
(some commands in V1.5 is not supported by V1.4)
PCB package of Bluetooth key modules
(PCB package lib in protel)
IVT software manual.pdf
(introduce how to operate the modern and make pair with Bluetooth module)
PDA serial test helper.exe
(serial helper used for WM system)
5 manual for the first use of HC-05 This chapter will introduce how to test and use the HC-05 if it’s the first time for user to operate it. (1) PINs description PIN1
UART_TXD, Bluetooth serial signal sending PIN, can connect with MCU’s RXD PIN UART_RXD, Bluetooth serial signal receiving PIN, can connect with the MCU’s TXD PIN,
PIN2 there is no pull-up resistor in this PIN. But It needs to be added an eternal pull-up resistor. RESET, the reset PIN of module, inputting low level can reset the module, when the module PIN11 is in using, this PIN can connect to air. PIN12
VCC, voltage supply for logic, the standard voltage is 3.3V, and can work at 3.0-4.2V
PIN13
GND
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
LED1, indicator of work mode. Has 3 modes: When the module is supplied power and PIN34 is input high level, PIN31 output 1Hz square wave to make the LED flicker slowly. It indicates that the module is at the AT mode, and the baud rate is 38400; When the module is supplied power and PIN34 is input low level, PIN31 output 2Hz square wave to make the LED flicker quickly. It indicates the module is at the pairable mode. If PIN31 PIN34 is input high level, then the module will enter to AT mode, but the output of PIN31 is still 2Hz square wave. After the pairing, PIN31 output 2Hz square ware. Note: if PIN34 keep high level, all the commands in the AT command set can be in application. Otherwise, if just excite PIN34 with high level but not keep, only some command can be used. More information has provided at chapter 2. Output terminal. Before paired, it output low level. Once the pair is finished, it output high PIN32 level. Mode switch input. If it is input low level, the module is at paired or communication mode. If it’s input high level, the module will enter to AT mode. Even though the module is at PIN34 communication, the module can enter to the AT mode if PIN34 is input high level. Then it will go back to the communication mode if PIN34 is input low level again. (2) Application circuit 1 (connect to the 3.3V system)
Figure 7 Application 1
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
(3) Application circuit 2 (connect to 5V serial system or PC serial)
Figure 8 Application circuit 2
(4) AT command test This chapter introduces some common commands in use. The detail introduction about HC-05 command is in HC-0305 AT command set. Enter to AT mode: Way1: Supply power to module and input high level to PIN34 at the same time, the module will enter to AT mode with the baud rate-38400. Way2: In the first step, supply power to module; In the second step, input high level to PIN34. Then the module will enter to AT mode with the baud rate-9600. Way1 is recommended. Command structure: all command should end up with “\r\n” (Hex: 0X0D X0A) as the terminator. If
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
the serial helper is installed, user just need enter “ENTER” key at the end of command.
Reset the master-slave role command: AT+ROLE=0
----Set the module to be salve mode. The default mode is salve.
AT+ROLE=1
----Set the module to be master mode.
Set memory command: AT+CMODE=1 Set the module to make pair with the other random Bluetooth module (Not specified address). The default is this mode. AT+CMODE=1 Set the module to make pair with the other Bluetooth module (specified address). If set the module to make pair with random one first, then set the module to make pair with the Bluetooth module has specified address. Then the module will search the last paired module until the module is found.
Reset the password command AT+PSWD=XXXX Set the module pair password. The password must be 4-bits.
Reset the baud rate AT+UART== <Param>,<Param2>,<Param3>. More information is provided at HC-0305 command set Example: AT+UART=9600,0,0
----set the baud rate to be 9600N81
Reset the Bluetooth name AT+NAME=XXXXX
Summary: HC-05 has many functions and covers all functions of HC-06. The above commands are the most common ones. Besides this, HC-05 leaves lots of space for user. So HC-05 is better than HC-06 and
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
recommended. HC-03 is similar with HC-05. The above introduction also suits HC-03 The following reference about HC-03 and HC-05 can be downloaded from company website www.wavesen.com: HC-03 datasheet .pdf
(the command set introduction is included)
HC-05 datasheet .pdf
(the command set introduction is included)
IVT BlueSoleil-2.6
(IVT Bluetooth drive test version)
Bluetooth FAQ.pdf PCB package of Bluetooth key modules IVT software manual.pdf
(PCB package lib in protel) (introduce how to operate the modern and make pair with Bluetooth module)
PDA serial test helper.exe
(serial helper used for WM system)
HC-03/05 Bluetooth serial command set.pdf
6. Ordering information The website of Guangzhou HC Information Technology Co., Ltd is www.wavesen.com The contact information is provided at the company website. Order Way: If you want our product, you can give order to the production center of our company directly or order it in Taobao. There is a link to Taobao in our company website. Package: 50 pieces chips in an anti-static blister package. The weight of a module is about 0.9g. The weight of a package is about 50g.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Please provide the product’s model when you order: HC-04-M HC-04-S HC-06-M HC-06-S
HC-04 master module HC-04 slave module HC-06 master module HC-06 slave module
HC-03 HC-05
HC-03/05 can be preset to be master module or slave module.
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
Guangzhou HC Information Technology Co., Ltd.
Product Data Sheet
Module Data Sheet
Rev 1 1.0
1.01
2010/5/15
2011/4/6
MODEL : DRAWN BY :
HC-05
Ling Xin
Description: CHECKED BY :
Eric Huang
BC04 has external 8M Flash and EDR mode HC-03 is industrial, and compatible with civil HC-05
APPD.
BY:
Former version
Simon Mok
REV :
2.0
PAGES:
Linvaor is the former of Wavesen.
introduction www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
Contents 1. Product’s picture 2. Feature 3. Pins description 4. The parameters and mode of product 5. Block diagram 6. Debugging device 7. Characteristic of test 8. Test diagram 9. AT command set
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
1.Product’s picture
Figure 1. A Bluetooth module
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
Figure 2 50 pieces chips in an anti-static blister package
2. Feature
Wireless transceiver
Sensitivity (Bit error rate) can reach -80dBm.
The change range of output’s power:
-4 - +6dBm.
Function description (perfect Bluetooth solution) Has an EDR module; and the change range of modulation depth: 2Mbps - 3Mbps. Has a build-in 2.4GHz antenna; user needn’t test antenna.
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
Has the external 8Mbit FLASH Can work at the low voltage (3.1V~4.2V). The current in pairing is in the range of 30~40mA. The current in communication is 8mA. PIO control can be switched. Has the standard HCI Port (UART or USB) The USB protocol is Full Speed USB1.1, and compliant with 2.0. This module can be used in the SMD. It’s made through RoHS process. The board PIN is half hole size. Has a 2.4GHz digital wireless transceiver. Bases at CSR BC04 Bluetooth technology. Has the function of adaptive frequency hopping. Small (27mm×13mm×2mm). Peripheral circuit is simple. It’s at the Bluetooth class 2 power level. Storage temperature range: -40 ℃ - 85℃, operating temperature range: -25 ℃ - +75℃ Any wave inter Interference: 2.4MHz,the power of emitting: 3 dBm. Bit error rate: 0. Only the signal decays at the transmission link, bit error may be produced. For example, when RS232 or TTL is being processed, some signals may decay.
Low power consumption
Has high-performance wireless transceiver system
Low Cost
Application fields: Bluetooth Car Handsfree Device Bluetooth GPS Bluetooth PCMCIA , USB Dongle
Bluetooth Data Transfer Software CSR www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
3.PINs description
Figure 3 PIN configuration
PIN Name GND
1V8
The PINs at this block diagram is same as the physical one. PIN # Pad type Description 13 21 22
14
VSS
VDD
Ground pot Integrated 1.8V (+) supply with On-chip linear regulator output within 1.7-1.9V
VCC
12
3.3V
AIO0
9
Bi-Directional
AIO1
10
Bi-Directional
PIO0
PIO1 PIO2
23
24 25
Bi-Directional RX EN Bi-Directional TX EN Bi-Directional
Programmable input/output line Programmable input/output line Programmable input/output line, control output for LNA(if fitted) Programmable input/output line, control output for PA(if fitted) Programmable
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
Note
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
input/output line Programmable
PIO3
26
Bi-Directional
PIO4
27
Bi-Directional
PIO5
28
Bi-Directional
PIO6
29
Bi-Directional
PIO7
30
Bi-Directional
PIO8
31
Bi-Directional
PIO9
32
Bi-Directional
PIO10
33
Bi-Directional
PIO11
34
Bi-Directional
RESETB
11
CMOS Input with weak intemal pull-down
UART_RTS
4
CMOS output, tri-stable with weak internal pull-up
UART request to send, active low
UART_CTS
3
CMOS input with weak
UART clear to send, active
internal pull-down
low
UART_RX
2
UART_TX
1
SPI_MOSI
17
SPI_CSB
16
SPI_CLK
19
CMOS input with weak internal pull-down CMOS output, Tri-stable with weak internal pull-up CMOS input with weak internal pull-down CMOS input with weak
input/output line Programmable input/output line Programmable input/output line Programmable input/output line Programmable input/output line Programmable input/output line Programmable input/output line Programmable input/output line Programmable input/output line
UART Data input UART Data output Serial peripheral interface data input Chip select for serial
internal pull-up
peripheral interface, active low
CMOS input with weak
Serial peripheral interface
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
CLK_REQ
CLK_OUT
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
internal pull-down
clock Serial peripheral interface data Output
SPI_MISO
18
CMOS input with weak internal pull-down
USB_-
15
Bi-Directional
USB_+
20
Bi-Directional Default : 1.8V external power
1.8V
14
PCM_CLK
5
Bi-Directional
PCM_OUT
6
CMOS output
PCM_IN
7
CMOS Input
PCM_SYNC
8
Bi-Directional
supply input
1.8V internal power supply.
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
4. The parameters and mode of product
If you want more information, please visit www.wavesen.com.
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
5. Block diagram
Figure 5 Block diagram
6. Debugging device 6.1 Device PC, hardware, 3G,3G Frequency Counter (SP3386), 3.15V DC power supply, Shielding,Bluetooth Test box. 6.2 Software
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
7. Characteristic of test Test Condition 25℃ RH 65%
Min 2.4
Max
Unit
2.4835
MHz
4 8
dBm dB
1.
Carrier Freq.
2. 3.
RF O/P Power Step size of Power control
-6 2
4.
Freq. Offset ( Typical Carrier freq.)
-75
75
KHz
5.
Carrier Freq. drift ( Hopping on, drift rate/50uS )
-20
20
KHz
1 slot packet 3 slot packet
-25 -40
25 -40
KHz KHz
Average Freq. Deviations ( Hopping off, modulation ) 140
175
KHz
6.
( ISM Band )
Typ
Freq. Deviation Ratio of Freq. Deviation 7 . Receive Sensitivity @< 0.1% BER( Bit error rate )
2
115
KHz
0.8 -83
dBm
8. Test diagram 3GHz Ferq. Counter
RS232
CH C
RF
COM 1
O/P LPT1
UUT
Interface circuit
Computer
SPI
Shielding Box
Fig 1. Programming and Freq. Alignment
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
GPIB Bluetooth test set RF I/P
Computer
COM 1
LP1
RS232 RF Port
UUT
SPI
Shielding Box
Fig 2 RF parameter Test Procedure
www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Guangzhou HC Information Technology Co., Ltd.
9.AT command set More information about command set is provided at HC-05 master-salve bluetooth serial module command set.pdf. Please download it from our company website www.wavesen.com. www.wavesen.com Phone: 020-84083341 Fax: 020-84332079 QQ:1043073574 Address: Room 527, No.13, Jiangong Road, Tianhe software park, Tianhe district, Guangzhou Post: 510660 Business consultant:[email protected] Technology consultant: [email protected] Complaint and suggestion: [email protected]
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
HC-03/05 Embedded Bluetooth Serial Communication Module AT command set Last revised: April, 2011 HC-05 embedded Bluetooth serial communication module (can be short for module) has two work modes: order-response work mode and automatic connection work mode. And there are three work roles (Master, Slave and Loopback) at the automatic connection work mode. When the module is at the automatic connection work mode, it will follow the default way set lastly to transmit the data automatically. When the module is at the order-response work mode, user can send the AT command to the module to set the control parameters and sent control order. The work mode of module can be switched by controlling the module PIN (PIO11) input level.
Serial module PINs: 1. PIO8 connects with LED. When the module is power on, LED will flicker. And the flicker style will indicate which work mode is in using since different mode has different flicker time interval. 2. PIO9 connects with LED. It indicates whether the connection is built or not. When the Bluetooth serial is paired, the LED will be turned on. It means the connection is built successfully. 3. PIO11 is the work mode switch. When this PIN port is input high level, the work mode will become order-response work mode. While this PIN port is input low level or suspended in air, the work mode will become automatic connection work mode. 4. The module can be reset if it is re-powered since there is a reset circuit at the module.
===========================Notification ========================== 1. How to get to the AT mode. Way 1: Step 1: Input low level to PIN34. Step 2: Supply power to the module. Step 3: Input high level to the PIN34. Then the module will enter to AT mode. The baud rate is as
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
same as the communication time, such as 9600 etc. Way 2: Step 1: Connect PIN34 to the power supply PIN. Step 2: Supply power to module (the PIN34 is also supplied with high level since the PIN34 is connected with power supply PIN). Then the module will enter to AT module. But at this time, the baud rate is 38400. In this way, user should change the baud rate at the AT mode, if they forget the communication baud rate.
How to get to the communication mode: Step 1: Input low level to PIN34. Step 2: Supply power to the module. Then the module will enter to communication mode. It can be used for pairing.
2. How to set this module be the master role. Step 1: Input high level to PIO11. Step 2: Supply power to the module. And the module will enter to the order-response work mode. Step 3: Set the parameters of the super terminal or the other serial tools (baud rate: 38400, data bit:8, stop bit:1, no parity bit, no Flow Control) Step 4: Sent the characters “AT+ROLE=1\r\n” through serial, then receive the characters “OK\r\n”. Here, “\r\n” is the CRLF. Step 5: Input low level to PIO, and supply power to the module again. Then this module will become master role and search the other module (slave role) automatically to build the connection.
3. Notes. (1) HC-03 and HC-05’s command should end up with “\r\n”. It means when you finish programming, you should add terminator (“ENTER” or “0x0d 0x0a”) to the program. It’s different from HC-04 and HC-06 (They don’t need terminator). (2) The most common commands for HC-03 and HC-05 are: AT+ROLE (set master –slave), AT+CMODE( set address pairing) , AT+PSWD (set password). If you want the master module has the function of remembering slave module, the most
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
simply way is: First, set AT+CMODE=1. Make the master module pair with the slave module. Second, set AT+CMODE=0. Then the master module just can make pair with that specified slave module. (3) When PIN34 keeps high level, all commands can be used. Otherwise, only some of them can be used. ==============================================================
Detailed description of Command (AT command is case- sensitive, should end up with terminator (“enter” or “\r\n”).) 1. Test Command
Response
Parameter
AT
OK
None
Command
Response
Parameter
AT+RESET
OK
None
Response
Parameter
2. Reset
3. Get the soft version Command
+VERSION: <Param> AT+VERSION?
Param: Version number OK
Example : at+version?\r\n +VERSION:2.0-20100601 OK
4. Restore default status Command
Response
Parameter
AT+ORGL
OK
None
The parameter of default status:
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
①.Device type: 0 ②.Inquire code: 0x009e8b33 ③.Module work mode: Slave Mode ④.Connection mode: Connect to the Bluetooth device specified ⑤.Serial parameter: Baud rate: 38400 bits/s; Stop bit: 1 bit; Parity bit: None. ⑥.Passkey: “1234” ⑦.Device name: “H-C-2010-06-01” ……….. 5. Get module Bluetooth address Command
Response
Parameter
+ADDR: <Param> AT+ADDR?
Param: Bluetooth address OK
Bluetooth address will show as this way: NAP: UAP: LAP(Hexadecimal) Example: Module Bluetooth address: 12: 34: 56: ab: cd: ef at+addr?\r\n +ADDR:1234:56:abcdef OK
6. Set/ inquire device’s name Command
Response
AT+NAME=<Param>
OK
Parameter
1. +NAME:<Param> AT+NAME?
OK----success
Param: Bluetooth device name Default: “HC-05”
2. FAIL----failure Example: AT+NAME=HC-05\r\n
---set the module device name: “HC-05”
OK AT+NAME= “HC-05”\r\n
---set the module device name: “HC-05”
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
OK at+name=Beijin\r\n
---set the module device name: “Beijin”
OK at+name= “Beijin”\r\n
---set module device name : “Beijin”
OK at+name?\r\n +NAME: Bei jin OK
7. Get the remote Bluetooth device’s name Command
Response
Parameter Param1:
Remote
Bluetooth
1. +NAME:<Param2> device address AT+RNAME?<Param1>
OK----success Param2:
Remote
Bluetooth
2. FAIL----failure device address Bluetooth address will show as this way: NAP:UAP:LAP (Hexadecimal) Example: Bluetooth device address: 00:02:72: od: 22 : 24; device name: Bluetooth at+rname? 0002,72,od2224\r\n +RNAME:Bluetooth OK
8. Set/ inquire module role Command
Response
Parameter
AT+ROLE=<Param>
OK
Param: 0---- Slave role
+ ROLE:<Param>
1---- Master role
OK
2---- Slave-Loop role
AT+ ROLE? Default: 0
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Role introduction: Slave (slave role)----Passive connection; Slave-Loop----Passive connection, receive the remote Bluetooth master device data and send it back to the master device; Master (master role)----Inquire the near SPP Bluetooth slave device, build connection with it positively, and build up the transparent data transmission between master and slave device.
9. Set/inquire device type Command
Response
AT+CLASS=<Param>
OK
Parameter Param: device type Bluetooth device type is a 32-bit parameter indicates the device type and what type can be
1. + CLASS:<Param> supported. AT+ CLASS?
OK----success Default: 0 2. FAIL----failure More information is provided at the
appendix
1(device
type
introduction). For inquiring the custom Bluetooth device from around Bluetooth devices quickly and effectively, user can set the module to be non-standard Bluetooth device type, such as 0x1f1f (Hexadecimal).
10. Set/ inquire-Inquire access code Command
Response
Parameter
1. OK----success
Param: Inquire access code
2. FAIL----failure
Default: 9e8b33
AT+IAC=<Param> +IAC: <Param>
The more information is provided at the
OK
appendix 2(Inquire access code introduction).
AT+ IAC?
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Access code is set to be GIAC type (General Inquire Access Code:0x9e8b33), and used for seeking ( or being sought by ) all the Bluetooth devices around. For inquiring (or being inquiring by) the custom Bluetooth device from around Bluetooth devices quickly and effectively, user can set the inquire access code to be the other type number (not GIAC nor LIAC), such as 9e8b3f. Example: AT+IAC=9e8b3f\r\n OK AT+IAC?\r\n +IAC: 9e8b3f OK
11. Set/ inquire - Inquire access mode Command
Response
Parameter
AT+INQM=<Param>,
1. OK----success
Param: Inquire access mode
<Param2>,<Param3>
2. FAIL----failure
0----inquiry_mode_standard 1----inquiry_mode_rssi Param2: the maximum of Bluetooth devices response
+INQM:<Param>,<Param2>,
aram3> inquiring time OK The range of limited time: 1~48 ( Corresponding time:1.28s~61.44s) Default: 1, 1, 48
Example: AT+INQM=1,9,48\r\n
----Set Inquire access mode: 1) has RSSI signal intensity indicator, 2) stop inquiring once more than 9 devices response, 3) limited time is 48*l. 28=61.44s.
OK
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
AT+INQM\r\n +INQM:1, 9, 48 OK
12. Set/Inquire- passkey Command
Response
AT+PSWD=<Param>
OK
Parameter Param: passkey
+ PSWD : <Param> Default: “1234”
AT+ PSWD? OK
13.Set/ Inquire- serial parameter Command
Response
AT+UART=<Param>,<
Parameter Param1: baud rate( bits/s)
OK Param2>,<Param3>
The value (Decimal) should be one of the following: 4800 9600 19200 38400 57600 + 115200 UART=<Param>,<Para 23400
AT+ UART? m2>,<Param3>
460800 OK 921600 1382400 Param2:stop bit: 0----1 bit 1----2 bits Param3: parity bit
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
0----None 1----Odd parity 2----Even parity Default: 9600, 0, 0 Example: Set baud rate to be 115200, stop bit to be 2 bits, parity bit to be even parity. AT+UART=115200,1,2,\r\n OK AT+UART? +UART:115200,1,2 OK
14. Set/ Inquire - connection mode Command
Response
AT+CMODE=<Param>
OK
Parameter Param: 0----connect the module to the specified Bluetooth address. (Bluetooth specified
address by
the
can
be
binding
command) + CMODE:<Param> 1----connect the module to any
AT+ CMODE? OK
address (The specifying address has no effect for this mode.) 2----Slave-Loop Default connection mode: 0
15. Set/Inquire - bind Bluetooth address Bluetooth address will show as this way: NAP: UAP:LAP(Hexadecimal)
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Command
Response
AT+BIND=<Param>
OK
Parameter Param----Bluetooth
address
needed to be bind + BIND:<Param> Default address:
AT+ BIND? OK
00:00:00:00:00:00 Bluetooth address will show as this way: NAP:UAP:LAP(Hexadecimal) This command is effective only when the module wants to connect to the specified Bluetooth address. Example: The module is at connection mode which connects to specified Bluetooth address, and the specified address is 12:34:56:ab:cd:ef. Command and the response show as follow: AT+BIND=1234, 56, abcdef\r\n OK AT+BIND?\r\n +BIND:1234:56:abcdef OK
16. Set/Inquire - drive indication of LED and connection status Command
Response
AT+POLAR=<Param1>,
Parameter Param1:The value is
OK <Param1>
0----PI08 outputs low level and turn on LED 1----PI08 outputs high level and turn on + POLAR=<Param1>, LED
AT+ BIND?
<Param1> OK
Param2:The value is 0----PI09 output low level, indicate successful connection 1----PI09
output
high
level,
and
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
indicate successful connection Default: 1, 1 HC-05 Bluetooth module definition: The output of PI08 drives indication of LED work mode; the output of PI09 indicates the connection status. Example: PI08 outputs low level and turn on LED, PI09 outputs high level and indicates successful connection. Command and response show as follow: AT+POLAR=0, 1\r\n OK AT+POLAR?\r\n +POLAR=0, 1 OK
17. Set PIO single port output Command
Response
Parameter Param1: PIO port number(Decimal) Param2: PIO port status
AT+PIO=<Param1>,<Param2>
OK 0----low level 1----high level
HC-05 Bluetooth module provides the user with the ports (PI00~PI07 and PI010) which can extern another input and output ports. Example: 1. PI010 port outputs high level AT+PI0=10, 1\r\n OK 2. PI010 port outpust low level AT+PI0=10, 0\r\n OK
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
18. Set PIO multiple port output Command
Response
AT+MPIO=<Param>
OK
Parameter Param:
Mask combination
of
PIO ports number (Decimal) HC-05 Bluetooth module provides the ports (PI00~PI07 and PI010) which can extern another input and output ports to the user. (1) Mask of PIO port number = (1<<port number) (2) Mask combination of PIO ports number= (PIO port number mask 1|PIO port number mask 2|……) Example : PI02 port number mask=(1<<2) =0x004 PI010 port number mask =(1<<10)=0x400 Mask combination of PI02 and PI010 port number=(0x004|0x400)=0x404
Example: 1. PI010 and PI02 ports output high level AT+MPI0=404\r\n OK
2. PI04 port output high level AT+PI0=004\r\n OK
3. PI010 port output high level AT+PI0=400\r\n OK
4. All ports output low level AT+MPI0=0\r\n
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
OK
19. Inquire PIO port input Command
Response
Parameter Param----PIO port value (16bits) Param[0]=PI00 Param[1]=PI01
+MPIO: <Param> AT+MPIO?
Param[2]=PI02 OK …… Param[10]=PI010 Param[11]=PI011
HC-05 Bluetooth module provides the user with the ports (PI00~PI07 and PI010) which can extern another input and output ports.
20. Set/ Inquire page scan and inquire scan parameter Command
Response
Parameter
OK
Param1:time
interval
+IPSCAN:
inquiring
AT+IPSCAN=<Param1>,
<Param1>,<Param2>,
Param2: duration in inquiring
<Param2>,
<Param3>,<Param4>
Param3: time interval of paging
<Param3>,<Param4>AT+I OK
Param4: duration in paging
PSCAN?
The
above
parameters
decimal. Default:1024,512,1024,512 Example: at+ipscan=1234,500,1200,250\r\n OK at+ipscan? +IPSCAN:1234,500,1200,250
of
are
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
21. Set/ Inquire—SHIFF energy parameter Command
Response
Parameter
AT+SNIFF=<Param1>
Param1: maximum time
,<Param2>,
OK
Param2: minimum time
<Param3>,<Param4>
Param3: test time Param4: limited time
+SNIFF: AT+IPSCAN?
<Param1>,<Param2>,<Par am3>,<Param4>
The above parameters are decimal. Default : 0,0,0,0
22. Set/ Inquire safe and encryption mode Command
Response
Parameter
AT+SENM=<Param
1. OK----success
Param: the value of safe mode:
>,<Param2>,
2. FAIL----failure
0----sec_mode0+off 1----sec_mode1+non_secure 2----sec_mode2_service 3----sec_mode3_link
AT+ SENM?
+SENM:<Param>,<Param
4----sec_mode_unknown
2>,
Param2: the value of encryption mode:
OK
0----hci_enc_mode_off 1----hci_enc_mode_pt_to_pt 2----hci_enc_mode_pt_to_pt_and_bcast Default: 0,0
23. Delete authenticated device in the Bluetooth pair list Command
Response
Parameter
AT+PMSAD=<Param>
OK
Param: Bluetooth device address
Example: Delete the device ( address: 12:34:56:ab:cd:ef ) in the blue pair list
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
at+rmsad=1234,56,abcdef\r\n OK
---- successful deletion
Or at+rmsad=1234,56,abcdef\r\n FAIL
----There is no the Bluetooth device whose address is 12:34:56:ab:cd:ef in the pair list.
24. Delete all authenticated devices in the pair list Command
Response
Parameter
AT+RMAAD
OK
None
Example: Move all devices away from the pair list. at+rmaad\r\n OK
25. Seek the authenticated device in the Bluetooth pair list Command
Response 1. OK----success
Parameter Param: Bluetooth device address
AT+FSAD=<Param> 2. FAIL----failure Example: Seek the authenticated device (address: 12:34:56:ab:cd:ef) in the pair list at+fsad=1234,56,abcdef\r\n OK
----the Bluetooth device whose address is 12:34:56:ab:cd:ef is found.
at+fsad=1234,56,abcde0\r\n FAIL
----There is no the Bluetooth device whose address is 12:34:56:ab:cd:e0 in the pair list.
26. Get the authenticated device count from the pair list Command
Response
Parameter
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
+ADCN:<Param>
Param:
OK
Count
Authenticated
Device
AT+ADCN? Example: at+adcn? +ADCN:0
----There is no authenticated device in the pair list.
OK
27. Get the Bluetooth address of Most Recently Used Authenticated Device Command
Response
AT+MRAD?
Parameter
+ MRAD : <Param>
Param: the Bluetooth address of
OK
Most
Recently
Used
Authenticated Device Example: at+mrad? +MRAD:0:0:0
----There is no device that has been used recently.
OK
28. Get the work status of Bluetooth module Command
Response
Parameter Param: work status of module Return value: “INITIALIZED” “READY”
----initialized status ---- ready status
+ STATE: <Param>
“PAIRABLE”
----pairable status
OK
“PAIRED”
----paired status
“INQUIRING”
----inquiring status
AT+STATE?
“CONNECTING”----connecting status “CONNECTED”----connected status “DISCONNECTED”----disconnected
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
status “NUKNOW”----unknown status Example: at+state? +STATE:INITIALIZED
----initialized status
OK
29. Initialize the SPP profile lib Command
Response
Parameter
1. OK----success AT+INIT
None 2. FAIL----failure
30. Inquire Bluetooth device Command
Response
Parameter Param1: Bluetooth address
+INQ: <Param1>,<Param2>,<Param3>, Param2: device type AT+INQ
…… Param3:
RSSI
signal
OK intensity Example 1: at+init\r\n
---- Initialize the SPP profile lib( can’t repeat initialization)
OK at+iac=9e8b33\r\n
----Inquire Bluetooth device has an access code
OK at+class=0\r\n
----Inquire the Bluetooth device type
at+inqm=1,9,48\r\n
----Inquire mode: 1) has the RSSI signal intensity indication, 2) stop inquiring if more than 9 Bluetooth devices response, 3) limited time in inquiring is 48*1.28=61.44s.
At+inq\r\n
----inquire the Bluetooth device around
+INQ:2:72:D2224,3E0104,FFBC
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
+INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC0 +INQ:1234:56:0,1F1F,FFC1 +INQ:2:72:D2224,3F0104,FFAD +INQ:1234:56:0,1F1F,FFBE +INQ:1234:56:0,1F1F,FFC2 +INQ:1234:56:0,1F1F,FFBE +INQ:2:72:D2224,3F0104,FFBC OK
Example 2: at+iac=9e8b33\r\n ----inquire the Bluetooth device has an access code OK at+class=1f1f\r\n
----inquire the Bluetooth device whose device type is 0x1f1f
OK at+inqm=1,9,48\r\n ----inquire mode: 1) has the RSSI signal intensity indication, 2) stop inquiring if more than 9 Bluetooth devices response, 3) limited time in inquiring is 48*1.28=61.44s At+inq\r\n ----filter and inquire the Bluetooth device around +INQ:1234:56:0,1F1F,FFC2 +INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC2 +INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC1 +INQ:1234:56:0,1F1F,FFC0 +INQ:1234:56:0,1F1F,FFC2 OK
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Example 3: at+iac=9e8b3f\r\n
---- inquire the Bluetooth device whose access code is 0x9e8b3f
OK at+class=1f1f\r\n
----inquire the Bluetooth device whose device type is 0x1f1f
OK at+inqm=1,1,20\r\n
----inquire mode: 1) Has the RSSI signal intensity indication, 2) stop inquiring if more than 1 Bluetooth device response, 3) limited time in inquiring is 20*1.28=25.6s
At+inq\r\n
----filter and inquire the Bluetooth device around
+INQ:1234:56:ABCDEF,1F1F,FFC2 OK
31. Cancel Bluetooth device Command
Response
Parameter
AT+INQC
OK
None
32. Set pair Command
Response
Parameter Param1: Bluetooth address of
1. OK----success
remote device
2. FAIL----failure
Param2:
AT+PAIR=<Param1>,<Param2> limited
time
of
connection (second) Example: Make pair with the remote Bluetooth device( address:12:34:56:ab:cd:ef), the limited time is 20s. At+pai=1234,56,abcdef,20\r\n OK
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
33. Connect device Command
Response
Parameter
1. OK----success
Param: Bluetooth address of
2. FAIL----failure
remote device
AT+LINK=<Param> Example: Connect with the remote Bluetooth device (address: 12:34:56:ab:cd:ef) at+fsad=1234,56,abcdef\r\n
----To check whether the Bluetooth device (address: 12:34:56:ab:cd:ef) is in the pair list or not.
OK at+link=1234,56,abcdef\r\n
----The Bluetooth device (address: 12:34:56:ab:cd:ef) is in the pair list. The connection can be built directly without inquiring.
OK
34. Disconnection Command
Response
Parameter
1.+DISC:SUCCESS----successful Disconnection OK 2.+DISC:LINK_LOSS----lose the connection OK 3.+DISC:NO_SLC----No SLC connection AT+DISC
None OK 4、+DISC:TIMEOUT----disconnection timeout OK 5、+DISC:ERROR----disconnection error OK
35. Enter to energy mode: Command
Response
Parameter
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
AT+ENSNIFF=<Param>
OK
Param: Bluetooth address of device
36. Exit energy mode Command AT+EXSNIFF=<Param>
Response OK
Parameter Param: Bluetooth address of device
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI Appendix 1:Introduction of AT command error code The form of error ---- ERROR:(error_code) error_code(Hexadecimal)
Note
0
AT command error
1
Default result
2
PSKEY write error
3
Too long length of device name (more than 32 bytes).
4
No device name
5
Bluetooth address: NAP is too long.
6
Bluetooth address: UAP is too long.
7
Bluetooth address: LAP is too long.
8
No PIO number’s mask
9
No PIO number
A
No Bluetooth devices.
B
Too length of devices
C
No inquire access code
D
Too long length of inquire access code
E
Invalid inquire access code
F
The length of passkey is 0.
10
Too long length of passkey (more than 16 bytes)
11
Invalid module role
12
Invalid baud rate
13
Invalid stop bit
14
Invalid parity bit
15
Authentication device is not at the pair list.
16
SPP lib hasn’t been initialized.
17
SPP lib has been repeated initialization.
18
Invalid inquire mode
19
Too long inquire time
1A
No Bluetooth address
1B
Invalid safe mode
1C
Invalid encryption mode
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Appendix 2: The introduction of devices The Class of Device/Service(CoD) is a 32 bits number that of 3 field specifies the service supported by the device. Another field specifies the minor device class, which describes the device type in more detail The Class of Device /Service (CoD) field has a variable format. The format is indicated using the ’within the CoD .The length of the Format Type field is variable and ends with two bits different from’11’.The version field starts at the least significant bit of the CoD and may extend upwards. In the ’format#1’ of the CoD (format Type field =00), 11 bits are assigned as a bit –mask (multiple bits can be set) each bit corresponding to a high level generic category of service class. Currently 7 categories are defined. These are primarily of a’ public service’ nature. The remaining 11 bits are used for indicating device type category and other device-specific characteristics. Any reserved but otherwise unassigned bits, such as in the Major Service Class field, should be to 0.
Figure 1.2: The Class of Device/Service field (format type). Please note the krder in which the octets are sent on the air and stored in memory. Bit number 0 is sent first on the air . 1. MAJOR SERVICE CLASSES Bit no Major Service Class 13 Limited Discoverable Mode [Ref #1] 14 (reserved) 15 (reserved) 16 Positioning(Location identification) 17 Networking (LAN, Ad hoc, … ) 18 Rendering (Printing ,Speaker,…) 19 Capturing (Scanner, Microphone,…) 20 0bject Transfer (v-Inbox, v-Folder,…) 21 Audio (Speaker, Microphone, Headset service,…)
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
22 Telephony (Cordless telephony, Modem, Headset service,…) 23 Information (WEB-server, WAP- server,…) TABLE 1.2:MAJOR SERVICE CLASSES [Ref #1 As defined in See Generic Access Profile, Bluetooth SIG]
2. MAJOR DEVICE CLASSES The Major Class segment is the highest level of granularity for defining a Bluetooth Device. The main function of a device is used for determining the major Class grouping. There are 32 different possible major classes. The assignment of this Major Class field is defined in Table1.3. 1 2 1 1 1 0 9 8 Major Device Class 0 0 0 0 0 Miscel laneous [Ref #2] 0 0 0 0 1 Computer (desktop, notebook, PDA, organizers,…) 0 0 0 1 0 Phone (cellular ,cordless ,payphone, modem,…) 0 0 0 1 1 LAN/Network Access point 0 0 1 0 0 Audio/Video (headset, speaker, stereo, video display, vcr …) 0 0 1 0 1 Periphereal (mouse, joystick, keyboards.…) 0 0 1 1 0 Imaging (printing, scanner, camera, display,…) 1 1 1 1 1 Uncategorized, specific device code not specified XXXX
All other values reserved
TABLE 1.3: MAJOE DEVICE CLASSES [Ref #2:Used where a more specific Major Device Class is not suited (but only as specified as in this document) .Devices that do not have a major class assigned can use the all-1 code until’ classified’]
3. THE MINOR DEVICE CLASS FIELD The’ Minor Device Class field’ (bits 7 to 2 in the CoD ), are to be interpreted only in the context of the Major Device Class (but interpreted of the Service Class field). Thus the meaning of the bits may change, depending on the value of the ’ Major Device Class field’. When the Minor Device Class field indicates a device class ,then the
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
primary decvice class should be reported, e. g . a cellular phone that can work as a cordless handset should
4. MINOR DEVICE CLASS FIELD–COMPUTER MAJOR CLASS Minor Device Class 7 6 5 4 3 2 bit no of CoD 0 0 0 0 0 0 Uncategorized, code for device not assigned 0 0 0 0 0 1 Desktop workstation 0 0 0 0 1 0 Server-class computer 0 0 0 0 1 1 Laptop 0 0 0 1 0 0 Handheld PC/PDA(clam shell) 0 0 0 1 0 1 Palm sized PC/PDA 0 0 0 1 1 0 Wearable computer (Watch sized) X X X X X X All other values reserved TABLE 1.4: SUB DEVICE CLASS FIELD FOR THE’ COMPUTER ’MAJOR CLASS
5. MINOR DEVICE CLASS FIELD – PHONE MAJOR CLASS Minor Device Class 7 6 5 4 3 2 bit no of CoD 0 0 0 0 0 0 Uncategorized, code for device not assigned 000001 Cellular 0 0 0 0 1 0 Cordless 0 0 0 0 1 1 Smart phone 0 0 0 1 0 0 Wired modem or voice gateway 0 0 0 1 0 1 Common ISDN Access 0 0 0 1 1 0 Sim Card Reader X X X X X X All other values reserved TABLE1.5: SUB DEVICE CLASSES FOR THE’PHONE’ MAJOR CLASS
6. MINOR DEVICE CLASS FIELD –LAN/NETWORK ACCESS POINE MAJOR
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
CLASS Minor Device Class 7 6 5 bit no of CoD 0 0 0 Fully available 0 0 1 1 – 17% utilized 0 1 0 1 7 - 33% utilized 0 1 1 3 3 – 50% utilized 1 0 0 5 0 – 67% utilized 1 0 1 6 7 – 83% utilized 1 1 0 8 3 – 99% utilized 1 1 1 No service available [REF #3] XXX All other values reserved TABLE1.6: THE LAN/NETWORK ACCESS POINE LOAD FACTOR FIELD [Ref
#3:“Device is fully utilized and cannot accept additional connections at this time,
please retry later”] The exact loading formula is not standardized. It is up to each LAN/Network Access Point implementation to determine what internal conditions to report as a utilization of communication requirement is that the box .As a recommendation, a client that locates multiple LAN/Network Access Points should attempt to connect to the one reporting the lowest load. Minor Device Class 4 3 2 bit no of CoD 0 0 0 Uncategorized (use this value if no other apply ) XXX All other values reserved TABLE1.7:RESERVED SUB-FIELD FOR THE LAN/NETWORK ACCESS POINE
7. MINOR DEVICE CLASS FIELD – AUDIO/VIDEO MAJOR CLASS Minor Device Class 7 6 5 4 3 2 bit no of CoD 0 0 0 0 0 0 Uncategorized, code not assigned
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
0 0 0 0 0 1 Device conforms to the Headset profile 000010 Hands-free 0 0 0 0 1 1 (Reserved ) 0 0 0 1 0 0 Microphone 0 0 0 1 0 1 Loudspeaker 0 0 0 1 1 0 Headphones 0 0 0 1 1 1 Portable Audio 0 0 1 0 0 0 Car audio 0 0 1 0 0 1 Set-top box 0 0 1 0 1 0 HiFi Audio Device 001011 VCR 0 0 1 1 0 1 Camcorder 0 0 1 1 1 0 Video Monitor 0 0 1 1 1 1 Video Display and Loudspeaker 0 1 0 0 0 0 Video Conferencing 0 1 0 0 0 1 (Reserved) 0 1 0 0 1 0 Gaming/Toy [Ref #4] X X X X X X All other values reserved [Ret #4: Only to be used with a Gaming/Toy device that makes audio/video capabilities available via Bluetooth] TABLE 1.8: SUB DEVICES FOR THE ’AUDIO/VIOEO’MAJOR CLASS
8. MINOR DEVICE CLASS FIELD – PERIPHERAL MAJOR CLASS Minor Device Class 7 6 bit no of CoD 0 1 Keyboard 1 0 Pointing device 1 1 Combo keyboard /pointing device X X X All other values reserved TABLE1.9: THE PERIPHERAL MAJOR CLASS KEYBOARD/POINTING DEVICE
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
FIELD Bits 6 and 7 independently specify mouse, keyboard or combo mouse/keyboard devices. These may be combined with the lower bits in a multifunctional device. Minor Device Class 5 4 3 2 bit no of CoD 0 0 0 0 Uncategorized device 0 0 0 1 Gamepd 0 0 1 1 Remote control 0 1 0 0 Sensing device 0 1 0 1 Digitizer tablet X X X X All other values reserved TABLE1.10: RESERVED SUB-FIELD FOR THE DEVICE TYPE
9. MINOR DEVICE CLASS FIELD – IMAGING MAJOR CLASS Minor Device Class 7 6 5 4 bit no of CoD X X X 1 Display X X 1 X Camera X 1 X X Scanner 1 X X X Printer X X X X All other values reserved TABLE 1.11: THE TMAGING MAJOR CLASS BITS 7 TO 7 Bits 4 to 7 independently specify bi splay, camera, scanner or printer. These may be combined in a multifunctional device. Minor Device Class 3 2 bit no of CoD 0 0 Uncategorized, default X X All other values reserved TABLE 1. 12: THE IMAGING MAJOR CLASS BITS 2 AND 3 Bits 2 and 3 are reserved
PLAGIAT PLAGIATMERUPAKAN MERUPAKANTINDAKAN TINDAKANTIDAK TIDAKTERPUJI TERPUJI
Appendix 3: (The Inquiry Access Codes) The General-and Device-Specific Inquiry Access Codes (DIACs) The Inquiry Access Code is the first level of filtering when finding Bluetooth devices. The main purpose of defining multiple IACs is to limit the number of responses that are received when scanning devices within range. 0. 0x9E8B33 ---- General/Unlimited Inquiry Access Code(GIAC) 1. 0x9E8B00 ---- Limited Dedicated Inquiry Access Code(LIAC) 2. 0x9E8B01 ~ 0x9E8B32 RESERVED FOR FUTURE USE 3. 0x9E8B34 ~ 0x9E8B3F RESERVED FOR FUTURE USE
The Limited Inquiry Access Code(LIAC)is only intended to be used for limited time periods in scenarios where both sides have been explicitly caused to enter this state, usually by user action. For further explanation of the use of the LIAC, please refer to the Generic Access Profile. In contrast it is allowed to be continuously scanning for the General Inquiry Access Code (GIAC)and respond whenever inquired.