I am using one XBee S2 configured as coordinator API attached to my laptop and one XBee S2 attached to an Arduino Uno that is configured as a router AT. I want to generate an alarm on LabVIEW as I have used VISA for serial communication.

#include <SoftwareSerial.h>

int buttonState1 = 0;
SoftwareSerial XBee(2,3); // RX, TX
int pin=13;
void setup() {


void loop() {
    if (Serial.available())
       buttonState1 = digitalRead(2);

    if (buttonState1 == HIGH) {
       // turn LED on:


    else {
       // turn LED off:


but I am getting no response at all.

What could be the root cause for this and how do I diagnose that?

  • you have never used XBee Serial, whereas you are supposed to read data from it. Apr 11 '17 at 4:27

Pin 2 & 3 are hardware serial pins. You can't/shouldn't attach softwareserial pins to them.

In short, your SoftwareSerial XBee is never used and uses the same pins of the hardware serial.

What are you actually trying to achieve? I have a hard time understanding it. Though. You should first check if your connection is working.

What devices do you have connected to the arduino?

Is it [Arduino] <-> [XBEE] <-> [PC]?

Test your connection using the code below

int incomingByte = 0;   // for incoming serial data

void setup() {
        Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);


  • kindly guide me more i am attaching pin2 of xbee with dig0 and pin3 of xbee with dig1 still its not working no response
    – user10449
    Jun 4 '15 at 3:18
  • No, on an UNO the hardware serial pins are 0 and 1. 2 and 3 are the interrupt pins and if the OP isn't using external interrupts he's fine to use them as soft serial.
    – Delta_G
    Jun 5 '18 at 5:09

Are you using XBee shield or directly connecting it to Arduino and are you using point to point communication between the two XBees?

For getting and sending data between two XBees they must be configured in point to point mode. First, test them to ensure that they are getting data through this communication.

If yes, then issue will be on your LabVIEW VI, because your Arduino code seems to be fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.