Get Xbee response from Serial and send to a browser

Hi,

I demonstrate my set up board like this:

Group 1: Arduino Uno + Xbee shield : broadcast the signal
Group 2: Arduino Uno + Xbee shield + Ethernet shield: receive the signal from group 1, get the signal strength from AT command and print it into the browser.

The problem here is I can’t get the result after sending to the Serial my ATDB command, actually, I am not sure it did worked as I expected.

Here is the code that I used to retrieve the signal strength.

int data;

void setup()
{
  Serial.begin(9600);
}

void receiver_checker(){  
  delay(1200);
  Serial.print("+++");
  delay(1200);
  bool bOK = false;
  while (Serial.available() > 0) {
    Serial.write(Serial.read());
     bOK = true;
  }
  
  if(bOK)
  {
    Serial.println();
    Serial.println("ATDB");
    delay(100);
    while (Serial.available() > 0) {
    Serial.write(Serial.read());
    }
    Serial.println();
  }
  
  Serial.println();
}

void loop()
{  
  while(Serial.available() > 0){
    data = Serial.read();
    if(data == '1'){
      // Broadcaster 1
      //Serial.println("1------------------");
      receiver_checker();      
    }
  }
  
}

Here is the code I combined the previous one and the server part from Web Server tutorial:

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xCA, 0xFE, 0x00, 0x00, 0x00, 0x02
};
IPAddress ip(1, 1, 1, 2);
int data;
int count = 0;
char result;
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  // Serial.print("server is at ");
  // Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          if (Serial.available() > 0) {
            // read the oldest byte in the serial buffer:
            data = Serial.read();
            // if it's a capital H (ASCII 72), turn on the LED:
            if (data == '1') {
              count += 1;
              client.print("The number of times:");
              client.print(count);
              result = receiver_checker();
              client.print("========================");
              client.print(result);
              client.print("========================");
            } 
          }
         
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

char receiver_checker(){
  char signal;  
  delay(1200);
  Serial.print("+++");
  delay(1200);
  bool bOK = false;
  while (Serial.available() > 0) {
    Serial.write(Serial.read());
     bOK = true;
  }
  
  if(bOK)
  {
    Serial.println();
    Serial.println("ATDB");
    delay(100);
    while (Serial.available() > 0) {
     signal = Serial.read();
    }
    Serial.println();
  } 
  Serial.println();
  return signal;
}

If there is another way to interact with the Xbee shield not go through Serial like I ask and get response directly, please let me know!
Thank in advance!

and print it into the browser

Browsers are generally clients and request info from servers. You might use server code that listens for both serial input and browser request. The serial part would listen for serial signal strength data, save the data to a variable, then supply the variable data to a client when requested.

edit: you might first get the serial communication working using a tx/rx/gnd connection, then introduce the xbees.

Thank you for your answer but I am confusing how to get answer from Xbee, here through Serial, with my first code, whenever I sent an ATDB command, it would response me with a hex number like 3D or 38 (in range of 1 meter) indicate the signal strength of the last package it received. I thought I got some problem in my code, because it looks like I couldn't save the output from Xbee to the variable. When I tried to print it in the browser, it just showed blank space!

while (Serial.available() > 0) {
     signal = Serial.read();
    }

I thought the code there is the source of the problem, but I am not sure how to fix it!

I know beside AT command, we can use also API to interact with XBee, can someone advise how to do it in my case?