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
}
}