Home/Support/Support Forum/Visual Basic Application - For anybody that wants to send data to Xbee
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Visual Basic Application - For anybody that wants to send data to Xbee

0 votes
I've been trying to communcate in API mode to my Xbee from a PC for a while now. My biggest problem has been the actual sending of Hex data, for some reason Visual Basic only likes to send string data. I finally got it to work and here's what I used:


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Dim TestData() As Byte = {&HFE, &H11, &H11, &HFF}

'Dim TestData(3) As Byte

'TestData(0) = &HFE

'TestData(1) = &H11

'TestData(2) = &H11

'TestData(3) = &HFF

SerialPort.Write(TestData, 0, 4)

End Sub
asked Jan 22, 2008 in 3rd Party Python and API development in other Languages by HarrisnHJones New to the Community (31 points)

Please log in or register to answer this question.

4 Answers

0 votes
Thanks for posting that! I'm sure that will be very useful to others in the VB world so its nice of you to post your solution here :)
answered Jan 22, 2008 by anonymous
0 votes
how can i enter into command mode in visual basic? hope you will reply thanks
answered Jun 13, 2009 by dioxden08 New to the Community (42 points)
0 votes

am trying to send data to my xbee through vb express 2008 too, well am trying to switch on and off an led from an xbee cnnected via usb cable to my pc and an idle xbee which is powered by a 3.3V battery and has only an led soldered through the pin 20 via a resistor to pin 1 of the xbee
but the codes am sending is like ;
SerialPort1.Write(ATD0=4) ' switch on the LED
SerialPort1.Write(ATD0=5) ' switch off the LED

the thing is that its not working at all.

am guessing that maybe both xbees have been wrongly configured in the x-ctu software.

what should be the correct configuration?

by the way am using xbee s1 modules

answered Jun 6, 2012 by bn4al New to the Community (7 points)
0 votes
I have written several .NET applications for XBee, including VB.NET. When sending API data using the serial port control, I usually place the bytes inside of an array and then send them out, much like HarrisnHJones.

Here's the array I created to use the transmit request API frame (0x10) to send an ASCII "1":

Dim ar1 As Byte() = {&H7E, &H0, &HF, &H10, &H1, &H0, &H0, &H0, &H0, &H0, &H0, &HFF, &HFF, &HFF, &HFE, &H0, &H0, &H31, &HC2}
sp.Write(ar1, 0, 19)
answered Aug 16, 2012 by nathanf Community Contributor (80 points)