Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang digunakan untuk melacak posisi benda dimana ia berada sekarang dengan menggunakan perantara sms, jadi pada alat telah terpasang sebuah GPS EM411 untuk mengetahui letak koordinatnya kemudian pemilik bisa monitoring posisinya dengan cara melakukan sms dengan text "Monitor" maka akan dibalas dengan koordinat pada alat tersebut, pada saat yang bersamaan Relay ON. kemudian jika dibalas dengan pesan text "Ok" maka Relay akan OFF. alat ini juga terdapat bluetooth yang mana untuk melakukan ON / OFF Relay langsung menggunakan aplikasi android jadi tidak perlu menggunakan sms pun bisa. untuk lebih jelasnya berikut adalah program dan skemanya.
LINK LIBRARY GPS
a. Arduino Mega
b. Minimum System ATMega8535
c. LCD 16x2
d. GPS EM411
e. Modul sms SIM800L
f. Bluetooth HC-05
g. Modul Relay
h. Program Android
i. Program Arduino IDE
#include <TinyGPS++.h>
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "Wire.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(A5, A4, A3, A2, A1, A0);
static const uint32_t GPSBaud = 4800;
// The TinyGPS++ object
TinyGPSPlus gps;
#include "sms.h"
SMSGSM sms;
char string[160];
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
char strsms[5];
char latstr[20];
char lonstr[20];
char latlonstr[20];
void setup()
{
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
Serial1.begin(GPSBaud);
if (gsm.begin(2400)) {
started=true;
} else {
}
if(started) {
// if (sms.SendSMS("085726496643", "ALAT READY ok"));
}
lcd.begin(16, 2);
lcd.clear();
lcd.noCursor();
}
void loop()
{
while (Serial1.available() > 0)
if (gps.encode(Serial1.read()))
displayInfo();
if (millis() > 5000 && gps.charsProcessed() < 10)
{
while(true);
}
}
void displayInfo()
{
if (gps.location.isValid())
{
lcd.setCursor(0, 0);
lcd.print("LAT= ");
lcd.print(gps.location.lat(), 6);
lcd.setCursor(0, 1);
lcd.print("LNG= ");
lcd.print(gps.location.lng(), 6);
dtostrf(gps.location.lat(),10,6,latstr);
dtostrf(gps.location.lng(),10,6,lonstr);
sprintf(string,"LAT= %s, LONG= %s", latstr, lonstr);
if(gsm.begin(9600)){
started=true;
}
int pos=0;
if(started){
pos=sms.IsSMSPresent(SMS_ALL);
if(pos){
sms.GetSMS(pos,n,smsbuffer,100);
if(!strcmp(smsbuffer,"monitor")){
digitalWrite(13,HIGH);
sms.SendSMS(n,string);
}
if(!strcmp(smsbuffer,"Monitor")){
digitalWrite(13,HIGH);
sms.SendSMS(n,string);
}
if(!strcmp(smsbuffer,"Ok")){
digitalWrite(13,LOW);
}
if(!strcmp(smsbuffer,"ok")){
digitalWrite(13,LOW);
}
delsms();
}
}
delay(100);
}
else
{
}
}
void delsms()
{
for (int i=0; i<10; i++)
{
int pos=sms.IsSMSPresent(SMS_ALL);
if (pos!=0)
{
if (sms.DeleteSMS(pos)==1){}else{}
}
}
}
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "Wire.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(A5, A4, A3, A2, A1, A0);
static const uint32_t GPSBaud = 4800;
// The TinyGPS++ object
TinyGPSPlus gps;
#include "sms.h"
SMSGSM sms;
char string[160];
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
char strsms[5];
char latstr[20];
char lonstr[20];
char latlonstr[20];
void setup()
{
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
Serial1.begin(GPSBaud);
if (gsm.begin(2400)) {
started=true;
} else {
}
if(started) {
// if (sms.SendSMS("085726496643", "ALAT READY ok"));
}
lcd.begin(16, 2);
lcd.clear();
lcd.noCursor();
}
void loop()
{
while (Serial1.available() > 0)
if (gps.encode(Serial1.read()))
displayInfo();
if (millis() > 5000 && gps.charsProcessed() < 10)
{
while(true);
}
}
void displayInfo()
{
if (gps.location.isValid())
{
lcd.setCursor(0, 0);
lcd.print("LAT= ");
lcd.print(gps.location.lat(), 6);
lcd.setCursor(0, 1);
lcd.print("LNG= ");
lcd.print(gps.location.lng(), 6);
dtostrf(gps.location.lat(),10,6,latstr);
dtostrf(gps.location.lng(),10,6,lonstr);
sprintf(string,"LAT= %s, LONG= %s", latstr, lonstr);
if(gsm.begin(9600)){
started=true;
}
int pos=0;
if(started){
pos=sms.IsSMSPresent(SMS_ALL);
if(pos){
sms.GetSMS(pos,n,smsbuffer,100);
if(!strcmp(smsbuffer,"monitor")){
digitalWrite(13,HIGH);
sms.SendSMS(n,string);
}
if(!strcmp(smsbuffer,"Monitor")){
digitalWrite(13,HIGH);
sms.SendSMS(n,string);
}
if(!strcmp(smsbuffer,"Ok")){
digitalWrite(13,LOW);
}
if(!strcmp(smsbuffer,"ok")){
digitalWrite(13,LOW);
}
delsms();
}
}
delay(100);
}
else
{
}
}
void delsms()
{
for (int i=0; i<10; i++)
{
int pos=sms.IsSMSPresent(SMS_ALL);
if (pos!=0)
{
if (sms.DeleteSMS(pos)==1){}else{}
}
}
}
j. Program Bascom AVR
$regfile = "m8535.dat"
$crystal = 11059200
$baud = 9600
On Urxc Getchar
Ddrd.7 = 1
Ddrd.6 = 0
Ddrb.1 = 1
Ddrb.2 = 1
Dim Perintah As String * 10
Dim X As Integer
Dim Y As Integer
Portb.1 = 1
Portb.2 = 1
Wait 1
X = 0
Y = 0
Enable Interrupts
Enable Urxc
Do
If Pind.6 = 0 Then
Y = 0
End If
If Pind.6 = 1 Then
Y = 1
End If
If X = 0 And Y = 0 Then
Portd.7 = 0
Portb.1 = 0
Portb.2 = 1
End If
If X = 0 And Y = 1 Then
Portd.7 = 1
Portb.1 = 1
Portb.2 = 0
End If
If X = 1 And Y = 0 Then
Portd.7 = 1
Portb.1 = 1
Portb.2 = 0
End If
If X = 1 And Y = 1 Then
Portd.7 = 1
Portb.1 = 1
Portb.2 = 0
End If
Loop
Getchar:
Perintah = Inkey()
Select Case Perintah
Case "a" :
'relay off
X = 0
Wait 1
Case "b" :
'relay on
X = 1
Wait 1
End Select
Return
End
$crystal = 11059200
$baud = 9600
On Urxc Getchar
Ddrd.7 = 1
Ddrd.6 = 0
Ddrb.1 = 1
Ddrb.2 = 1
Dim Perintah As String * 10
Dim X As Integer
Dim Y As Integer
Portb.1 = 1
Portb.2 = 1
Wait 1
X = 0
Y = 0
Enable Interrupts
Enable Urxc
Do
If Pind.6 = 0 Then
Y = 0
End If
If Pind.6 = 1 Then
Y = 1
End If
If X = 0 And Y = 0 Then
Portd.7 = 0
Portb.1 = 0
Portb.2 = 1
End If
If X = 0 And Y = 1 Then
Portd.7 = 1
Portb.1 = 1
Portb.2 = 0
End If
If X = 1 And Y = 0 Then
Portd.7 = 1
Portb.1 = 1
Portb.2 = 0
End If
If X = 1 And Y = 1 Then
Portd.7 = 1
Portb.1 = 1
Portb.2 = 0
End If
Loop
Getchar:
Perintah = Inkey()
Select Case Perintah
Case "a" :
'relay off
X = 0
Wait 1
Case "b" :
'relay on
X = 1
Wait 1
End Select
Return
End
k. VIDEO HASILNYA
No comments:
Post a Comment