Xbee and Arduino

Good day everyone! Please enlighten me. I have a setup of Arduino Mega and Xbee s2c. I am receiving sensor data with my xbee and I can see it in my serial monitor. My problem is how can i get the data from the xbee and use it as input to be transmitted to the internet? What type of data appears on the serial monitor? Does this xbee reeived data can be sent to internet? Your help is appreciated. Thanks!

The data doesn't go straight from the xbee to the Serial monitor does it? It goes through the Arduino. Arduino reads from the xbee and then prints out what it read. And there is your answer. You're reading that data with the Arduino, so go do something more with it than just print it if you want to.

Delta_G:
The data doesn't go straight from the xbee to the Serial monitor does it? It goes through the Arduino. Arduino reads from the xbee and then prints out what it read. And there is your answer. You're reading that data with the Arduino, so go do something more with it than just print it if you want to.

Yes, i know it goes through the arduino. Ive tried this code:

void loop () {

if (XBee.available()) {
Serial.write(XBee.read());
}
datasens1 = XBee.read();
sens1 = datasens1 ;

data = "&waterlvl=" + sens1;// data sent must be under this form //name1=value1&name2=value2.

httppost();

delay(1000);

But i cant seem to send the data to my server. Any suggestions in the coding? Thanks!

"Any suggestions"

Post complete code IN CODE TAGS and details of your server.

Delta_G:
“Any suggestions”

Post complete code IN CODE TAGS and details of your server.

Hello! So here’s my code:

#include <SoftwareSerial.h>
String ssid = "WiFi";
String password = "CruzzurC1234";

SoftwareSerial esp(10, 11);// RX, TX
SoftwareSerial XBee(17, 16);//RX, TX

String data;
String server = "34.211.192.31"; // www.example.com
String uri = "test.php";// our example is /esppost.php
int sens1 , sens2;
int datasens1;

void setup() {

  XBee.begin(9600);
  esp.begin(9600);
  Serial.begin(9600);
  reset();
  connectWifi();

}

//reset esp8266 module

void reset() {

  esp.println("AT+RST");
  delay(1000);
  if (esp.find("OK") ) Serial.println("Module Reset");

}

//connect to wifi network

void connectWifi() {

  String cmd = "AT+CWJAP=\"" + ssid + "\",\"" + password + "\"";
  esp.println(cmd);
  delay(4000);
  if (esp.find("OK")) {
    Serial.println("Connected!");

  }

  else {

    connectWifi();

    Serial.println("Cannot connect to wifi");
  }

}

void loop () {

  if (XBee.available()) {
    Serial.write(XBee.read());
  }
  datasens1 = XBee.read();
  sens1 = datasens1 ;

  data = "&waterlvl=" + sens1;// data sent must be under this form //name1=value1&name2=value2.

  httppost();

  delay(1000);

}

void httppost () {

  esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.

  if ( esp.find("OK")) {

    Serial.println("TCP connection ready");

  } delay(1000);

  String postRequest =

    "POST " + uri + " HTTP/1.0\r\n" +

    "Host: " + server + "\r\n" +

    "Accept: *" + "/" + "*\r\n" +

    "Content-Length: " + data.length() + "\r\n" +

    "Content-Type: application/x-www-form-urlencoded\r\n" +

    "\r\n" + data;

  String sendCmd = "AT+CIPSEND=";//determine the number of characters to be sent.

  esp.print(sendCmd);

  esp.println(postRequest.length() );

  delay(500);

  if (esp.find(">")) {
    Serial.println("Sending.."); esp.print(postRequest);

    if ( esp.find("SEND OK")) {
      Serial.println("Packet sent");

      while (esp.available()) {

        String sensdat1 = esp.readString();

        Serial.println(sensdat1);

      }

      // close the connection

      esp.println("AT+CIPCLOSE");

    }

  }
}

I am using the Xbee.read to get my data from the xbee and use it as input but i think what im doing is wrong. Any help in coding is appreciated! Also, my data base is in mysql and i am using phpmyadmin to organize my data. i have my own server too. you can see my ip address in the code. Thanks!

“you can see my ip address in the code.”

Not a good idea. You should probably redact that if you don’t want a bunch of ner-do-wells playing tricks on said server.