andrewrapp / xbee-arduino

Arduino library for communicating with XBee radios in API mode
GNU General Public License v2.0
334 stars 162 forks source link

Arduino Mega 2560 Software Serial Not Working #44

Open bluewookie88 opened 7 years ago

bluewookie88 commented 7 years ago

Hello!

We have an xBee Pro S2C that is using this library very well on a Software Serial connection to ports 2 and 3 on an Arduino Uno. However, when we take the same setup and try it on a Arduino Mega 2560 using any of the ports specified here:

https://www.arduino.cc/en/Reference/SoftwareSerial Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

We cannot get this setup to work on the Arduino Mega 2560. We did not try every combination of these ports but tried most of them and it continues to fail. We can get successful packets on an Uno on pins 2 and 3.

Code is as follows:

`#include "Arduino.h"

include "XBee.h"

include

define IS_STAR 0

if IS_STAR

define rxPin 10 //input

define txPin 11 //output

else

define rxPin 2 //input

define txPin 3 //output

endif

include "SoftReset.h"

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///setup xbee object

XBee xbee = XBee(); SoftwareSerial xBeeSerial = SoftwareSerial(rxPin, txPin);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Setting up class & contructors

Laser::Laser () {

        pinMode(rxPin, INPUT);
        pinMode(txPin, OUTPUT);
        xBeeSerial.begin(9600);
        xbee.setSerial(xBeeSerial);
        Serial.begin(9600);`

Any thoughts as to what changes would need to be made to this library in order to run on a Mega if any?