Simple wireless sensor network test bed using SKXbee

Works done? Proud of it? Show off here! Let's see what you've built can help inspire others.

Simple wireless sensor network test bed using SKXbee

Postby mohamad_taib » Sun May 13, 2012 5:24 pm

Project Name: simple wireless sensor network test bed using SKXbee
Author/Designer: Mohamad Taib bin Miskon
Project Description:
Remote sensor nodes will sample the temperature and humidity using 10 bit conversion and send the data through wireless link to coordinator to be interpreted in more readable form. this project consist of 1 coordinator and 2 end device or sensor mote.

coordinator consist of
- 1 arduino board + xbee pro module + xbee shield

sensor motes consist of :
SKXbee + temperature sensor + humidity sensor

Data packets were sent to coordinator in API frame format.

Photo :
532707_422077611143710_100000244250326_1581439_1774208084_n.jpg


Compiler: Arduino + XCTU
Source code:

sample program as follows:
CODE: SELECT_ALL_CODE
this source code seems messy as many unnecessary lines still there
     
#include <NewSoftSerial.h>
NewSoftSerial xbeeSerial(2, 3);
byte packet[40]; //guess array size bigger than necessary
int i = 0;
int num = 0;
int count = 1;
int idx = 0;
int dataArray[5][5];
long tlong;
long tlong2;
long tlong3;
long tlong4;
int dg1,dg2,dg3,dg4;
int d1,d2,d3,d4;
int dc1,dc2,dc3,dc4;
unsigned long start, time, elapsed,minit,hour;
void setup()
{
Serial.begin(9600);
Serial.println("waiting for packets...");
Serial.println("time: 0:0:0,");
// set the data rate for the NewSoftSerial port
xbeeSerial.begin(9600);
}
void loop() // run over and over again
{

//get all the bytes in one RF packet
while(xbeeSerial.available()) {
 
packet[i] = xbeeSerial.read();
num = i+1; //num is the number of bytes in the RF packet
i++;
delay(1); //a little delay is necessary at 9600 baud rate
}
if(i>0){//Only want to print it once!
Serial.println();
timer();
printit();
fillDataArray();
empty_packet(num);
}
}
void printit(){

Serial.print("sample number :");
Serial.println(count);
Serial.print("Receive packet from mote Address :");
Serial.print(packet[4],HEX);
Serial.println(packet[5],HEX);
Serial.print("number of RF packet bytes = ");
Serial.println(num);
for(int j=0; j<num; j++){
Serial.print(packet[j],HEX);
Serial.print(", ");
}
Serial.println();
i =0; //reset counter wait for next RF packet
count++;
//num = 0;
}
void fillDataArray(){
 
       Serial.print("RSSI : -");
       Serial.println(packet[6],DEC);
       
        dataArray[0][0] = packet[11]*256 + packet[12];
   
        Serial.print("Voltage reading from temperature sensor :");
       tlong = (long)dataArray[0][0]*3000;
       tlong = tlong/1023;
       dg1 = tlong/1000;
       Serial.print(dg1);
       Serial.print(".");
       dg2 = (tlong/100)%10;
       Serial.print(dg2);
       dg3 = (tlong/10)%10;
       Serial.print(dg3);
       dg4 = tlong%10;
       Serial.print(dg4);
       Serial.print("V");
       Serial.println();

     
       tlong2 = (long)dataArray[0][0]*350; //205 utk full range dari -55C-150C
       tlong2 = tlong2/1023;  //26
       Serial.print(tlong2);
       Serial.print("degree");
       Serial.println();
     if (num>14)
     {
        dataArray[0][1] = packet[13]*256 + packet[14];//packet 13 utk MSB , packet 14 utk LSB
       
         Serial.print("Voltage reading from Humidity sensor :");
       tlong3 = (long)dataArray[0][1]*3000;
       tlong3 = tlong3/1023;
       d1 = tlong3/1000;
       Serial.print(d1);
       Serial.print(".");
       d2 = (tlong3/100)%10;
       Serial.print(d2);
       d3 = (tlong3/10)%10;
       Serial.print(d3);
       d4 = tlong3%10;
       Serial.print(d4);
       Serial.print("V");
       Serial.println();
       
       tlong4 = (long)dataArray[0][1]*80; //Relative humidity range 10% to 90%
       tlong4 = tlong4/1023;
       Serial.print(tlong4);
       Serial.println("%RH");
 }
 
  Serial.println();
  dg1 = 0;
   dg2 = 0;
  dg3 = 0;
  dg4 = 0;
  tlong2 =0;
   d1 = 0;
   d2 = 0;
  d3 = 0;
  d4 = 0;
  tlong3 =0;
  tlong4 =0;
}
void timer()
{
Serial.print("time: ");
start = millis();
hour = (start/3600000)%24;  //sec
Serial.print(hour);
Serial.print(":");

minit = (start/60000)%60;
Serial.print(minit);
Serial.print(":");
time = (start/1000)%60;   //hour

Serial.print(time);
Serial.println(",");
}
void empty_packet(int n)
{
 for (int m=0;m<n;m++)
  {
    packet[m] = 0;
   
  }
 
}


Till then.. have fun!
mohamad_taib
Freshie
 
Posts: 5
Joined: Tue Oct 25, 2011 4:08 pm

Re: Simple wireless sensor network test bed using SKXbee

Postby ober » Tue May 15, 2012 4:27 pm

Nice work! Thanks for sharing it!
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: Simple wireless sensor network test bed using SKXbee

Postby kl84 » Fri Jun 01, 2012 12:58 pm

How do you connect all three XBee together? Mess network? I only used one pair of XBee before :P
User avatar
kl84
Amateur
 
Posts: 166
Joined: Thu Jul 08, 2010 12:14 pm

Re: Simple wireless sensor network test bed using SKXbee

Postby mohamad_taib » Mon Jun 04, 2012 10:18 am

hi there,
sorry for the late reply,
i'm using star topology, we can set all remote node to send data to the same destination address which is the coordinator address. we can create mesh network using xbee series 2.
mohamad_taib
Freshie
 
Posts: 5
Joined: Tue Oct 25, 2011 4:08 pm


Return to Project Showcase

Who is online

Users browsing this forum: No registered users and 7 guests

cron