xbee and arduino wifi shield

I’m in the middle of a project at the moment that takes data from an arduino with an xbee s2 connected to it and sends that data to a coordinator xbee connected to an arduino.

What i’m trying to do at the moment and failing is to send the data from the coordinator xbee to ThingSpeak via wifi.

I only have the normal arduino wifi shield thats piggy backed onto the arduino.

I’ve connected the xbee s2 to the 5v, ground and the Rx of the wifi shield.
I don’t have access to any other shields and was hoping that it would be a straight forward thing but alas not.

When i receive data from the end device to the coordinator attached to the arduino, i’m able to see that data. I also have a sensor on the coordinator arduino that i wish to push to ThingSpeak. The issue arrises when i try to receive data from the end device and then push it through the wifi sheild.

I really just don’t know if its my code, wiring error or compatibility issues with the xbee and the wifi shield.

This is my code

#include “Adafruit_BME680.h”
#include “WiFi.h”
#include “ThingSpeak.h”
SoftwareSerial XBee(2, 3);

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme; // I2C
//Adafruit_BME680 bme(BME_CS); // hardware SPI
//Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK);

char ssid[] = “WiFi_Booster”; // your network SSID (name)
char pass[] = “RWTFYWTBLY”; // your network password (use for WPA, or use as key for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

// ThingSpeak Settings
char thingSpeakAddress[] = “api.thingspeak.com”;
char APIKey[] = “7N09113FNS651OWF”; // enter your channel’s Write API Key
unsigned long channel_id = “914317”;
const int updateThingSpeakInterval = 20 * 1000; // 20 second interval at which to update ThingSpeak

// Variable Setup
long lastConnectionTime = 0;
boolean lastConnected = false;

// Initialize Arduino Ethernet Client
WiFiClient client;

void setup() {

while (!Serial);

if (!bme.begin(0x76)) { // ********** change from the default address (0x77) to 0x76
Serial.println(“Could not find a valid BME680 sensor, check wiring!”);
while (1);

// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println(“WiFi shield not present”);
// don’t continue:
while (true);

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:


// Set up oversampling and filter initialization
bme.setGasHeater(320, 150); // 320*C for 150 ms


void loop() {

while (XBee.available() > 0)
{ // If data comes in from XBee, send it out to serial monitor

float airQuality = XBee.read();

Serial.println("Posting " + String(airQuality, 2) + " to ThingSpeak");
ThingSpeak.setField(5, String(airQuality, 2));

if (! bme.performReading()) {
Serial.println(“Failed to perform reading :(”);
Serial.print(“Temperature = “);
Serial.println(” *C”);

//ThingSpeak temp field
Serial.println(“Posting " + String(bme.temperature, 2) + " to ThingSpeak”);
ThingSpeak.setField(1, String(bme.temperature, 2));

Serial.print(“Pressure = “);
Serial.print(bme.pressure / 100.0);
Serial.println(” hPa”);

//ThinSpeak Pressure field
Serial.println(“Posting " + String(bme.pressure, 2) + " to ThingSpeak”);
ThingSpeak.setField(2, String(bme.pressure, 2));

Serial.print(“Humidity = “);
Serial.println(” %”);

//ThingSpeak humidity field
Serial.println(“Posting " + String(bme.humidity, 2) + " to ThingSpeak”);
ThingSpeak.setField(3, String(bme.humidity, 2));

Serial.print(“Gas = “);
Serial.print(bme.gas_resistance / 1000.0);
Serial.println(” KOhms”);

//ThingSpeak gas field
Serial.println(“Posting " + String(bme.gas_resistance / 1000.0, 2) + " to ThingSpeak”);
ThingSpeak.setField(4, String(bme.gas_resistance / 1000.0, 2));

Serial.print(“Approx. Altitude = “);
Serial.println(” m”);


ThingSpeak.writeFields(channel_id, APIKey);

void printWifiStatus() {
// print the SSID of the network you’re attached to:
Serial.print("SSID: ");

// print your WiFi shield’s IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print(“signal strength (RSSI):”);
Serial.println(" dBm");

Thanks in advance

I don’t know anything about the Wifi shield you are referring to but I can tell you is that if you are getting the data from the XBee, then it is not an issue with the XBee side of it. You might want to ask this question on a forum that is devoted to Arduino products as then the right folks will see it.