The begin and setSerial functions are identical. In this case you are setting software serial, then setting it to hardware serial, so you never use software serial. You can use one but not both. So to use software serial
xbee.setSerial(nss);
If hardware serial then
xbee.setSerial(Serial)
Always call begin on your serial object first, whether software or hardware
On Sat, Oct 20, 2012 at 4:37 PM, Leonard Corradine
<lacor...@gmail.com> wrote:
Hello,
I downloaded yesterday the patch update in order to communicate through the SoftwareSerial library, however, though I have configured the radios as specified, I cannot get them to talk to each other. I would like to know if there are any additional settings that need to be applied, other then setting up MY addresses and, enabling API mode.
Here is my code, just in case:
#include <XBee.h>
#include <StopWatch.h>
#include <SoftwareSerial.h>
#define sensPin5 0
int sensVal[6] ;
int count[2] ;
int countTot[2] ;
unsigned long lastTwo = 0;
const char comma = ',';
// allocate two bytes for to hold a 10-bit analog reading
uint8_t payload[] = { 0, 0, 0, 0 };
Tx16Request tx = Tx16Request(0x5000, payload, sizeof(payload));
SoftwareSerial nss(2,3);
XBee xbee = XBee();
StopWatch stopW2 ;
void setup()
{
Serial.begin(9600);
nss.begin(9600);
xbee.begin(nss);
xbee.setSerial(Serial);
Serial.print("<<<Program started>>>");
Serial.println();
}
void loop()
{
sensVal[5] = pulseIn(sensPin5, HIGH);
if(sensVal[5] != 0)
{
//Serial.println("pin 5");
stopW2.start();
count[1] ++ ;
if(stopW2.elapsed() - lastTwo > 500 )
{
//Serial.println(count[1]);
lastTwo = stopW2.elapsed();
countTot[1] = count[1];
payload[2] = countTot[1] ;
payload[3] = comma ;
//Serial.println(payload[2], DEC);
xbee.send(tx);
count[1] = 0;
}
}
I would kindly appreciate any help.
--
You received this message because you are subscribed to the Google Groups "xbee-api" group.
To view this discussion on the web visit https://groups.google.com/d/msg/xbee-api/-/yL7vrraIm-sJ.
To post to this group, send email to xbee...@googlegroups.com.
To unsubscribe from this group, send email to xbee-api+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xbee-api?hl=en.