xbeeTest
Based on the Book building wireless sensor networks i tried to set up a connection between an arduino with a SHT15 temprature and humitdy sensor and an mbed.
Configure the xbee

Program
Mbed
Import programXBeeTest
xbee Test, Serial communication with Arduino. transmit Data from an SHT15 connected to a arduino to the mbed
Arduino
to run this program you need the libary sensiron.h.
/*
* Example code for SHT1x or SHT7x sensors demonstrating blocking calls
* for temperature and humidity measurement in the setup routine and
* non-blocking calls in the main loop. The pin 13 LED is flashed as a
* background task while temperature and humidity measurements are made.
*/
#include <Sensirion.h>
const uint8_t dataPin = 9; // SHT serial data
const uint8_t sclkPin = 10; // SHT serial clock
const uint8_t ledPin = 13; // Arduino built-in LED
const uint32_t TRHSTEP = 5000UL; // Sensor query period
const uint32_t BLINKSTEP = 250UL; // LED blink period
Sensirion sht = Sensirion(dataPin, sclkPin);
uint16_t rawData;
float temperature;
float humidity;
float dewpoint;
byte ledState = 0;
byte measActive = false;
byte measType = TEMP;
unsigned long trhMillis = 0; // Time interval tracking
unsigned long blinkMillis = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
delay(15); // Wait >= 11 ms before first cmd
// Demonstrate blocking calls
sht.measTemp(&rawData); // sht.meas(TEMP, &rawData, BLOCK)
temperature = sht.calcTemp(rawData);
sht.measHumi(&rawData); // sht.meas(HUMI, &rawData, BLOCK)
humidity = sht.calcHumi(rawData, temperature);
dewpoint = sht.calcDewpoint(humidity, temperature);
logData();
}
void loop() {
unsigned long curMillis = millis(); // Get current time
// Rapidly blink LED. Blocking calls take too long to allow this.
if (curMillis - blinkMillis >= BLINKSTEP) { // Time to toggle the LED state?
ledState ^= 1;
digitalWrite(ledPin, ledState);
blinkMillis = curMillis;
}
// Demonstrate non-blocking calls
if (curMillis - trhMillis >= TRHSTEP) { // Time for new measurements?
measActive = true;
measType = TEMP;
sht.meas(TEMP, &rawData, NONBLOCK); // Start temp measurement
trhMillis = curMillis;
}
if (measActive && sht.measRdy()) { // Note: no error checking
if (measType == TEMP) { // Process temp or humi?
measType = HUMI;
temperature = sht.calcTemp(rawData); // Convert raw sensor data
sht.meas(HUMI, &rawData, NONBLOCK); // Start humidity measurement
} else {
measActive = false;
humidity = sht.calcHumi(rawData, temperature); // Convert raw sensor data
dewpoint = sht.calcDewpoint(humidity, temperature);
logData();
}
}
}
void logData() {
Serial.print(temperature); Serial.print("T;"); Serial.print(humidity);
Serial.print("H;"); Serial.print(dewpoint);
Serial.print("D;");
Serial.println(";X;");
}
Layout
(made with fritzing)
Mbed

Arduino

Graphs

Parts
Sensor
- Arduino Uno
- xbee shield
- xbee module
- SHT15 Breakout
Mbed Base
- mbed
- Breadboard & Wires
- xbee breakout board
- xbee module
- TextLCD
- 10KOhm Trimpot
Tools
- Sparkfun xbee explorer USB
2 comments on xbeeTest:
Please log in to post comments.

do i also need xctu to configure xbee with mbed? i want to send data wirelessly from one mbed to other mbed through xbee.