If I understand correctly you’re trying to control a LED on a remote XBee by sending commands to the local XBee that’s directly connected to your computer.
As a suggestion, start with a simpler case. Connect a LED to an output pin of the local XBee and check that you can control that. The AT commands will be “ATD0=4” and “ATD0=5” if you have the LED connected to DIO line 0.
I’ve never used visual basic so I don’t know what SerialPort1.Write does, but if it does what it looks like then you’re sending the 5-character string ‘20, 5’. The XBee will have no idea what to do with that.
To control a LED on a remote XBee you’ll need to learn about API packets.
The Digi product manual has all the details you need. Optionally, you might also want to look at my cookbook (see pinned posts at the top of the forum).
First, I assume your LED has 1 pin tied to 3.3vdc, and the other tied to pin 20? Plus some form of step-down resister?
The XBee can only ‘power’ the LED by pulling low (the ATD0=5) command.
By default writing ‘ATD0=5’ will cause that string to be sent to the remote, who will dump it out the serial port. If you use the ‘+++’ first, then you can toggle the pin 20/D0 on the local XBee, but not the remote.
As John mentioned, API frames will be required with the Remote AT Command Request (frame type 0x17).
even i thought the same but it’s actually working. i dont know how but its working while using the ‘+++’ and wont if i dont.
well i have to enter in command by typing the ‘+++’, wait for the ‘OK’, then type ‘ATD04’ and ATCN to exit the command for the LED to light up.
to switch off the LED i need to re-enter the command ‘+++’ , ’ ATD05’ and ‘ATCN’
here’s the code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim data(2) As Byte
'System.Threading.Thread.Sleep(1900)
SerialPort1.Write("+++")
System.Threading.Thread.Sleep(2000)
SerialPort1.Write(vbCrLf)
SerialPort1.Write("ATD04" & vbCrLf)
System.Threading.Thread.Sleep(900)
SerialPort1.Write("ATCN" & vbCrLf)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim data(2) As Byte
'System.Threading.Thread.Sleep(1900)
SerialPort1.Write("+++")
System.Threading.Thread.Sleep(2000)
SerialPort1.Write(vbCrLf)
SerialPort1.Write("ATD05" & vbCrLf)
System.Threading.Thread.Sleep(900)
SerialPort1.Write("ATCN" & vbCrLf)
End Sub
by the way i need to monitor voltages across a pin of the xbee which will be sent to the coordinator.
i believe that i should use the DI05 pins for ADC, what’s the maximun input voltage should i use. what the command i should type in the coordinator xbee to read those voltages?