Berawal dari project yg dikasih buat mengatasi kebakaran
hutan riau yang semakin tinggi, maka saya pun membuat sebuah alat yang
tujuannya membantu petugas hutan riau untuk memantau kondisi hutan.
Akhirnya setelah berbagai riset dilakukan, mulai dari hutan
universitas indonesia (UI) sampai dengan pondok halimun gunung gede sukabumi.
Prinsip kerja dari alat ini ialah komunikasi satu arah,
dimana xbee router sebagai pengirim dan xbee coordinat sebagai penerima.
Xbee router
Xbee cordinat
Untuk menampilkan data yang diterima oleh xbee coordinat
selain menggunakan LCD, saya menggunakan microsof visual basic net 2010 dengan
tampilan sebagai berikut:
Dan berikut kode vb:
Public Class Form1
Dim
pisah() As String
Dim
i As Integer =
0
Dim
j As Integer =
0
Dim
kata As String
Delegate
Sub SetTextCallback(ByVal [text] As String)
Public
Function GetWordCount(ByVal
Text As String)
As Long
'Definisikan
sebuah tanda hubung pada setiap akhir
'baris
yang merupakan bagian dari seluruh kata,
'jadi
kombinasikan bersama.
Text =
Trim(Replace(Text, "-" &
vbNewLine, ""))
'Ganti
baris baru dengan sebuah space tunggal
Text =
Trim(Replace(Text, vbNewLine, " "))
'Ganti
spasi yang lebih dari satu (jika ada)
'menjadi
spasi tunggal
Do
While Text Like
"*
*"
Text = Replace(Text,
"
", " ")
Loop
'Pisahkan
string dan kembalikan kata yang dihitung
GetWordCount = 1 +
UBound(Split(Text, ","))
End
Function
Sub
bukaPort()
SerialPort1.PortName = "COM12"
SerialPort1.BaudRate =
9600
SerialPort1.Parity =
IO.Ports.Parity.None
SerialPort1.StopBits =
IO.Ports.StopBits.One
SerialPort1.DataBits = 8
'Open our serial port
SerialPort1.Open()
End
Sub
Sub
tutupPort()
SerialPort1.Close()
End
Sub
Private
Sub Form1_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
bukaPort()
Label6.Text = Chr(176)
& "C"
End
Sub
Private
Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting()) 'Automatically
called every time a data is received at the serialPort
End
Sub
Private
Sub ReceivedText(ByVal
[text] As String)
Dim
tanah As String
Dim
lokasisuara As String
'compares
the ID of the creating Thread to the ID of the calling Thread
If
Me.rtbReceived.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.rtbReceived.Text
&= [text]
TextBox1.Text =
GetWordCount(rtbReceived.Text) - 1
pisah =
Split(rtbReceived.Text, ",")
i =
Len(rtbReceived.Text)
If j > 0 Then
j = i - j
End If
If Val(TextBox1.Text) > 3 Then
rtbReceived.Clear()
'Me.rtbReceived.Text &= [text]
'If rtbReceived.Text <> "a" Then
rtbReceived.Text
&= "a" & [text]
'End If
'TextBox2.Text = pisah(0)
kata = pisah(0)
TextBox3.Text =
pisah(1)
TextBox4.Text =
pisah(2)
tanah = pisah(3)
TextBox5.Text =
Trim(Replace(tanah, "a", ""))
If kata = "a"
Or kata = "aa"
Then
TextBox2.Text = "XBEE001"
End If
If Val(TextBox4.Text) > 32 And Val(TextBox4.Text) < 36 Then
Timer1.Enabled = True
Label7.Visible = False
Label8.Visible = True
Label12.Visible = False
'memainkan audio
ElseIf Val(TextBox4.Text) >= 45 Then
'My.Computer.Audio.Play(My.Resources.watch_alarm,
AudioPlayMode.WaitToComplete)
If Val(TextBox3.Text) > 70 And Val(TextBox3.Text) < 120 Then
Label10.Visible = True
Label7.Visible = False
Label8.Visible = False
Label12.Visible = False
End If
If Val(TextBox3.Text) > 120 Then
Label12.Visible = True
Label10.Visible = False
Label7.Visible = False
Label8.Visible = False
End If
Else
Timer1.Enabled = False
Label10.Visible = False
Label7.Visible = True
Label8.Visible = False
Label12.Visible = False
End If
'TextBox6.Text = Len(kata)
End
If
'i
= i - j
j = Len(rtbReceived.Text)
End
If
End
Sub
Private
Sub Timer1_Tick(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Timer1.Tick
Label11.Text =
Label11.Text + 1
End
Sub
End Class
Dan demo nya dapat dilihat pada video berikut:



No comments:
Post a Comment