I am using the CerbuinoBee with an XBee, but in a Gadgeteer project, how do I access the XBee?
try this (untested)
using System;
using System.IO.Ports;
using System.Text;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
namespace GadgeteerApp4
{
public partial class Program
{
private GT.Timer _timer;
static SerialPort xBeePort = new SerialPort("COM1", 57600, Parity.None, 8, StopBits.One);
void ProgramStarted()
{
xBeePort.Open();
_timer = new GT.Timer(1000);
_timer.Tick += new GT.Timer.TickEventHandler(_timer_Tick);
}
void _timer_Tick(GT.Timer timer)
{
byte[] buffer = Encoding.UTF8.GetBytes(DateTime.Now.ToString() + "\r\n");
xBeePort.Write(buffer, 0, buffer.Length);
xBeePort.Flush();
}
}
}
The XBee socket on the Cerbuino is COM1, I believe. Since there is no module, per se, you have to write the code to instantiate the serial port.
[edit] @ Justin beat me to a sample… note the default XBee baud rate is 9600, not 57600.
1 Like
Thanks, I guess I was thinking too hard. I am using the same XBee I was using with a Panda II on COM1, so it looks like I can pretty much just copy and paste the code. I figured it would be different with the gadgeteer stuff but using the module didn’t look right.