Send Data on X-CTU from Arduino+XBee to Microsoft SQL

Hi, I am currently working on developing an intelligent car park sysem for my final year project using Wireless Sensor Networks (WSN).

On one end I have the Arduino+XBee Shield+XBee powered by a 9V adapter. 6 ultrasonic sensors are connected to Arduino, and sensor data will be sent wirelessly to a computer using an XBee connected via USB on the computer.

What I would like to do now is to have the data displayed on the X-CTU on the receiver end of the XBee (the one connected to the computer) to be sent to the Microsoft SQL database. However, I have searched all over the internet and could not find any relevant answers.

Thank you in advance for your replies!

The XBee will appear as a virtual serial port on the system. You can write an application in a language of your choice that opens up the serial port and reads the incoming data. Your application should receive the same data you were previously seeing in the X-CTU terminal. It can then parse the data and store it however it wants in the SQL Server.

Chris

May I know in what software can I write on in order to read data from X-CTU? Can I use Processing? Once I have the database ready I will have to interface it on ASP.Net to form a webpage.

I’m very much clueless on how to get started as I do not have a strong IT base. I’m currently doing my degree in E&E Engineering, hence I really need all the help that I can get in this.

Hello winniec89,

As cpopp stated, you don’t need to read from X-CTU, you should read from the Serial Port where your X-Stick is. Once you achieve this in your program, you will read binary data in the same format you see in X-CTU.

The data output format will depend on how you configure your X-Stick (API or AT, refer to Reference Manual on how to parse them). I suppose that your application will receive data from more than one device, so AT will not be enough, but you can start with that as it is easier to parse (again, refer to the Ref Manual).

Hope it was helpful. Best regards,

Sebastián.-

P/S: The programming language makes no difference, as long as you can open the serial port. This may help you getting started if you prefer Processing, but you can do it as well in C/C++, Python, Java, etc.

Thank you very much for the replies.

I have done programming successfully on Processing to read data from the Serial Port where my XBee is connected, and it is now able to read the data as how it would using the X-CTU.

Now that I have that done, I still do not understand how I could parse the XBee in order for it to be able to store the data on MS SQL. I tried searching the internet but could not find information that I could comprehend.

Well done, that’s half of the work!

If there is no XBee library for Processing you will have to build your own parser. If you only want to receive frames from other XBees, implementing ZigBee Receive Packet frames (Frame Type 0x90) should be enough for start, consult Reference Manual to know its structure so you can guess the data offset.

Regards,

Sebastián

There is XBee library for Processing, but how can I parse the data so that it can be saved on MS SQL? Do I program it on Processing, or do I configure XBee? How do I implement ZigBee Receive Packet frames? I’m still trying to understand how to parse.

Hello Winniec89,

As Sebastian said, once you have the binary data you will have to parse it byte a byte. To know how to do it you will have to refer to the XBee Reference Manual. As an example:

Packet Header:
All XBee API packets start with byte 0x7E, this is the header of the frame. You will know where is the start of the packet by identifying this byte inside your binary data array.

Packet Lenght:
Following the packet header, next 2 bytes will be the payload length, so you will have to read that ammount of bytes to get the complete payload. For example if you read 0x00 0x0a means that the payload size is 10 bytes and you will have to read the following 10 bytes to get the payload.

Payload:
This data depends on the type of packet that is received. Inside the payload, first byte determines the packet type. In your case, you will have to wait for Frame type 0x90 (which is the ZigBee Receive Packet type). Next 8 bytes determine the 64 bit address of the XBee device that sent the packet. Next 2 bytes are the 16 bit address of the XBee device that sent the packet. Next byte is a bitfield with the receive options flags. And now, the rest of the bytes until payload is complete will be the data you really want (the data that is transmitted from the other XBee device).

Checksum.
To finish, the last byte after the payload is the packet checksum.

There are a lot more of details to take in consideration, but as an start you can follow that pattern.

Kind regards.

Hello my dear…
May I know in what software can I write on in order to read data from X-CTU? Can I use Processing…?

Nice surprise about this shorter form. Can you tell us what it is you are talking/writing about?
Has any info. about this shorter form been posted before (and i just missed it)?

Nice surprise about this shorter form. Can you tell us what it is you are talking/writing about?
Has any info. about this shorter form been posted before (and i just missed it)?

Hi,

Are you just asking about the format of the API frames? You can find more information about it on page 98 of the XBee ZB Manual: http://ftp1.digi.com/support/documentation/90000976_M.pdf (The latest version can be found by grabbing the product manual from this page: http://www.digi.com/products/wireless-wired-e...odule/xbee-zb-module#docs)

If you are using another product like DigiMesh you would want to pull up the appropriate product manual.

Chris