kali ini saya akan menulis tutorial membuat smart home sederhana yang kerjanya semua peralatan elektronik yang ada di rumah dikendalikan oleh hp android kita, dengan menggunakan Bluetooth dan ARDUINO,
seri bluetooth yang saya pakai adalah HC-05 dan arduino Mega 2560 komunikasi anatar arduino dan bluetooth menggunakan komunikasi Serial antara TX dan RX, RX dan TX,
pertama hubungkan terlebih dahulu bluetooth dan arduino nya, sebagai berikut
BT TX ===> RX1 Arduino Mega 2560 BT RX ===> TX1 Arduino Mega 2560 BT GND ===> GND Arduino Mega 2560 BT 5V ===> 5V Arduino Mega 2560
selanjutnya saya mengilustrasikan peralatan yang ada dirumah dengan LED yang berbeda warna, nanti jika ingin dipasang dirumah, maka gantilah LED tersebut dengan RELAY, prinsip kerja RELAY sangat sederhana dia seperti saklar ON/OFF, terdapat tiga connector pada relay yaitu NO, COM, dan NC
NO merupakan Normally Open yang apabila relay tidak diaktifkan maka konektor NO tidak terhubung dengan konektor COM dan ketika relay aktif NO dan COM akan terhubung, sedangkan NC merupakan Normally Close yang apabila relay tidak diaktifkan maka NC dan COM terhubung, dan apabila relay aktif maka NC dan COM terbuka,
jika sudah mengerti tentang relay mari kita lanjutkan tutorialnya,, hubungkan Arduino, Bluetooth dan empat LED Seperti pada gambar yang ada dibawah, karena relay yang saya punya aktif LOW,
(maksudnya drelay akan aktif bila kita kasih tegangan 0V atau LOW), maka saya rangkai led nya untuk atif LOW juga.
selanjutnya ketikan program dibawah ini dan uplode pada Arduino mega 2560
// deklarasi variable dulu
String suara;
char c;
// define pin nya
#define kipas 4
#define lampu 5
#define tv 6
#define garasi 7
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // komunikasi serial baud rate nya 9600
Serial1.begin(9600); // komunikasi serial1 baud rate nya 9600
// identifikasi pin nya sebagai OUTPUT
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//membuat program ketersediaan serial.
while(Serial1.available()){
delay(10);
c = Serial1.read();
if(c == ‘#’){break;}
suara+=c; // artinya suara = suara+c
}
if(suara.length()>0){
Serial.println(suara);
if(suara == “*semua nyala”){
nyalakan_semua();
}
else if (suara == “*semua mati”){
matikan_semua();
}
else if (suara == “*lampu nyala”){
digitalWrite(lampu, 0);
}
else if (suara == “*tv nyala”){
digitalWrite(tv, 0);
}
else if (suara == “*kipas nyala”){
digitalWrite(kipas, 0);
}
else if (suara == “*garasi buka”){
digitalWrite(garasi, 0);
}
suara=””;
}
}
void nyalakan_semua(){
digitalWrite(4, 0);
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(7, 0);
}
void matikan_semua(){
digitalWrite(4, 1);
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(7, 1);
}
jika sudah berhasil di uplode silahkan download aplikasi android nya di playstor,
selamat berkreasi, selamat belajar,, semoga bermanfaat, jika ada saran dan kritikan silahkan tinggalkan dikomentar, dan juga kalo ingin bertanya komentar dibawah :v
We use technologies like cookies to store and/or access device information. We do this to improve browsing experience and to show (non-) personalized ads. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.