Translate

Membuat Alat Monitoring Gas Menggunakan AVR dan VB.NET / visual studio 2010 - MS. ACCESS 2007 VIA BLUETOOTH

Membuat Alat Monitoring Gas Menggunakan AVR dan VB.NET / visual studio 2010 - MS. ACCESS 2007 VIA BLUETOOTH


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang digunakan untuk monitoring gas menggunakan komputer dengan interface visual studio, media transfer data yang digunakan adalah bluetooth dengan baudrate 9600. alat ini menggunakan mikrokontroller ATMega16 dan bluetooth HC-05. jadi alat ini akan mengirimkan data gas yang masih berbentuk nilai ADC satu detik sekali, kemudian di interface visual studio akan menampilkan nilai gas, jam dan tanggal, setelah menampilkan maka akan disimpan secara otomatis di database microsoft access 2007. untuk lebih jelasnya berikut program dan skemanya.

Software pairing bluetooth HC-05 ( Bluesoleil )
Download Link

Tutorial Pairing Bluetooth
https://www.youtube.com/watch?v=FVIUOoE9GNo



a. Minimum System




b. Sensor Gas 




c. Bluetooth HC-05



d. Program Bascom AVR

$regfile = "m16def.dat"
$crystal = 12000000
$baud = 9600

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Dim Dataadc As Word

Start Adc

Do

Dataadc = Getadc(0)

Print Dataadc

Wait 1
Loop



e. Program VB.NET



Public Class Form1
    Dim WithEvents SerialPort As New IO.Ports.SerialPort
    Dim con As New ADODB.Connection
    Dim rs As New ADODB.Recordset

    Sub connectDB()
        con.Open("provider=microsoft.jet.oledb.4.0;data source=Database1.mdb")
        rs.Open("Select * From tblgas", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database1DataSet.tblgas' table. You can move, or remove it, as needed.
        Me.TblgasTableAdapter.Fill(Me.Database1DataSet.tblgas)
        ConnectSerial()
    End Sub

    Private Sub ConnectSerial()
        Try
            SerialPort.BaudRate = 9600
            SerialPort.PortName = "COM5" 'notice how the ports are named? they HAVE to have COM in front of the number
            SerialPort.Open()
        Catch
            SerialPort.Close()
        End Try
    End Sub

    Delegate Sub myMethodDelegate(ByVal [text] As String)
    Dim myD1 As New myMethodDelegate(AddressOf myShowStringMethod)

    Sub myShowStringMethod(ByVal myString As String)
        'display text to our textbox called SerialText
        SerialText.AppendText(myString)
        gastxt.Text = SerialText.Text

    End Sub

    Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
        Dim str As String = SerialPort.ReadExisting()
        Invoke(myD1, str)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Call connectDB()
        rs.AddNew()
        rs(0).Value = gastxt.Text
        rs(1).Value = TextBox4.Text
        rs(2).Value = TextBox5.Text
        rs.Update()
        con.Close()

        SerialText.Text = " "
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        TextBox5.Text = Format(Now, "dd / MMM / yyyy")
        TextBox4.Text = Format(Now, "HH:mm:ss")

    End Sub

End Class




f. Tampilan Database





g. VIDEO TUTORIAL

    Link = https://www.youtube.com/watch?v=qN3GyEa-efU




h. VIDEO HASILNYA







No comments:

Post a Comment