[Solved] Arduino Fio no longer works with Xbee

Hey everyone. Thanks to all in advance for any help / advice you can provide.

I've been working on a weather station and it has been going well. See post links below for project history:
Post Link 1: [Solved] Printing to LCD from incoming XBee Data - Project Guidance - Arduino Forum
Post Link 2: Off Grid Weather Station: Usage Determination to size Battery/Solar Combo - Project Guidance - Arduino Forum

The Fio is hooked up to Xbee1 and an Uno is hooked up to Xbee2. To get the two Xbees communicating I used this tutorial and it worked great(Exploring Xbees and XCTU). I even used this "test code" (Xbee Shield Hookup Guide) and it was great when communicating to/from the Arduino Serial Port and the XCTU portal. After uploading the weather Tx and Rx code, it worked great when transmitting the Fio weather data to the Arduino Uno Rx.

Moving the project forward, I began calculating the usage requirements of the Weather Station using a Voltmeter and Kill-o-watt meter just to double check that my calculations were in the ballpark. I determined that I needed to put the Xbee1 to sleep when it isn't being used and only turn it on to transmit data. I used XCTU to adjust the settings and set "SM Sleep Mode" to "Pin Hibernate [1]". When testing the Xbees in the XCTU, they communicate fine with eachother. The problem was when I tried to use the "test code" on the Fio+Xbee1 to communicate to the XCTU with Xbee2. No communication or transfer of data occurred.

Trying to troubleshoot I did the following scenarios:

  1. Placed Xbee1 on the Arduino Uno (uploaded the "test code"). XCTU was connected to Xbee2. No communication occurred.
  2. Connected Xbee1 to the XCTU and Xbee2 on the Uno, the communication was fine.
  3. Connected Xbee1 into the XCTU, Xbee2 on the Fio, no communication occurred.

I think this could be due to a couple possibilities but I'm not sure how to test to see how to solve the issue:

  • When Xbee1 is on an Arduino (Fio or Uno) it doesn't work. OR/AND
  • Something is wrong with the Fio-Xbee connection. Could I have short circuited something when testing voltages with the volt meter? The Fio still takes the weather samples but it just doesn't seem to be able to send it anymore.

Does anyone have any thoughts or suggestions?

Thanks for the help

This is kinda embarrassing but I figured out my problem. It seems as if when you enable "Pin Hibernate [1]", it's default is to sleep and so therefore if that's all you do the Xbee will not transmit. You need to tell the Xbee to wake and sleep for it to work. I had to soldered a pin to the DTR pin slot on the Fio and link it to the "xbeePowerPin" Pin. That seems to have solved my issue. Hope that helps others.

#include <LowPower.h>
#define xbeePowerPin 9 // Arduino pin used to sleep the XBee

#include "DHT.h"
#define DHTPIN 7     // what digital pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

#include <Wire.h>
#include <Adafruit_BMP085.h>
#include "LowPower.h"

/***************************************************
  This is an example for the BMP085 Barometric Pressure & Temp Sensor

  Designed specifically to work with the Adafruit BMP085 Breakout
  ----> https://www.adafruit.com/products/391

  These displays use I2C to communicate, 2 pins are required to
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
// EOC is not used, it signifies an end of conversion
// XCLR is a reset pin, also not used here

Adafruit_BMP085 bmp;
int tempC;  // Variable for holding temp in C | oringinally float, changed to int
int tempF;  // Variable for holding temp in F | oringinally float, changed to int
float pressure; //Variable for holding pressure reading in Pa | oringinally float, changed to int
float pressuremmHg; // Variable for holding pressure reading in mmHg | oringinally float, changed to int
float pressureinHg; // Variable for holding pressure reading in inHg| oringinally float, changed to int
int dewpoint; // Variable for holding pressure reading in *C| oringinally float, changed to int

// We'll use SoftwareSerial to communicate with the XBee:
#include <SoftwareSerial.h>
// XBee's DOUT (TX) is connected to pin 2 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 3 (Arduino's Software TX)
SoftwareSerial XBee(2, 3); // RX, TX

  char dataPacket [64]; //an array with 12 integer elements, but 64 total characters
  int i; //used as an index into the array
  char P1[15]; // these are values created through the "dtostrf" function because the "sprintf" doesn't allow floats
  char P2[15]; // these are values created through the "dtostrf" function because the "sprintf" doesn't allow floats
  char P3[15]; // these are values created through the "dtostrf" function because the "sprintf" doesn't allow floats
  char H1[15]; // these are values created through the "dtostrf" function because the "sprintf" doesn't allow floats

void setup() {
  // Set up both ports at 9600 baud. This value is most important
  // for the XBee. Make sure the baud rate matches the config
  // setting of your XBee.
  XBee.begin(9600);
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
  bmp.begin();
    }
    
void loop() 
{
    // Enter power down state for 60 s with ADC and BOD module disabled
    //LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);    

//DHT Values Below:
  // Reading temperature or humidity takes about 250 milliseconds! | oringinally float, changed to int
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity(); 
  // Read temperature as Celsius (the default) | oringinally float, changed to int
  int t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true) | oringinally float, changed to int
  int f = dht.readTemperature(true);
  // Compute heat index in Fahrenheit (the default) | oringinally float, changed to int
  int hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)| oringinally float, changed to int
  int hic = dht.computeHeatIndex(t, h, false);
  int DP = (t - ((100 - h) / 5)); // Calculates the Dew Point in *C if Humidity >50% (DHT) dd.dd

//DHT Values Below:
  tempC = bmp.readTemperature(); //  Read Temperature (bmp)
  tempF = tempC * 1.8 + 32.; // Convert degrees C to F (bmp)
  pressure = bmp.readPressure(); //Read Pressure (bmp)
  pressuremmHg = (pressure * .0075); //(bmp) 
  pressureinHg = (pressure / 3386.39); //(bmp)

    dtostrf(pressure,9,2,P1); // due to issues showing pressue in the "sprintf" function because it's a float value. 9 digits, 0 significant digits
    dtostrf(pressuremmHg,6,2,P2); // due to issues showing pressue in the "sprintf" function because it's a float value.
    dtostrf(pressureinHg,5,2,P3); // due to issues showing pressue in the "sprintf" function because it's a float value.
    dtostrf(h,5,2,H1); // due to issues showing pressue in the "sprintf" function because it's a float value.

{
  pinMode(xbeePowerPin, OUTPUT);
  digitalWrite(xbeePowerPin, LOW);
  delay(1000);
// sprintf(dataPacket, "X%d" ,gx) - this is used to compile multiple datastrings togeter
// d=integer, f=float ,s=
sprintf(dataPacket,"<%d,%d,%d,%d,%d,%d,%s,%d,%s,%s,%s>",tempC,tempF,t,f,hic,hif,H1,DP,P1,P2,P3);
Serial.println(dataPacket);
XBee.print(dataPacket);
  // all together the output to the serial monitor is going to be the following
  //tt(2),ff(2),II(2),ii(2),hh(2),dd(2),HH.HH(5),DD.DD(5),PPPPPP(6),mmm.mm(6),NN.NN(5) 39 characters
  delay (14000);  // reduce this amount or completly remove when xbee sleep is working.
  pinMode(xbeePowerPin, INPUT_PULLUP);
  digitalWrite(xbeePowerPin, HIGH);
  delay(15000);  //remove this when code is fine
}
}