For this, smart lifejacket. The input sensors would most suitably be moisture sensors which turn the Xbee proximity scan on, on the remote unit. Actuators you would most likely use would be buzzers, LED's or other parts of a wider smart system.
Both units are running the same sketch as one another. This new sketch incorporates both send and receive sketches. Curiously, the Arduino Duemilanove with the 9V battery has a slightly less stable reception range than the 3.7V Seeeduino Stalker kit.
The range of this system is about 20meters strong signal and 50meters of disrupted signal. Less when line of sight is obscured.
The Seeeduino Stalker Waterproof Solar Kit is an excellent choice if you are looking to start using Xbee. No breakout boards or shields necessary and its already set up with a 3.7V lipo, mini solar panel and solar regulator.
To upload the sketch to Seeeduino Stalker you will need to use a UartBee and a mini USB cable, via the RX/TX pins (make sure you take off the Xbee while transferring the code onto the board);
RX/TX Coding Pins on Stalker;
- USB5V - Draws 5V from computer, via USB, while attached
- RXD - Receive Data
- TXD - Transfer Data
- GND - Ground the circuit
- DTR - Data Transfer
The sketch below switches an LED on in pin 13 on when the Xbee's are in range and the sensor reading is above 200, but is otherwise the same as the code further up the page;
int sensorPin = A0;
int sensorValue = 0;
void setup(){
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop(){
if (sensorValue > 200){
if(Serial.available() > 0){
digitalWrite(13,HIGH);
Serial.flush();
delay(100);
Serial.write('d');
Serial.flush();
delay(100);
}
}
else {
digitalWrite(13,LOW);
}
}
I revised the code when it was pointed out to me that in the permutation above everything turns on when the receivers are in range of each other. For this smart lifejacket example it would be more useful to swap that around. Also, I have added a speaker to the system as per my original concept;
/*this sketch is by seamus mccarthy 2011 using bits from examples and
online support communities.
It is meant to help people new to xbee to get started using it in your
own smart systems projects*/
int sensorPin = A0; //Sensor pin (moisture, light, pot etc)
int sensorValue = 0; //Sensor variable
void setup(){
Serial.begin(9600);
pinMode(13,OUTPUT); //LED pin
pinMode(6,OUTPUT); //add a pin for speaker tone
}
void loop(){
if (sensorValue > 200){ //if sensor value is above 200..
if(Serial.available() > 0){ //check if Serial data is available
digitalWrite(13,LOW); //Turn off LED
}
else {
digitalWrite(13,HIGH); //Turn on LED
tone(6, 440, 100); //play A4 note on pin 6 for 100 ms:
tone(6, 1760, 100); //play A6 note on pin 6 for 100 ms:
Serial.flush(); //flush
delay(100); //delay
Serial.write('d'); //send back serial to other unit
Serial.flush(); //flush
delay(100); //delay
}
}
}
// set pitches
#define NOTE_A4 440
#define NOTE_A6 1760
For a tutorial of how to make your own PCB at home visit this link.
Hello, what is the housing you used for the xbee on the life jacket? Also where can I buy/make my own?
ReplyDelete