xbee for teensy 3.0?

Status
Not open for further replies.

linuxgeek

Well-known member
Does the xbee module work with Teensy 3.0 yet?

And if not, will it work in the future? Or will the hardware of the xbee module need to be updated to work?

I'm asking cause I was gonna order a couple of SD card readers for teensy 3.0, and was going to order some xbee's as well, as long as it'll be possible to use it in the future.
 
I have not yet tested this. Everything in this message "should work", but comes with the caveat that I have not personally verified it.

Configure the XBee adaptor for Teensy 2.0. That routes the signals to pins 7 and 8. Do not solder the 15K resistor (brown, green, orange, gold). This page has the details:

http://www.pjrc.com/teensy/td_libs_XBee.html

On Teensy 3.0, pins 7 and 8 are Serial3. The latest 0.4 version of XBee supports using any port. You can download it here:

http://code.google.com/p/xbee-arduino/

You'll need to use Serial3.begin(9600), and then xbee.setSerial(Serial3), so the XBee library will use that port.

As you can see on the libraries page, I've started testing and documenting which libraries work with Teensy 3.0.

http://www.pjrc.com/teensy/td_libs.html

Many of the untested libraries actually have quite a bit of preliminary work. XBee is a good example, where I sent Andrew that patch in January. I actually sent Andrew an email a couple days ago, about any feedback on version 0.4. No answer yet. Either way, I'll update the page soon... but will probably wait a couple more days for a reply. There's plenty of other libraries to do. Luckily, I already have test hardware built for most of them from the days of testing Teensy 2.0.

Hopefully this message will help, before I get around to updating the XBee page.
 
I have not yet tested this. Everything in this message "should work", but comes with the caveat that I have not personally verified it.

Configure the XBee adaptor for Teensy 2.0. That routes the signals to pins 7 and 8. Do not solder the 15K resistor (brown, green, orange, gold). This page has the details:

http://www.pjrc.com/teensy/td_libs_XBee.html

On Teensy 3.0, pins 7 and 8 are Serial3. The latest 0.4 version of XBee supports using any port. You can download it here:

http://code.google.com/p/xbee-arduino/

You'll need to use Serial3.begin(9600), and then xbee.setSerial(Serial3), so the XBee library will use that port.

As you can see on the libraries page, I've started testing and documenting which libraries work with Teensy 3.0.

http://www.pjrc.com/teensy/td_libs.html

Many of the untested libraries actually have quite a bit of preliminary work. XBee is a good example, where I sent Andrew that patch in January. I actually sent Andrew an email a couple days ago, about any feedback on version 0.4. No answer yet. Either way, I'll update the page soon... but will probably wait a couple more days for a reply. There's plenty of other libraries to do. Luckily, I already have test hardware built for most of them from the days of testing Teensy 2.0.

Hopefully this message will help, before I get around to updating the XBee page.

Is there a schematic for the XBee board? I've seen this hand-written schematic... but it's not clear about wiring, pin #, etc.
http://www.pjrc.com/teensy/td_libs_XBee.html

Trying to understand how I get it to run on 5V from USB on the Teensy3.
And I read that if I omit the resistors, the 3.3V serial injterface to the Teensy3 will work.

I need a Teensy3 I/O bit to go to the RESET pin on the XBee - as the XBees do sometimes hang and the XBee's watchdog doesn't reset it. Needs a strong pullup as in the past, the XBee PRO's RF gets onto the reset pin and causes spurious resets. Cure was a small value bypass right near the XBee's reset pin.
 
I think you should look into this seriously and try to make it work on Teensy 3.0 if possible. Are you already into it?
 
I recently updated the XBee Adaptor page with a "Teensy 3.0 Usage" section. Scroll down, since it's currently at the end.

Eventually, I'll change this to a nicer description with photos. Several other updates are a much higher priority, but hopefully that text-only description will help?
 
for those not experienced with XBees (Digi International), be sure to know the difference between Series 1 (Freescale, non-ZigBee) and Series 2 (Ember, ZigBee-only).
Most apps in the student/hobby world should/must use Series 1.
 
and even 50.000+ medical simulators use the series 1 (Gaumard HAL), but anyway... a bit ignorant question, but an important: the Teensy 3 has more pins than the XBee adapter...

Would be convenient to also state anything about that issue at the bottom section of the XBee adapter page.
 
Hey folks - I read what Paul wrote and it's just not clear enough to get up and running. I have some questions.
1. You'll need XBee 0.4. This newest version lets you configure which serial port it uses.
Where is this? I looked through the settings and can't find it. I have an xbee 802.15.4
Where do you find out if you have this xbee? I just bought these so they are the newest ones. I'm using the Series 1 units.

"If using the USBtoSerial program to test, you'll need to edit the code to use Serial3."
Ok that makes sense but do you find that setting in xctu?

Thanks for the info!
 
Sorry, I normally have rolled my own code for XBees.

But have you tried looking through the examples that ship with Teensyduino?

It appears like it installs the library XBee

If you look at some of the example like: Serial1_tx.pde you will see in the Setup code:
Code:
void setup() {
  pinMode(statusLed, OUTPUT);
  pinMode(errorLed, OUTPUT);
  Serial.begin(9600);
  xbee.setSerial(Serial);
}
So you probably simply need to change the Serial to something like Serial3 or the like .

But again I have not tried it.
 
Ok so you are saying I don't need to set up the xbee to send on serial3 in xctu, just the teensy?
I was just using the example code that ships with the teensyduino software and changing the Serial to Serial3 on line 10
#define HWSERIAL Serial3

and it compiled just fine, I just can't get XTCU to find the radio.

I might be horribly confused. It's possible.

When I used the sparkfun shield I just used the sparkfun explorer to read all my radios then set them up then I put them out into the world on teensys and left one on my machine as a receiver using the explorer.

I saw on Paul's post that you could connect directly to the xbee in xtcu using these shields. I am super sure this is newbie shield user foolishness.

Thanks.
/* USB to Serial - Teensy becomes a USB to Serial converter
http://dorkbotpdx.org/blog/paul/teensy_as_benito_at_57600_baud

You must select Serial from the "Tools > USB Type" menu

This example code is in the public domain.
*/

// set this to the hardware serial port you wish to use
#define HWSERIAL Serial3

unsigned long baud = 19200;
const int reset_pin = 4;
const int led_pin = 13; // 13 = Teensy 3.X & LC
// 11 = Teensy 2.0
// 6 = Teensy++ 2.0
void setup()
{
pinMode(led_pin, OUTPUT);
digitalWrite(led_pin, LOW);
digitalWrite(reset_pin, HIGH);
pinMode(reset_pin, OUTPUT);
Serial.begin(baud); // USB, communication to PC or Mac
HWSERIAL.begin(baud); // communication to hardware serial
}

long led_on_time=0;
byte buffer[80];
unsigned char prev_dtr = 0;

void loop()
{
unsigned char dtr;
int rd, wr, n;

// check if any data has arrived on the USB virtual serial port
rd = Serial.available();
if (rd > 0) {
// check if the hardware serial port is ready to transmit
wr = HWSERIAL.availableForWrite();
if (wr > 0) {
// compute how much data to move, the smallest
// of rd, wr and the buffer size
if (rd > wr) rd = wr;
if (rd > 80) rd = 80;
// read data from the USB port
n = Serial.readBytes((char *)buffer, rd);
// write it to the hardware serial port
HWSERIAL.write(buffer, n);
// turn on the LED to indicate activity
digitalWrite(led_pin, HIGH);
led_on_time = millis();
}
}

// check if any data has arrived on the hardware serial port
rd = HWSERIAL.available();
if (rd > 0) {
// check if the USB virtual serial port is ready to transmit
wr = Serial.availableForWrite();
if (wr > 0) {
// compute how much data to move, the smallest
// of rd, wr and the buffer size
if (rd > wr) rd = wr;
if (rd > 80) rd = 80;
// read data from the hardware serial port
n = HWSERIAL.readBytes((char *)buffer, rd);
// write it to the USB port
Serial.write(buffer, n);
// turn on the LED to indicate activity
digitalWrite(led_pin, HIGH);
led_on_time = millis();
}
}

// check if the USB virtual serial port has raised DTR
dtr = Serial.dtr();
if (dtr && !prev_dtr) {
digitalWrite(reset_pin, LOW);
delayMicroseconds(250);
digitalWrite(reset_pin, HIGH);
}
prev_dtr = dtr;

// if the LED has been left on without more activity, turn it off
if (millis() - led_on_time > 3) {
digitalWrite(led_pin, LOW);
}

// check if the USB virtual serial wants a new baud rate
if (Serial.baud() != baud) {
baud = Serial.baud();
if (baud == 57600) {
// This ugly hack is necessary for talking
// to the arduino bootloader, which actually
// communicates at 58824 baud (+2.1% error).
// Teensyduino will configure the UART for
// the closest baud rate, which is 57143
// baud (-0.8% error). Serial communication
// can tolerate about 2.5% error, so the
// combined error is too large. Simply
// setting the baud rate to the same as
// arduino's actual baud rate works.
HWSERIAL.begin(58824);
} else {
HWSERIAL.begin(baud);
}
}
}
 
Last edited:
omg - I had the shield plugged in the wrong way around. I am shame cat right now.

SHAME CAT -

It might be useful to put a picture of it plugged in on the store page with the info.

Lol.
Face, I'd like to introduce you to palm...

best,
phoenix
 
Status
Not open for further replies.
Back
Top