Re: SoftwareSerial patch not working

80 views
Skip to first unread message

Andrew Rapp

unread,
Oct 20, 2012, 10:09:00 PM10/20/12
to xbee...@googlegroups.com
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.

Leonard Corradine

unread,
Oct 21, 2012, 9:11:14 AM10/21/12
to xbee...@googlegroups.com
Hi,

Thank you for the brief reply, I will put your them in practice and post the results, hopefully they will help other people.

Cheers

Leonard Corradine

unread,
Oct 25, 2012, 4:47:39 PM10/25/12
to xbee...@googlegroups.com
So, I've been using the library for the past days and it seems to be working without any inconveniences. Thank you for the contribution! 

Andrew Rapp

unread,
Oct 26, 2012, 1:02:51 PM10/26/12
to xbee...@googlegroups.com
Thanks for the feedback!

On Thu, Oct 25, 2012 at 2:47 PM, Leonard Corradine <lacor...@gmail.com> wrote:
So, I've been using the library for the past days and it seems to be working without any inconveniences. Thank you for the contribution! 

--
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/-/Y3DJLMX7BhMJ.
Reply all
Reply to author
Forward
0 new messages