XBee 2 data pins

Support forum for MegunoLink
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Wed Mar 29, 2017 4:42 pm

Which Arduino pins are used for communications with the Xbee? Can I change those pins and if so how? Reason being I got a Seeeduino Xbee shield that lets me choose any pair of digital pins.

Thanks

RoboBill
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Thu Mar 30, 2017 12:37 am

Hi RoboBill, MegunoLink talks to the modules using their API packet format natively so you can plug them straight into an xbee adapter with a COM port and talk to them using our xbee visualiser. If you are using it through an arduino you would need to read the xbee using software serial or a second serial port and mirror that data out the main serial port to MegunoLink.

What exactly are you trying to do?

Cheers
Phil
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Thu Mar 30, 2017 3:04 am

Hi Phil,

I'm trying to control and visualize data remotely on an Arduino 2560. I've set up a Dragino to upload sketches remotely. Do you have any examples of using an XBee i.e. the XBee Arduino sketch that works with a Megunolink program?

Thanks

RoboBill
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Fri Mar 31, 2017 7:14 am

We don't have any xbee examples and I don't have easy access of the hardware currently. I'll try my best to outline a scenario that I believe I have seen working.

If you take two xbees and put them in serial adapters like these
https://www.sparkfun.com/products/11812

And connect megunolink to both of them. First remembering to configure the xbees using xctu as outlined on this page (one as a coordinator and one as an endpoint or router).
http://www.megunolink.com/documentation/xbee-manager/
See the "Things to note" at the bottom of the page. The xbees must be series 2 and must be configured as outlined (API mode etc).

Then you can send messages over the network from one xbee to another and MegunoLink can display the packets and visualise the data as if it was any other serial connection.

I tested this by sending a message in one monitor windows and seeing that it appeared out the other monitor window (proving that it went out over the radio link).

Then you could take that second xbee and put it back with your micro and get it to send the messages back to the computer.

Hope this was helpful
Phil
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Sun Apr 02, 2017 11:14 pm

Hi Phil,

OK I got the two XBees to communicate and have the robot XBee mounted on a Seeeduino shield with the pins 12 for receiving and 8 for transmitting.
Here is a bit of my code added to your Blink2.0 :

#include "CommandHandler.h" // The serial command handler is defined in here.

// We'll use SoftwareSerial to communicate with the XBee:
#include <SoftwareSerial.h>
// XBee's DOUT (TX) is connected to pin 12 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 8 (Arduino's Software TX)
SoftwareSerial XBee(12, 8); // RX, TX

CommandHandler<> SerialCommandHandler;

Can I modify your command handle file to recognize XBee as defined by the SoftwareSerial function?

Thanks

RoboBill
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Mon Apr 03, 2017 11:07 am

Hi, this example shows our command handler using multiple sources
https://github.com/Megunolink/MLP/blob/ ... andler.ino

I think you could replace CommandProcessor<> Serial2CommandHandler(CommonCommands, Serial2);

with CommandProcessor<> Serial2CommandHandler(CommonCommands, Xbee);

Phil
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Mon Apr 03, 2017 9:21 pm

Hi Phil,

Thanks for the suggestion, but I can't find the CommandProcessor<> Serial2CommandHandler(CommonCommands, Serial2); anywhere

BTW I am a very real beginner arduino programmer

Thanks

RoboBill
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Tue Apr 04, 2017 5:34 am

Hi Bill, that code is in one of our examples. The arduino program is called MultiSourceCommandHandler.ino.

It allows you to have multiple sources triggering a single set of commands. Our library is typically installed inside the libraries folder of your Arduino IDE. In my case it is in "\arduino-1.8.1\libraries\MegunoLinkPro\examples\InterfacePanel\MultiSourceCommandHandler".

Use that example to transfer the relevant bits over to your program so that your software serial can be used to call commands.

Cheers
Phil
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Mon Apr 17, 2017 4:47 am

Hi Phil,

Sorry, but since I'm not a programmer, I don't understand your explanation. So I took on a much simpler example like Sparkfun's XBee_Serial_Passthrough.ino. I modified it a little. I'm able to transmit from the Xbee (series 2) to the serial but not from the serial to the xbee. Here is my sketch....



/*****************************************************************
XBee_Serial_Passthrough.ino

*****************************************************************/
//#include <XBee.h>
//#include <MegunoLink.h>
// We'll use SoftwareSerial to communicate with the XBee:
#include <SoftwareSerial.h>
// XBee's DOUT (TX) is connected to pin 9 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 11 (Arduino's Software TX)
SoftwareSerial nss(11, 9); // RX, TX

void setup()
{
// Set up both ports at 9600 baud. This value is most important
// for the XBee. Make sure the baud rate matches the config
// setting of your XBee.
nss.begin(19200);
Serial.begin(19200);
}

void loop()
{
if (Serial.available())
{ // If data comes in from serial monitor, send it out to XBee
nss.println(Serial.read());

}
if (nss.available())
{ // If data comes in from XBee, send it out to serial monitor
Serial.println(nss.read());
}
}


What am I doing wrong?

Thanks

RoboBill
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Thu Apr 20, 2017 4:35 pm

OK I just found Paul Martinsen's XBee 2 article which will be a great help. I now have the XBee 2's talking to Megunolink. I did go back to XBee series 1 and successfully hooked them up as a simple serial connections, but my series 2 xbees have the mini ufl's for external antennas where as my series 1 were on board antennas... and I need external antenna :-)


Thanks

RoboBill
Post Reply