Teensy 3.2 & Xbee Series 1 & Sparkfun Adapter - serial communication

Status
Not open for further replies.
Hi,

I want to send accelerometer data from one xbee connected to a teensy with sparkfun adapter, to another xbee connected to a macbook with a sparkfun explorer.
I didin't wired the sensor yet, firstly I just want to test communication between two xbees but it doesn't work.

Here are the units:
IMG_5753.jpgIMG_5754.jpg

XTCU configuration of the agent(teensy)
teensy adapter.jpg
XTCU configuration of the host(explorer)
explorer.jpg

I have read these two tutorials, one is the sparkfun's tutorial:
https://learn.sparkfun.com/tutorials/teensy-xbee-adapter-hookup-guide
I have tried the codes both uart and suart given in this tutorial.
Both units connected to computer through USB.
The code:
Code:
    #include <AltSoftSerial.h>
//Serial test using the software uart on pins 20/21.
//Connect an XBee and Teensy 3.1 to the adapter board
//Connect an XBee to a serial terminal of your choice (USB dongle for example)
//
//Characters sent out the XBee terminal go:
// Onto the airwaves -> into S-UART RX -> out the serial monitor
//
//Characters sent out the serial monitor go:
// Out the S-UART TX pin -> onto the airwaves -> out the SBee serial terminal
//
//Be sure to select S-UART on the adapter board's switch for HW serial

AltSoftSerial altSerial;

void setup() {
  // initialize serial communication at 9600 bits per second:
  //Begin serial monitor port
  Serial.begin(9600);
  //Begin SW UART serial
  altSerial.begin(9600);

}

// the loop routine runs over and over again forever:
void loop() {
  // Take data received from the serial monitor and pass it to the HW UART
  if(Serial.available())
  {
    altSerial.print(Serial.read(), BYTE);
  }

  // Take data received from the HW UART and pass it to the serial monitor
  if(altSerial.available())
  {
    Serial.print(altSerial.read(), BYTE);
  }

  //Wait to reduce serial load
  delay(5);
}
When this code is running, I type something to the teensy console, "DOUT" led blinks very weak and nothing is being delivered to xtcu console.(vice versa the same)

Another sparkfun tutorial:
https://learn.sparkfun.com/tutorials/exploring-xbees-and-xctu
In this tutorial, 2 xbees connected to computer with 2 explorers so 2 xbees showing up in XTCU software.
But it doesn't solved my problem because I have 1 explorer 1 adapter.


With this setup, how can I transmit accelerometer data from a standalone unit to computer?
before coming there, how can I simply send/receive serial messages?

any help, suggestion?
 
How is the switch setup? Looks like there is a switch to use pins 20 and 21 with software serial.
Else uses pins 0 and 1... Which I would recommend.

In that case remove altSerial and replace all references to Serial1
 
I tried both switch modes. There is another code in the tutorial for communication through UART, thats not working either.
Which is :
Code:
    //Serial test using the hardware uart on pins 0/1 (UART1).
//Connect an XBee and Teensy 3.1 to the adapter board
//Connect an XBee to a serial terminal of your choice (USB dongle for example)
//
//Characters sent out the XBee terminal go:
// Onto the airwaves -> into UART1 RX -> out the serial monitor
//
//Characters sent out the serial monitor go:
// Out the UART1 TX pin -> onto the airwaves -> out the SBee serial terminal
//
//Be sure to select UART1 on the adapter board's switch for HW serial

void setup()
{
  //Begin serial monitor port
  Serial.begin(9600);
  //Begin HW serial
  Serial1.begin(9600);

}

void loop()
{
  // Take data received from the serial monitor and pass it to the HW UART
  if(Serial.available())
  {
    Serial1.print(Serial.read(), BYTE);
  }

  // Take data received from the HW UART and pass it to the serial monitor
  if(Serial1.available())
  {
    Serial.print(Serial1.read(), BYTE);
  }

  //Wait to reduce serial load
  delay(5);
}
 
When you try running it, does the RSSI leds on the XBee adapters light up? Again this would show if the two xbees are talking.

From your earlier posting it looks like the IDS are setup for MY and DL to work.

What on the PC are you using to talk to the USB Xbee adapter? I assume it is configured for 9600 baud?

Also long shot, double check your solder joints, I did not see anything obvious with your picture of the top. But did not see the bottom of the Teens 3.1 xbee adapter.

If you run the above program and you type something in the Arduino Serial monitor window and hit enter, does the TX led on the Teensy adapter flash at all? This would tell you it is actually trying to send something (the IO pin is working).

Likewise if you try on the PC side does the TX led flash when you try to send something?

In both of the above cases is the RX led flashing at all when the TX of the other one is saying it is sending something? This would say that the two xbees are talking.
 
Firstly I am using a macbook pro.
Using XTCU to talk with USB Xbee Adapter.
Baud rates are the same on radios: 9600:
Screen Shot 2018-02-07 at 16.27.13.png
Here is the bottom side of the adapter:
IMG-5755.jpg

When I type in Ardunio Serial monitor window, DOUT pin is flashing very poorly, I can only see the flashing when I turn the lights off.
When I type in XTCU Serial Console, there is no flashing on the adapter leds.

On the other hand, I tried to add the second xbee as a remote radio in XTCU Software.
During the search, I see these messages in the console:
Screen Shot 2018-02-07 at 16.22.34.jpg

But at the end, it says "No remote devices discovered."
 
Here is a simpler code for just sending "xbeetest" every half of a second, through serial1.
Code:
void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {

    Serial1.print("testxbee");
    Serial.print("testxbee");
    delay(500);

}

DOUT flashing every half of a second, so it seems like sending:
[video]https://drive.google.com/open?id=0B6kl5zhiiKmaa0tyS3JpY0hyOUpheDNMbkgtWmdZW DJ6YlRV[/video]

But no messages received in the xtcu console.
 
It has been awhile since I have used the DIGI software and when I do, I still gravitate to the old version of the software. In the old version I think there was some connect button to have the terminal monitor actually talk to the XBees... Not sure if still the same with newer...

I think the next thing I would do would try is to see how well I can talk to the USB xbee locally...

Again I am rusty with XBees and have not used the Sparkfun Teensy Xbee adapter.

But if you type: +++
Does it respond with an OK...
If so, can you then type in commands like: atmy
And have it return the my for the xbee. and likewise: atdl
Which should return the destination low...

If so the XBee is talking to the MAC. You can then wait for that local connection to close again...
Or I think the command to close out of this is: atcn

You may also try this in the Arduino debug terminal to see if it is talking as well...

Edit: Also maybe try a different terminal window to talk from the MAC to the serial port to eliminate maybe XCTU not responding correctly.
 
Finally the issue is fixed its my bad!
Its because of missing headers:(
IMG_5753.jpg
Teensy_XBEE_Tutorial-02.jpg

Now its working very well!
Thanks Kurt for your time and effort.
and thanks to sparkfun technical service:)
 
Glad it is working! I meant to check if they required any of those connections for the 3.3v or GND...
 
Eventually,
I can read accelerometer data within Pure Data, but its hexadecimal.
Anyone know how to convert hexadecimal data to ascii?
 
Not sure what you are asking, nor the context...

But for example if you receive a binary value from Serial1 and wish to output it as an Ascii string back on Serial.

Code:
int value = Serial1.read();   // this reads in a binary value (one byte)
Serial.println(value, DEC);   // this will output the value as an ASCII string in base 10
Serial.println(value, HEX);  // Like above but will be a Hex string...

Now there are things like if the data coming from Serial1 is more than a byte, than you may need to combine values..
Like above but have two byte value assume LSB MSB...
Code:
int value = Serial1.read();   // this reads in a binary value (one byte)
value += (Serial1.read << 8);  // read in 2nd byte shift it up 8 bits to add onto value...
Serial.println(value, DEC);   // this will output the value as an ASCII string in base 10
Serial.println(value, HEX);  // Like above but will be a Hex string...

Now if instead you wish to have an ASCII string in memory, there are multiple ways to do so... You could use some form of conversion function..
You could use String functions, itoa functions, sprintf, ... Goggle finds lots of hits... like: https://stackoverflow.com/questions/7910339/how-to-convert-int-to-string-on-arduino
 
Status
Not open for further replies.
Back
Top