Getting Xbee working with Gadgeteer?

I wonder if someone can help me…

I ve switched from Arduino to Gadgeteer and i m trying to get the Xbee module working… I ve tried everything to no avail…

With arduino it was really simple - connecting the tx of the arduino to the rx of the Xbee would sent any serial data from arduino via serial - instant wireless!!!
(After configuring the Xbee’s using a command line serial program to configure them - the ATDH ATID etc.)

With Gadgeteer I can open a serial port using the gadgeteer serial module… and send serial data from my Gadgeteer project to the computer. Why wont the same code send data via serial when the Gadgeteer serial module is replaced with an xbee?
All i want to do is wire replacement to make the project wireless…

Here’s a sample of the code i m using:


public partial class Program
{
GT.Interfaces.Serial mySerial;

void ProgramStarted()
{
// settings for the serial port

mySerial = new GT.Interfaces.Serial(GT.Socket.GetSocket(8, false, null, null), 9600, GT.Interfaces Serial.SerialParity.None, GT.Interfaces.Serial    

//open the serial port

mySerial.Open();

//test the port is open

mySerial.Writeline("HelloWorld!");


Could anyone give me any suggestions for a work around to get the xbee to just relay the serial data?

Thanks in advance,

Ben

The community has been working on an XBee driver for NETMF and Gadgeteer Check this link:
http://tinyclr.com/forum/21/5553/

Thanks Joe - Thats really good information.

I ve taken a good look at the post you recommended and there’s some amazing work taking place on there. However, what the developers seem to want to create is really complicated…

All i want is the hardware to send the data via serial.

Instead of a complicated driver could it be possible to get the hardware to output serial regardless of where it’s going?

In a similar way to the way Arduino does this? The Arduino doesn’t need to know it’s connected to an Xbee, it sends the data via tx regardless as long as it has been instructed to do this in the software that ts been programmed with.

It’s really frustrating because it seems to be a really simple problem?

A solution to this would be really useful for musicians developing their own Digital Musical Instruments for Live Electronic Performance. I’m trying to set up a selection of code snippets that would enable musicians to get up and running really quickly with the Gadgeteer platform. So solving this would benefit a lot of other people.

Thanks for taking the time to look at this,

Ben

Thanks in advance.

Ben

If you need a simple connection then all you need is to send data and it should be received on the other end. We already expose the serial port.

Xbee experts, am I missing something here?

Thanks Gus. Could you elaborate and explain in more detail how i go about that please?

  • Sorry i m really new to coding so need as much support as possible.

Would the way to do this be different from my current approach outlined in the code in my earlier post about this topic?

Any sample code for how to do this would be amazing!
I’m using the Fez Spider mainboard.

Thanks in advance,

Ben

@ benfreeth - Welcome to FEZ land. Check out http://xbee.codeplex.com for a work in progress on providing XBee drivers (Joe’s link will point you to the same place). The code is still in test, with no official release, but should give you a good idea of where we’re headed.

In the meantime, are you using a GHI XBee module, or did you wire the XBee to a U or K type socket yourself? If it is the former, you should not have to instantiate the serial port. It is done automatically for you when you connect modules in the designer.

If it is directly wired (without a module), the code you provided should not be doing any “work” in the ProgramStarted method. Take a look at this blog post for a better idea of how the Dispatcher works, http://blogs.msdn.com/b/net_gadgeteer/archive/2011/12/19/why-not-while-true.aspx.

I hope this is enough info to get you going. If not, you’ll find lots of folks willing to help here.

Thanks for the warm welcome ransomhall - i appreciate that :slight_smile: Nice to meet you!

Can i offer my services as a tester to try to test the code for the
http://xbee.codeplex.com
i can give feedback on my experience?

I ve just looked at the Xbee module and it’s actually a Systech xbee module (i’m using a whole range of modules from Newcastle University and most are GHI or Seeedstudio).

I was thinking of trying to wire the Xbee itself without the Systech Module directly to a U or K socket using the GHI Extender 1.2 module.
A while ago there was an issue with the Serial Module and to make it work you used this code in the progam.cs file:


GT.Interfaces.Serial serial = new GT.Interfaces.Serial(GT.Socket.GetSocket(11, false, null, null), 9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 8, GT.Interfaces.Serial.HardwareFlowControl.NotRequired, null);

The work around was to not add the module in the designer.
The code set the module up on socket 11 (a U socket).

I m going to take a look at the blog post about the Dispatcher you recommended.

I ll let you know how i get on.

Cheers,

Ben

That posts great -

http://blogs.msdn.com/b/net_gadgeteer/archive/2011/12/19/why-not-while-true.aspx

it’s really useful to get the structure of the code right so that the timer actually ticks and the program doesn’t get stuck an infinite while loop. I ve learned quite a bit from that

So add a new timer in the Program part of the code. Then add a new event handler for the timer and start it in the void ProgramStarted() part of the code. So that the code doesn’t block the dispatcher and stop it from running.

So if i m directly wiring my xbee with the GHI extender 1.2 module i should open the serial port when the timer ticks, so under this part of the code?:

void ledBlinkTimer_Tick(GT.Timer timer)

So it would look something like:

void ledBlinkTimer_Tick(GT.Timer timer)

//configure the serial port

GT.Interfaces.Serial serial = new GT.Interfaces.Serial(GT.Socket.GetSocket(11, false, null, null), 9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 8, GT.Interfaces.Serial.HardwareFlowControl.NotRequired, null);
 
//open the serial port
 
mySerial.Open();
 
//test the port is open
 
mySerial.Writeline("HelloWorld!");

I ll try that and see if it works.

Thanks for this.

Ben

Definitely! The more testing we all do, the better the first release will be. Please use the codeplex site to report any issues or start discussions specific to that project. You can also use the thread Joe pointed out.

Each manufacturer provides their own driver code for each module. The source for which is available at http://gadgeteer.codeplex.com . Before I started working on the XBee driver project I had no trouble issuing XBee AT commands with the GHI module. There should be an installer for the Systech driver code, as well. Make sure you have the latest version of everything. If you grab the source code previously mentioned, you can at least debug through it to help pinpoint the problem.

In general, this is a very new platform, and a lot of the module code is a work in progress. I can’t speak to other manufacturers (I’m one of the groupies here :)), but GHI is extremely responsive in resolving any bugs we come across in their code.

Ok ransomhall I ll go on the Codeplex site and ask to get involved!!

i ll get the latest source code too and have a go at debugging through it.

Ah actually i ve just found this:

http://mftoolkit.codeplex.com/

i ve downloaded it but i m not sure what to do with it…

It looks like it contains code to enable xbee functionality.

Its got a folder called Release 10…which contains 2 more folders: Debug and Release… these have more folders… one is called Xbee and contains Xbee.dll and Xbee.pdb

Could these files be drivers for the Xbee? - I m excited because this could be the solution!!!

Have you ever used these or come across them before?
Where should i put these files so MSVS can use them with Gadgeteer?

Thanks in advance again!!!

[quote]If you need a simple connection then all you need is to send data and it should be received on the other end. We already expose the serial port.

Xbee experts, am I missing something here?[/quote]

Gus is right. XBee modules with factory settings work in transparent mode. I treat it as a demo but many people use it as a main feature. Quote from manual:

[quote]By default, XBee/XBee-PRO RF Modules operate in Transparent Mode. When operating in this
mode, the modules act as a serial line replacement - all UART data received through the DI pin is
queued up for RF transmission. When RF data is received, the data is sent out the DO pin.[/quote]

If you got it working on Arduino you shouldn’t have any problems when using Spider. This is just plain UART send/receive game. Even though you are using Systech module you can use GHI module in the designer as it’s current implementation is only exposing serial line that you need.

If you are able to connect both XBee to a PC (using this for example http://www.sparkfun.com/products/8687) here is a demo showing you how to test the transparent mode. At the beginning the video show also how to restore your module to factory settings.

mftoolkit is a versatile .NET MF library pack and XBee library is one of many there. If all you want (as you say you do) is to send/receive data between two XBee you don’t need it. If you want to do more I suggest using the driver Gus and ransomhall mentioned rather than mftoolkit.

There he goes being humble again.

@ benfreeth FYI - Gralin is the guy who wrote the code Joe and I mentioned!