Project Report wireless sensor Network

34
Submitted By –Braj Raj Singh Submitted to Prof. Carl Lundgren Telecommunication Engineering Technology Rochester Institute Of Technology Graduate Research Paper Wireless Sensor Network For Smart Grid Refrigerator/Freezer Unit

Transcript of Project Report wireless sensor Network

Page 1: Project Report wireless sensor Network

Submitted  By  –Braj  Raj  Singh                                                                                                                                                        Submitted  to-­‐  Prof.  Carl  Lundgren    Telecommunication  Engineering  Technology  

R o c h e s t e r   I n s t i t u t e   O f   T e c h n o l o g y  

 

   

Graduate  Research  Paper                                                                                                                Wireless  Sensor  Network  For  Smart  Grid    Refrigerator/Freezer  Unit  

Page 2: Project Report wireless sensor Network

  2  

Index  

1).  Introduction                                                                                                                                                                                                        Page  3                                                                                                                                                                  

2).  Required  Component  -­‐  

I. MSP  430  Microcontroller                                                                                                                                                  Page-­‐  4  

II. CC2500                                                                                                                                                                                                                  Page-­‐  6  

III. EZ430-­‐RF2500T  Target  Board                                                                                                                                    Page  -­‐7  

3).  Access  Point                                                                                                                                                                                                          Page  -­‐8  

4).  Program  for  Access  Point                                                                                                                                                            Page  -­‐9  

5).      End  Device                                                                                                                                                                                                            Page  -­‐15  

6).  Compiling  and  Loading  the  Access  Point  code                                                                                    Page  -­‐16  

7).  Program  for  End  device                                                                                                                                                                  Page  -­‐19  

8).  Compiling  and  Loading  the  End  Device  Code                                                                                        Page-­‐  25  

8).  Temperature  Sensors  Monitoring  Portal                                                                                                      Page  -­‐26  

9).  Wireless  Sensor  Network  diagram                                                                                                                            Page  -­‐28              

10).  Data  Acquisition  system  for  wireless  sensor                                                                                      Page  -­‐29  

11).  Process  to  configure  Real  Term  application                                                                                        Page  -­‐30  

12).  Representation  of  Sensors  data                                                                                                                                  Page  -­‐31  

13).  Customized  program  for  Data  Acquisition  (End  Device).                                            Page  -­‐32  

14).  References                                                                                                                                                                                                            Page  -­‐34  

Page 3: Project Report wireless sensor Network

  3  

Introduction –  

Wireless Sensor Network-

A  wireless  sensor  network  consists  of  spatially  distributed  autonomous  sensors  to  monitor  physical  or  environmental  conditions,  such  as  temperature,  sound,  vibration,  pressure,  motion  or  pollutants  and  to  cooperatively  pass  their  data  through  the  network  to  a  main  location.  These  Wireless  networks  are  used  in  many  industrial  and  consumer  applications,  such  as  industrial  process  monitoring  and  control,  machine  health  monitoring,  and  so  on.  

The  Wireless  Sensor  Network  is  built  of  nodes  from  a  few  to  several  hundreds  or  even  thousands,  where  each  node  is  connected  to  one  or  more  sensors.  Each  such  sensor  network  node  has  typically  several  parts:  a  radio  transceiver  with  an  internal  antenna  or  connection  to  an  external  antenna,  a  microcontroller,  an  electronic  circuit  for  interfacing  with  the  sensors  and  an  energy  source,  usually  a  battery  or  an  embedded  form  of  energy  harvesting.  A  sensor  node  might  vary  in  size  from  that  of  a  shoebox  down  to  the  size  of  a  grain  of  dust,  although  functioning  "motes"  of  genuine  microscopic  dimensions  have  yet  to  be  created.  The  cost  of  sensor  nodes  is  similarly  variable,  ranging  from  a  few  to  hundreds  of  dollars,  depending  on  the  complexity  of  the  individual  sensor  nodes.  Size  and  cost  constraints  on  sensor  nodes  result  in  corresponding  constraints  on  resources  such  as  energy,  memory,  computational  speed  and  communications  bandwidth.  The  topology  of  the  WSNs  can  vary  from  a  simple  star  network  to  an  advanced  multi-­‐hop  wireless  mesh  network.  The  propagation  technique  between  the  hops  of  the  network  can  be  routing  or  flooding.  

 

Wireless Sensor Network for Smart Grid Refrigerator-  

This  Project  research  is  based  on  remotely  monitoring  and  analyzing  the  temperature  of  Refrigerator/Freezer  unit  using  wireless  sensors.    Specifically,  this  portion  of  the  project  was  the  development  and  fabrication  of  wireless  temperature  instrumentation  to  be  placed  in  multiple  locations  in  the  refrigerator  and  freezer  compartments.    This  wireless  data  acquisition  system  allows  minimal  thermal  leakage;  and  data  storage  and  display  remote  to  the  R/F  allows  continuous  and  offsite  monitoring.  In  addition  to  data  acquisition,  the  system  is  a  prototype  for  future  systems  where  the  temperature  sensor(s)  communicates  with  the  demand  management  controller  to  avoid  excessive  temperature  excursions.  

Page 4: Project Report wireless sensor Network

  4  

Required  Components  of  project-­‐    (1).  MSP430  Microcontroller-­‐    MSP430  is  one  of  the  main  component  of  wireless  sensor  network.  This  is  Mixed  Signal  Processor,  Which  is  ideal  for  battery-­‐powered  measurement  applications.      

                                                                   Ultra-­‐low  Power-­‐    The   MSP430   architecture   is   designed   specifically   for   ultra-­‐low   power   applications.  Specific   operating  modes   are   implemented   to   reduce  power   consumption  and  extend  battery   life.   The   real-­‐time   clock   mode   uses   as   little   as   0.8µA   and   can   transition   to  industry  leading  250mA  /  MIPS  full-­‐speed  active  mode  in  less  than  1µs.  Other   important   low-­‐power   feature   such   as   zero-­‐power   brown-­‐out   reset   (BOR)   and  extremely   low  pin   leakage  have  enabled  MSP430  customers   to  develop  battery-­‐based  products  that  will  last  for  over  10-­‐years  from  the  original  battery.    The  MSP430  modern   16-­‐bit   RISC   architecture   reduces   code   size   and   allows   advanced  signal  processing  features  not  possible  using  conventional  8-­‐bit  MCUs.        

Page 5: Project Report wireless sensor Network

  5  

Intelligent  mixed-­‐signal  peripherals   including  10-­‐16-­‐bit  ADC’s,  comparators,  DAC’s,  LCD  drivers   and   supply   voltage   supervisors   support   precision   measurement.   This   allows  applications  to  get  implemented  faster,  using  less  code  and  power  at  lower  cost.  Applications   operating   at   lower   power,   with   smaller   packaging   and   higher-­‐precision  analog  benefit  greatly  from  the  MSP430’s  embedded  emulation.      No   external   emulator   is   required   as   the   device   emulates   itself.   JTAG   is   used   to  communicate   unobtrusively   with   the   MSP430   in   application.   This   means   that   all  development   is  done  under   the   same  condition   that  will  be   seen   in   the   final  product.  Using   embedded   emulation   projects   are   developed   faster,   with   few   errors   and   at   a  lower  cost.        

 

           

FLASH

8-60K B

RAM

512-10K B

PORBOR

8MhzBasicClock

Watchdog

15-bit

RISCCPU16-bit JT

AG

/EE

M

Port3/4Port5/6

MAB

MDB

Timer_B7

16-bit

Port1/2with IRQ

Comp_A

USART1UART/SPI

Timer_A3

16-bit

ADC12200ksps

Vref Temp

DAC12_0DAC12_1

DM

A

SVS

USART0UART/SPI

I2C

MPYMPYSMAC

MACS

Page 6: Project Report wireless sensor Network

  6  

   (2).  CC2500-­‐    

The  CC2500  is  a  low-­‐cost  2.4  GHz  transceiver  designed  for  very  low-­‐power  wireless  applications.  

 The  RF  transceiver  is  integrated  with  a  highly  configurable  baseband  modem.  The  modem  supports  various  modulation  formats  and  has  a  configurable  data  rate  up-­‐to  500  kBaud.  

 

                         Key  Feature  of  CC2500-­‐  

High  sensitivity  (–104  dBm  at  2.4  kBaud  1%  packet  error  rate).  

 Low  current  consumption  (13.3  mA  in  RX,  250  kBaud,  input  well  above  sensitivity  

limit).  

 Programmable  output  power  up  to  +1  dBm.  

 Excellent  receiver  selectivity  and  blocking  performance.  

 Programmable  data  rate  from  1.2  to  500  kBaud  .  

 Frequency  range:  2400  –  2483.5  MHz  

Page 7: Project Report wireless sensor Network

  7  

(3).  EZ430-­‐RF2500T  Target  Board-­‐  

The  eZ430-­‐RF2500  used  as  a  stand-­‐alone  development  tool.  Additionally,  the  eZ430-­‐

RF2500T  target  board  used  to  detached  from  the  debugging  interface  and  integrated  

into  another  design  by  removing  the  plastic  enclosure.    

The  target  board  features-­‐  

 Most  of  its  pins  are  easily  accessible.  

MSP430F2274  –    

1) 32KB  Flash  

2) 1KB  RAM  

3) USCI  (UART,  2xSPI,  I2C,  IrDA)    

4) 10-­‐bit  200  kbps  ADC  

5) 2  Op  Amps  

CC2500  –    

1) 2.4  GHz,  ISM  band  multi-­‐channel  low  power  transceiver  

2) 2  LEDs    

3) 1  pushbutton  

4) Battery  expansion  board  with  2  AAA  batteries    

 

 

Page 8: Project Report wireless sensor Network

  8  

Access  Point  –  

There  are  two  main  part  of  RF  wireless  sensor  Network  one  is  programmable  USB  

Access  point,  which  is  a  simple  serial  port  device.  In  Access  point  each  circuit  board  

holds  a  complete  computer  and  a  2.4  GHz  radio  transceiver.    

The  computer  contains  several  analog  and  digital  I/O  channels,  including  10  bit  analog  

to  digital  conversion,  two  op-­‐amps,  and  an  interface  to  the  radio  chip.    

We  can  program  the  computer  in  C  using  a  very  nice  development  system  included  with  

the  kit.  This  also  provides  us  with  the  libraries  needed  to  use  the  radio  to  send  and  

receive  simple  messages.  We  can  interact  with  the  computer  via  18  pins,  two  LED’s  and  

a  pushbutton.  

 

 

   

 

 

Page 9: Project Report wireless sensor Network

  9  

Program  for  Access  point  –    The  access  point  build  includes  implementation  of  an  unknown  number  of  end  device  peers  in  addition  to  access  point  functionality.  In  this  scenario  all  End  Devices  establish  a  link  to  the  access  point.  The  AP  acts  as  a  data  hub.  All  End  Device  peers  are  on  the  access  point  and  not  on  other  distinct  ED  platforms.  There  is  still  a  limit  to  the  number  of  peers  supported  on  the  access  point  that  is  defined  by  the  macro  NUM_CONNECTIONS.  The  access  point  will  support  NUM_CONNECTIONS  or  fewer  peers  but  the  exact  number  does  not  need  to  be  known  at  build  time.          /*  reserve  space  for  the  maximum  possible  peer  Link  IDs  */    static  linkID_t  sLID[NUM_CONNECTIONS]  =  {0};  static  uint8_t    sNumCurrentPeers  =  0;  /*  callback  handler  */  static  uint8_t  sCB(linkID_t);  /*  received  message  handler  */  static  void  processMessage(linkID_t,  uint8_t  *,  uint8_t);  /*  Frequency  Agility  helper  functions  */  static  void        checkChangeChannel(void);  static  void        changeChannel(void);  /*  work  loop  semaphores  */  static  volatile  uint8_t  sPeerFrameSem  =  0;  static  volatile  uint8_t  sJoinSem  =  0;  static  volatile  uint8_t  sSelfMeasureSem  =  0;  #ifdef  FREQUENCY_AGILITY    /*  BEGIN  interference  detection  support  */    #define  INTERFERNCE_THRESHOLD_DBM  (-­‐70)  #define  SSIZE        25  #define  IN_A_ROW    3  static  int8_t    sSample[SSIZE];  

Page 10: Project Report wireless sensor Network

  10  

static  uint8_t  sChannel  =  0;  #endif    /*  FREQUENCY_AGILITY  */  /*  blink  LEDs  when  channel  changes...  */  static  volatile  uint8_t  sBlinky  =  0;  //data  for  terminal  output  const  char  splash[]    volatile  int  *  tempOffset  =  (int  *)0x10F4;  __interrupt  void  ADC10_ISR(void);  __interrupt  void  Timer_A  (void);        /*    END  interference  detection  support      */  #define  SPIN_ABOUT_A_QUARTER_SECOND      NWK_DELAY(250)  void  main  (void)  {  bspIState_t  intState;  memset(sSample,  0x0,  sizeof(sSample));    BSP_Init();  BCSCTL3  |=  LFXT1S_2;                                            //  LFXT1  =  VLO  TACCTL0  =  CCIE;                                                      //  TACCR0  interrupt  enabled  TACCR0  =  12000;                                                      //  ~1  second  TACTL  =  TASSEL_1  +  MC_1;                                    //  ACLK,  upmode    COM_Init();    //Transmit  splash  screen  and  network  init  notification    TXString(  (char*)splash,  sizeof  splash);  TXString(  "\r\nInitializing  Network....",  26  );    SMPL_Init(sCB);    

Page 11: Project Report wireless sensor Network

  11  

//network  initialized  TXString(  "Done\r\n",  6);    /*  green  and  red  LEDs  on  solid  to  indicate  waiting  for  a  Join.  */    if  (!BSP_LED2_IS_ON())  {  toggleLED(2);  }  if  (!BSP_LED1_IS_ON())  {  toggleLED(1);  }    /*  main  work  loop  */    while  (1)  {    if  (sJoinSem  &&  (sNumCurrentPeers  <  NUM_CONNECTIONS))  {  /*  listen  for  a  new  connection  */  while  (1)  {  if  (SMPL_SUCCESS  ==  SMPL_LinkListen(&sLID[sNumCurrentPeers]))  {  break;  }    /*Implement  fail-­‐to-­‐link  policy  here.  otherwise,  listen  again.  */    }  sNumCurrentPeers++;  BSP_ENTER_CRITICAL_SECTION(intState);  sJoinSem-­‐-­‐;  

Page 12: Project Report wireless sensor Network

  12  

BSP_EXIT_CRITICAL_SECTION(intState);  }    //if  it  is  time  to  measure  our  own  temperature...  if(sSelfMeasureSem)  {  char  msg  [6];  char  addr[]  =  {"HUB0"};  char  rssi[]  =  {"000"};  int  degC,  volt;  volatile  long  temp;  int  results[2];    ADC10CTL1  =  INCH_10  +  ADC10DIV_4;          //  Temp  Sensor  ADC10CLK/5  ADC10CTL0  =  SREF_1  +  ADC10SHT_3  +  REFON  +  ADC10ON  +  ADC10IE  +  ADC10SR;  for(  degC  =  240;  degC  >  0;  degC-­‐-­‐  );    //  delay  to  allow  reference  to  settle  ADC10CTL0  |=  ENC  +  ADC10SC;                      //  Sampling  and  conversion  start  __bis_SR_register(CPUOFF  +  GIE);            //  LPM0  with  interrupts  enabled  results[0]  =  ADC10MEM;    ADC10CTL0  &=  ~ENC;    ADC10CTL1  =  INCH_11;                                    //  AVcc/2  ADC10CTL0  =  SREF_1  +  ADC10SHT_2  +  REFON  +  ADC10ON  +  ADC10IE  +  REF2_5V;  for(  degC  =  240;  degC  >  0;  degC-­‐-­‐  );    //  delay  to  allow  reference  to  settle  ADC10CTL0  |=  ENC  +  ADC10SC;                      //  Sampling  and  conversion  start  __bis_SR_register(CPUOFF  +  GIE);            //  LPM0  with  interrupts  enabled  results[1]  =  ADC10MEM;  ADC10CTL0  &=  ~ENC;  ADC10CTL0  &=  ~(REFON  +  ADC10ON);            //  turn  off  A/D  to  save  power    //oC  =  ((A10/1024)*1500mV)-­‐986mV)*1/3.55mV  =  A10*423/1024  -­‐  278  //the  temperature  is  transmitted  as  an  integer  where  32.1  =  321  //hence  4230  instead  of  423  

Page 13: Project Report wireless sensor Network

  13  

temp  =  results[0];  degC  =  (((temp  -­‐  673)  *  4230)  /  1024);  if(  (*tempOffset)  !=  0xFFFF  )  {  degC  +=  (*tempOffset);  }    temp  =  results[1];  volt  =  (temp*25)/512;    msg[0]  =  degC&0xFF;  msg[1]  =  (degC>>8)&0xFF;  msg[2]  =  volt;  transmitDataString(1,  addr,  rssi,  msg  );  BSP_TOGGLE_LED1();  sSelfMeasureSem  =  0;  }    /*  Runs  in  ISR  context.  Reading  the  frame  should  be  done  in  the  */  /*  application  thread  not  in  the  ISR  thread.  */  static  uint8_t  sCB(linkID_t  lid)  {  if  (lid)  {  sPeerFrameSem++;  sBlinky  =  0;  }  else  {  sJoinSem++;  }  /*  leave  frame  to  be  read  by  application.  */  return  0;  }  

Page 14: Project Report wireless sensor Network

  14  

static  void  processMessage(linkID_t  lid,  uint8_t  *msg,  uint8_t  len)  {  /*  do  something  useful  */  if  (len)  {  toggleLED(*msg);  }  return;  }  static  void  changeChannel(void)  {  #ifdef  FREQUENCY_AGILITY  freqEntry_t  freq;  if  (++sChannel  >=  NWK_FREQ_TBL_SIZE)  {  sChannel  =  0;  }  freq.logicalChan  =  sChannel;  SMPL_Ioctl(IOCTL_OBJ_FREQ,  IOCTL_ACT_SET,  &freq);  BSP_TURN_OFF_LED1();  BSP_TURN_OFF_LED2();  sBlinky  =  1;  #endif  return;  }    

 

 

 

 

 

Page 15: Project Report wireless sensor Network

  15  

END  Device-­‐  

The  second  part  is  END  device.  Hardware  circuit  of  both  devices  are  identical  but  they  

both  running  on  different  programs.  

 

 

 

                                     

 

 

           

Page 16: Project Report wireless sensor Network

  16  

Compiling  and  Loading  the  Access  Point  code-­‐   To  build  the  executable  for  the  Access  Point  you  start  by  selecting  the  Access  Point  tab  from  the  Workspace  panel  of  the  IAR  Embedded  Workbench  window.   (1). Select the Access Point Tab –

 2)  On  the  menu  bar  select  “Project”,  then  “Rebuild  All”.  This  will  recompile  the  project  and  prepare  the  programming  files.  

Page 17: Project Report wireless sensor Network

  17  

3) The next step is to load the new code into your little Access Point circuit board- To do this just plug the USB stick carrying the AP device into a USB port as before. Now select “Project” on the menu bar, then “Debug”. This will download the new program to the little circuit board and will start the debugger.

Page 18: Project Report wireless sensor Network

  18  

4). Since we are not interested in running the debugger, once the debugger starts we can just select “Debug” and “Stop Debugging” from the menu bar.

Now device is programmed and we can unplug the stick from the USB port.

 

Page 19: Project Report wireless sensor Network

  19  

Program  for  End  Device-­‐   EZ430-­‐RF2500  Temperature  Sensor  End  Device  //  Description:  This  is  the  End  Device  software  for  the  eZ430-­‐2500RF  Temperature  Sensing  //    #define  I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE  #include  "bsp.h"  #include  "mrfi.h"  #include  "nwk_types.h"  #include  "nwk_api.h"  #include  "bsp_leds.h"  #include  "bsp_buttons.h"  #include  "vlo_rand.h"  #ifndef  APP_AUTO_ACK  #error  ERROR:  Must  define  the  macro  APP_AUTO_ACK  for  this  application.  #endif  void  toggleLED(uint8_t);  static  void  linkTo(void);  static  linkID_t  sLinkID1  =  0;  #define  SPIN_ABOUT_A_SECOND      NWK_DELAY(1000)  #define  SPIN_ABOUT_A_QUARTER_SECOND      NWK_DELAY(250)    /*  How  many  times  to  try  a  Tx  and  miss  an  acknowledge  before  doing  a  scan  */    #define  MISSES_IN_A_ROW    2  void  createRandomAddress(void);    volatile  int  *  tempOffset  =  (int  *)0x10F4;  //  Temperature  offset  set  at  production  char  *  Flash_Addr  =  (char  *)0x10F0;                //  Initialize  radio  address  location  __interrupt  void  ADC10_ISR(void);  __interrupt  void  Timer_A  (void);  /*  work  loop  semaphores  */  static  volatile  uint8_t  sSelfMeasureSem  =  0;  void  main  (void)  {          addr_t  lAddr;            BSP_Init();      if(Flash_Addr[0]  ==  0xFF  &&  Flash_Addr[1]  ==  0xFF  &&    

Page 20: Project Report wireless sensor Network

  20  

         Flash_Addr[2]  ==  0xFF  &&  Flash_Addr[3]  ==  0xFF  )        {          createRandomAddress();  //  set  Random  device  address  at  initial  startup      }      lAddr.addr[0]  =  Flash_Addr[0];      lAddr.addr[1]  =  Flash_Addr[1];      lAddr.addr[2]  =  Flash_Addr[2];      lAddr.addr[3]  =  Flash_Addr[3];      SMPL_Ioctl(IOCTL_OBJ_ADDR,  IOCTL_ACT_SET,  &lAddr);        /*  Keep  trying  to  join  (a  side  effect  of  successful  initialization)  until  successful  .  Toggle  LEDS  to  indicate  that  joining  has  not  occurred*/  

     while  (SMPL_SUCCESS  !=  SMPL_Init(0))      {          toggleLED(1);          toggleLED(2);          SPIN_ABOUT_A_SECOND;      }        /*  LEDs  on  solid  to  indicate  successful  join.  */        if  (!BSP_LED2_IS_ON())      {          toggleLED(2);      }      if  (!BSP_LED1_IS_ON())      {          toggleLED(1);      }      BCSCTL3  |=  LFXT1S_2;                                            //  LFXT1  =  VLO      TACCTL0  =  CCIE;                                                      //  TACCR0  interrupt  enabled      TACCR0  =  12000;                                                      //  ~  1  sec      TACTL  =  TASSEL_1  +  MC_1;                                    //  ACLK,  upmode                /*  Unconditional  link  to  AP  which  is  listening  due  to  successful  join.*/      linkTo();      while  (1)  ;  }  static  void  linkTo()  

Page 21: Project Report wireless sensor Network

  21  

{      uint8_t          msg[3];      uint8_t          misses,  done;      /*  Keep  trying  to  link...  */      while  (SMPL_SUCCESS  !=  SMPL_Link(&sLinkID1))      {          toggleLED(1);          toggleLED(2);          SPIN_ABOUT_A_SECOND;      }      /*  Turn  off  LEDs.  */      if  (BSP_LED2_IS_ON())      {          toggleLED(2);      }      if  (BSP_LED1_IS_ON())      {          toggleLED(1);      }      SMPL_Ioctl(  IOCTL_OBJ_RADIO,  IOCTL_ACT_RADIO_SLEEP,  0);      while  (1)      {              __bis_SR_register(LPM3_bits+GIE);    //  LPM3  with  interrupts  enabled                  if  (sSelfMeasureSem)  {              volatile  long  temp;              int  degC,  volt;              int  results[2];                          uint8_t            noAck;              smplStatus_t  rc;                /*  get  radio  ready...awakens  in  idle  state  */                SMPL_Ioctl(  IOCTL_OBJ_RADIO,  IOCTL_ACT_RADIO_AWAKE,  0);                                        ADC10CTL1  =  INCH_10  +  ADC10DIV_4;              //  Temp  Sensor  ADC10CLK/5              ADC10CTL0  =  SREF_1  +  ADC10SHT_3  +  REFON  +  ADC10ON  +  ADC10IE  +  ADC10SR;              for(  degC  =  240;  degC  >  0;  degC-­‐-­‐  );        //  delay  to  allow  reference  to  settle              ADC10CTL0  |=  ENC  +  ADC10SC;                          //  Sampling  and  conversion  start              __bis_SR_register(CPUOFF  +  GIE);                //  LPM0  with  interrupts  enabled  

Page 22: Project Report wireless sensor Network

  22  

           results[0]  =  ADC10MEM;                      ADC10CTL0  &=  ~ENC;                      ADC10CTL1  =  INCH_11;                                          //  AVcc/2              ADC10CTL0  =  SREF_1  +  ADC10SHT_2  +  REFON  +  ADC10ON  +  ADC10IE  +  REF2_5V;              for(  degC  =  240;  degC  >  0;  degC-­‐-­‐  );        //  delay  to  allow  reference  to  settle              ADC10CTL0  |=  ENC  +  ADC10SC;                          //  Sampling  and  conversion  start              __bis_SR_register(CPUOFF  +  GIE);                //  LPM0  with  interrupts  enabled              results[1]  =  ADC10MEM;              ADC10CTL0  &=  ~ENC;              ADC10CTL0  &=  ~(REFON  +  ADC10ON);                //  turn  off  A/D  to  save  power                        //  oC  =  ((A10/1024)*1500mV)-­‐986mV)*1/3.55mV  =  A10*423/1024  -­‐  278              //  the  temperature  is  transmitted  as  an  integer  where  32.1  =  321              //  hence  4230  instead  of  423              temp  =  results[0];              degC  =  ((temp  -­‐  673)  *  4230)  /  1024;              if(  (*tempOffset)  !=  0xFFFF  )              {                  degC  +=  (*tempOffset);                }              /*  message  format,    UB  =  upper  Byte,  LB  =  lower  Byte              -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐              |degC  LB  |  degC  UB  |    volt  LB  |              -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐                    0                  1                    2              */                        temp  =  results[1];              volt  =  (temp*25)/512;              msg[0]  =  degC&0xFF;              msg[1]  =  (degC>>8)&0xFF;              msg[2]  =  volt;                            done  =  0;              while  (!done)              {                  noAck  =  0;                  /*  Try  sending  message  MISSES_IN_A_ROW  times  looking  for  ack  */                  for  (misses=0;  misses  <  MISSES_IN_A_ROW;  ++misses)                  {  

Page 23: Project Report wireless sensor Network

  23  

                   if  (SMPL_SUCCESS  ==  (rc=SMPL_SendOpt(sLinkID1,  msg,  sizeof(msg),  SMPL_TXOPTION_ACKREQ)))                      {    /*  Message  acked.  We're  done.  Toggle  LED  1  to  indicate  ack  received.  */                            toggleLED(1);    //  Toggle  On  LED1                          __delay_cycles(2000);                          toggleLED(1);                          break;                      }                      if  (SMPL_NO_ACK  ==  rc)                      {    /*  Count  ack  failures.  Could  also  fail  because  of  CCA  and  we  don't  want  to  scan  in  this  case.    */                          noAck++;                      }                  }                  if  (MISSES_IN_A_ROW  ==  noAck)                  {                      /*  Message  not  acked.  Toggle  LED  2.  */                      toggleLED(2);    //  Turn  On  LED2                      __delay_cycles(2000);                      toggleLED(2);    #ifdef  FREQUENCY_AGILITY    /*  Assume  we're  on  the  wrong  channel  so  look  for  channel  by  using  the  Ping  to  initiate  a  scan  when  it  gets  no  reply.  With  a  successful  ping  try  sending  the  message  again.  Otherwise,    for  any  error  we  get  we  will  wait  until  the  next  button  press  to  try  again.  */                      if  (SMPL_SUCCESS  !=  SMPL_Ping(sLinkID1))                      {                          done  =  1;                      }  #else                      done  =  1;  #endif    /*  FREQUENCY_AGILITY  */                  }                  else  

Page 24: Project Report wireless sensor Network

  24  

               {                      /*  Got  the  ack  or  we  don't  care.  We're  done.  */                      done  =  1;                  }              }      /*  radio  back  to  sleep  */                SMPL_Ioctl(  IOCTL_OBJ_RADIO,  IOCTL_ACT_RADIO_SLEEP,  0);          }      }  }  void  toggleLED(uint8_t  which)  {      if  (1  ==  which)      {          BSP_TOGGLE_LED1();      }      else  if  (2  ==  which)      {          BSP_TOGGLE_LED2();      }      return;  }  void  createRandomAddress()  {      unsigned  int  rand,  rand2;      do      {          rand  =  TI_getRandomIntegerFromVLO();        //  first  byte  can  not  be  0x00  of  0xFF      }      while(  (rand  &  0xFF00)==0xFF00  ||  (rand  &  0xFF00)==0x0000  );      rand2  =  TI_getRandomIntegerFromVLO();            BCSCTL1  =  CALBC1_1MHZ;                                        //  Set  DCO  to  1MHz      DCOCTL  =  CALDCO_1MHZ;      FCTL2  =  FWKEY  +  FSSEL0  +  FN1;                          //  MCLK/3  for  Flash  Timing  Generator      FCTL3  =  FWKEY  +  LOCKA;                                        //  Clear  LOCK  &  LOCKA  bits      FCTL1  =  FWKEY  +  WRT;                                            //  Set  WRT  bit  for  write  operation            Flash_Addr[0]=(rand>>8)  &  0xFF;  

Page 25: Project Report wireless sensor Network

  25  

   Flash_Addr[1]=rand  &  0xFF;      Flash_Addr[2]=(rand2>>8)  &  0xFF;        Flash_Addr[3]=rand2  &  0xFF;              #pragma  vector=ADC10_VECTOR  __interrupt  void  ADC10_ISR(void)  {      __bic_SR_register_on_exit(CPUOFF);                //  Clear  CPUOFF  bit  from  0(SR)  }    /*  Timer  A0  interrupt  service  routine*/    #pragma  vector=TIMERA0_VECTOR  __interrupt  void  Timer_A  (void)  {      sSelfMeasureSem  =  1;          __bic_SR_register_on_exit(LPM3_bits);                //  Clear  LPM3  bit  from  0(SR)    }   Compiling and Loading the End Device code- The  process  for  building  the  executable  for  the  End  Device  is  identical  to  the  process  for  the  Access  Point,  the  only  difference  being  that  you  start  by  selecting  the  “End  Device”  tab.      

   

Page 26: Project Report wireless sensor Network

  26  

All  of  the  other  steps  are  identical,  except  we  need  to  plug  a  different  little  circuit  board  into  the  USB  stick  before  doing  the  programming  step,  otherwise  we  will  just  end  up  reprogramming  the  Access  Point.  In  other  words,  we  will  need  to  open  up  the  USB  stick  and  remove  the  AP  circuit  board  and  then  attach  the  ED  circuit  board  to  the  USB  programmer.  

 

     

Temperature  Sensors  Monitoring  Portal-­‐        

eZ430-­‐RF2500  is  preloaded  with  a  wireless  temperature  sensor  network  firmware  and  can  be  re-­‐programmed  at  any  time.  This  network  consists  of  an  Access  Point  that  measures  its  own  temperature  and  also  wirelessly  receives  temperature  measurements  from  End  Devices.  

  End  Devices  measure  their  temperature  once  per  second  and  then  enter  a  low-­‐

power  mode  to  reduce  battery  usage.  The  Access  Point  transmits  all  measured  data  to  the  PC  through  the  UART  backchannel.  The  included  PC  Sensor  Monitor  Visualizer  provides  a  demonstration  of  the  eZ430-­‐RF2500  using  the  Simplicity  protocol  across  a  star  network.  In  the  PC  Sensor  Monitor  Visualizer,  the  center  node  is  the  Access  Point  and  the  attached  bubbles  are  the  End  Devices.  

Page 27: Project Report wireless sensor Network

  27  

     

The  PC  application  displays  the  temperature  of  both  the  End  Devices  and  Access  Point.  Additionally,  the  PC  application  is  capable  of  simulating  distance  from  its  access  point  when  the  End  Devices  are  moved  .The  number  of  End  Devices  can  be  expanded  by  adding  more  target  boards  in  the  star  network.  

   

             

Page 28: Project Report wireless sensor Network

  28  

Wireless  sensor  Network  Diagram-­‐          

     

 

 

 

 

Page 29: Project Report wireless sensor Network

  29  

Data  Acquisition  system  for  wireless  sensor-­‐  

 

For  data  acquisitions  we  used  real  term  application  .The  real  term  is  a  terminal  program  specially  designed  for  capturing,  controlling  and  debugging  binary  and  other  difficult  data  streams.  It  is  far  better  for  debugging  commas  than  Hyper-­‐terminal.  It  has  no  support  for  dialing  modems.      

 

 

 

Page 30: Project Report wireless sensor Network

  30  

Process  to  configure  Real  Term  application-­‐  

 

1. Disconnect  all  of  the  ED’s  from  their  battery  packs  so  that  only  the  AP  is  left  

active.  

2. Close  the  Sensor  Monitor  window.  

3. The  AP  looks  like  a  simple  serial  port  device  to  your  computer.  Every  time  it  

blinks,  the  AP  is  actually  attempting  to  send  data  to  your  PC.    

4. Start  up  Real-­‐term,  which  is  a  terminal  emulator  program  select  the  Port  tab,  then  

the  Port  dropdown  menu,  and  select  the  highest  numbered  serial  port  you  see  

5. Now  open  the  port  by  clicking  on  the  “Open”  button  twice.  You  should  see  a  new  

line  of  data  appearing  every  second  or  so.  

 

 

Page 31: Project Report wireless sensor Network

  31  

Representation  of  Sensors  data-­‐  

In  Real  term  serial  capture  program  Every  line  of  data  represents  the  measurements  

made  by  the  AP  of  its  own  temperature  and  operating  voltage:  $HUB0,  93.2F,3.5,000,N#  

 

 This  is  the  temperature  information  the  Sensor  Monitor  program  displaying  in  the  

image.  If  we  power  up  one  of  the  End  devices  we  can  see  data  appearing  in  the  terminal  

program  window  at  about  twice  the  rate  as  before.  This  is  because  the  Access  point  is  

now  receiving  data  from  the  End  devices  every  second  or  so,  and  it  forwards  this  to  the  

PC  in  addition  to  its  own  information.  

Power  up  several  more  End  devices  and  see  what  changes  in  the  terminal  window.  

The  third  number  in  the  lines  from  the  ED  (057  or  058  in  the  image  above)  is  the  

signal  strength  of  the  End  devices  radio  transmission  as  measured  by  the  Access  point.  

 

 

Page 32: Project Report wireless sensor Network

  32  

Customized  program  for  Data  Acquisition  (End  Device)  –  

         *  BEGHDR  *  NAME:                void  transmit_time_delay(void)  *  DESCRIPTION:  Sets  timer  to  transmit  time  based  on  timer_state  *  INPUTS:            void  *  PROCESSING:    Sets  timer  to  transmit  time,  for  2  min  and  4  min  transmit  times  *                            loop  number  of  30  sec  times  to  make  2  min  and  4  min.  *  OUTPUTS:          void  **************************************************************  void  transmit_time_delay(void)  {      volatile  unsigned  int  i  =  0;      in_delay  =  1;      switch  (timer_state)      {          case  timer_state_1:                                          //  Timer  State  ==  1;  5  Secs              delay(sec5);              in_delay  =  0;              battery_full_timer  +=  sec5;              break;          case  timer_state_2:                                          //  Timer  State  ==  2;  10  Secs              delay(sec10);              in_delay  =  0;              battery_full_timer  +=  sec10;              break;              case  timer_state_3:                                          //  Timer  State  ==  3;  20  Secs              delay(sec20);              in_delay  =  0;              battery_full_timer  +=  sec20;              break;        case  timer_state_4:                                          //  Timer  State  ==  4;  40  Secs              delay(sec40);              in_delay  =  0;  

Page 33: Project Report wireless sensor Network

  33  

           battery_full_timer  +=  sec40;              break;              case  timer_state_5:                                          //  Timer  State  ==  5;  2  mins              while((i++  <  4)  &&  (timer_state  ==  timer_state_5))              {                  delay(sec30_2);                  in_delay  =  0;                  battery_full_timer  +=  sec30_2;              }              break;              case  timer_state_6:                                          //  Timer  State  ==  6;  4  mins              while((i++  <  8)  &&  (timer_state  ==  timer_state_6))              {                  delay(sec30_4);                  in_delay  =  0;                  battery_full_timer  +=  sec30_4;              }              break;          default:              break;      }  }//  void  transmit_time_delay(void)  

 

 

 

Initial  steps  of  project  based  on  temperature  analyzing  and  monitoring  using  radio  

frequency  sensor.  This  range  is  limited  in  particular  area  so,  we  are  looking  forward  for  

IP  Address  based  temperature  monitoring  and  wireless  data  acquisition.  

This  project  could  play  a  substantial  part  in  reducing  carbon  emission  not  only  for  RIT,  

but  for  the  community  in  general.  

Page 34: Project Report wireless sensor Network

  34  

 

References-­‐  

 

 

Carl  Lundgren  Professor  

Manufacturing  &  Mech.  Eng.  Tech./Packaging  Science  

Antonio  Mondragon,  Ph.D.  Assistant  Professor  

http://www.iar.com/en/Products/IAR-­‐Embedded-­‐Workbench/  

http://realterm.sourceforge.net/  

www.hep.princeton.edu/~marlow/rrs/Guides/Workbench.pdf  

http://www.ti.com/tool/ez430-­‐rf2500-­‐seh  

http://www.ti.com/tool/EZ430-­‐RF2500T  

http://www.arduino.cc/cgi-­‐bin/yabb2/YaBB.pl?num=1289334133  

http://en.wikipedia.org/wiki/Wireless_sensor_network