Xbee development kit + Visual Basic

Hello everybody, I don’t know if this is the right place to be asking my questions, but I hope someone can guide me in the right direction.

Equipment:

Xbee type: XB24

Xbee pro type: XBP24

Development kit board with USB to my laptop computer

Another development kit board with a loopback.

The Xbee pro is sending to the normal Xbee.

I’m trying to make a program in visual basic to split the received data into understandable segments. I have managed to get some kind of reading into the computer, but I am having huge problems understanding the data.

I am a newbie at VB-programming, so I could be way of target in my code. That is why I’m posting here, I don’t want to spend hours programming only to find out that I need to do everything over again because I’m doing it all wrong.

What I want the code to do, is collect data from the Xbee. I have found this website:

http://www.digi.com/support/kbase/kbase … jsp?kb=188

I’m not sure that the information about the datastream here is correct, but it is a good start.

What I’m trying to do is collect all that information, and split it up.

Here is my go at splitting it up:

Imports System
Imports System.IO
Imports System.IO.Ports

Public Class Form1
    Dim bytes(13) As Byte
    Dim offset As Integer = 0
    Dim count As Integer = 14
    Dim resulttype As String

    Dim WithEvents xbee As New SerialPort

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        xbee.BaudRate = 9600
        xbee.PortName = "com4"
        xbee.Parity = Parity.Even
        xbee.StopBits = 1
        xbee.DataBits = 8

    End Sub

    
    Private Sub timer1_tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Received.Clear()
        Try
            xbee.Open()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Dim Data
        xbee.Read(bytes, offset, count)
        'Data = Data & " "

        'Received.AppendText(Data)
        For i As Integer = 0 To 13
            resulttype = invenum(i)
            Data = bytes(i)
            Received.AppendText(resulttype & ": |  " & Data & vbNewLine)
        Next

        Try
            xbee.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
        If Timer1.Enabled = False Then
            Timer1.Enabled = True
        Else
            Timer1.Enabled = False
        End If
    End Sub

    Public Function invenum(ByVal i As Integer)
        Select (i)
            Case 0 : Return "Start delimiter"
            Case 1 : Return "Length byte 1"
            Case 2 : Return "length byte 2"
            Case 3 : Return "API identifier byte"
            Case 4 : Return "Source address byte 1"
            Case 5 : Return "Source address byte 2"
            Case 6 : Return "RSSI value byte"
            Case 7 : Return "Option byte"
            Case 8 : Return "Sample quantity byte"
            Case 9 : Return "Channel indicator 1"
            Case 10 : Return "Channel indicator 2"
            Case 11 : Return "Sample data 1"
            Case 12 : Return "Sample data 2"
            Case 13 : Return "Checksum"
        End Select
    End Function
End Class

There are several versions of the XBee modules/firmware so some questions first:

What are the full part numbers of the XBee modules (on the label)?

What is the firmware versions in the XBee modules?

Did you download the proper document on the XBee firmware version you have?

When we know this then we can help with the format of the data.

Also check the thread titled “Better XBee documentation” for links.

I’m going to have to come back to you on that. It seems I can’t post anymore and I have to join some group that I can’t find.

I’m fluent in VB6 but not VB.net.

Here’s a link to the XBee series 1 manual. If you have series 2, then go download that one instead.

http://ftp1.digi.com/support/documentat … 0982_B.pdf

Using series 1, which it sounds like you are:

If you use the 802.15.4 mode firmware, rather than DigiMesh (or in series 2, ZigBee from Ember), then…

Read the manual (above). You’ll see that the 802.15.4 firmware acts like a Hayes Modem with +++ to break, then AT commands per the manual.

and/or

You can configure the firmware to use the API mode, where all data to and from the Xbee is wrapped in a packet header with a checksum suffix.

So these are two basic modes. Start with the simple AT command mode and transparent serial port extension. Then play with digital I/O port replication. Then if need arises, go to the API mode.

I find that using the XBees configured to not use coordinators and PANs, but rather just peer to peer communications, is easiest. It’s kind of like the ad-hoc mode in 802.11/WiFi, and like talking on an Ethernet using MAC addresses without TCP/IP. Anyone can talk directly to anyone, in peer to peer, no coordinator mode. Assuming the two are in RF range.

Hello again.

It turns out that the reading that I got was correct, and that I had problems with the settings on the XBee. I have now fixed it, and the data I’m receiving is good.

Thank you for your feedback guys.