# How can i sent API frame to XBee (S2) Router using VisualStudio C#

**URL:** <https://forums.digi.com/t/how-can-i-sent-api-frame-to-xbee-s2-router-using-visualstudio-c/13209>\
**Category:** XBee & XBee Gateway\
**Tags:** c, sent-api-via-xbee, api, xbee\
**Created:** [June 25, 2014, 11:01pm UTC](https://forums.digi.com/t/how-can-i-sent-api-frame-to-xbee-s2-router-using-visualstudio-c/13209 "2014-06-25T23:01:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AwStranger](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@AwStranger](https://forums.digi.com/u/AwStranger)\
**Post date:** [June 25, 2014, 11:01pm UTC](https://forums.digi.com/t/how-can-i-sent-api-frame-to-xbee-s2-router-using-visualstudio-c/13209/1 "2014-06-25T23:01:00Z")

</div>

How do i sent API frames to XBee Router Via C# program. I have been trying to find samples or tutorial online to get me started but to no avail.

InitializeComponent();  
SerialPort port = new SerialPort(“COM4”, 9600, Parity.None, 8, StopBits.One);  
port.DataReceived += new SerialDataReceivedEventHandler(SerialPort\_DataReceived);  
port.Open();

```
        port.DtrEnable = true;
        port.RtsEnable = true;
        byte[] buffer = new byte[1024];

```

This code is all ive found but it is only to open my coordinator Xbee port( I think) How do i sent API frame and get a reading from it?  
Help greatly appreciated! Thank you

---

<div class="post-metadata">

**Author:** ![engereggae](https://avatars.discourse-cdn.com/v4/letter/e/6a8cbe/32.png) [@engereggae](https://forums.digi.com/u/engereggae)\
**Post date:** [July 1, 2014, 8:19am UTC](https://forums.digi.com/t/how-can-i-sent-api-frame-to-xbee-s2-router-using-visualstudio-c/13209/2 "2014-07-01T08:19:44Z")

</div>

this is the mode that I send comands API for other xbee in C#

private void button11iron\_Click(object sender, EventArgs e)  
{  
try  
{

```
            byte[] bytesToSend5 = new byte[] { 0x7E, 0x00, 0x11, 0x17, 0x01, 0x00, 0x13, 0xA2, 0x00, 0x40, 0x49, 0xA0, 0xEB, 0xFF, 0xFE, 0x02, 0x49, 0x52, 0x01, 0xF4, 0x8F};
            Comport.Write(bytesToSend5, 0, bytesToSend5.Length);

            textBox2.Text = "TX: 7E 00 11 17 01 00 13 A2 00 40 49 A0 EB FF FE 02 49 52 01 F4 8F";
            textBox2.ForeColor = Color.Green;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Erro no Comando !", MessageBoxButtons.OK, MessageBoxIcon.Stop);
        }
    }

```

change your adress zigbee. int this case i send the comand IR  
that sends values ​​of samples every 500 milliseconds

---

<div class="post-metadata">

**Author:** ![gcharles81](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@gcharles81](https://forums.digi.com/u/gcharles81)\
**Post date:** [March 1, 2018, 3:58pm UTC](https://forums.digi.com/t/how-can-i-sent-api-frame-to-xbee-s2-router-using-visualstudio-c/13209/3 "2018-03-01T15:58:37Z")

</div>

hello can you explain more the exact location of the 16 bit address in your byte array , my xbee receiver has address of 02

where do i key in this - thanks in advance
