0% found this document useful (0 votes)
12 views

Hy439 Sensor Nets Part2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Hy439 Sensor Nets Part2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Introduction to Wireless Sensor

Networks:
Networking Aspects
Nancy Panousopoulou
Electrical and Computer Engineer, PhD
Signal Processing Lab, ICS-FORTH
[email protected]

8.04.2014, 10.04.2014
sensor processing, transceiver
(transducer, measuring a storage (connection to the outer-world,
e.g. other sensor nodes, or data
physical phenomenon e.g. (communication with sensor,
heat, light, motion, vibration, collectors --sinks)

Outline
data acquisition, and
and sound) preprocessing, buffers handling,
etc)

• Part 1: Applications, Standards and Protocols power unit


(battery based – limited lifetime!)

• Introduction & Reasoning of Existence

• Sensing, Processing, and Networking Aspects

• Standards, Topologies & Protocols

• Part 2: WSN Programming

• WSN Core and types of nodes

• Real-time Operating Systems

• Examples & Hands on Session


WSN Core
Typical State Machine of a Sensor Node

Standby / Wake-up(SENSOR)
sleep sensing

Data Ready
(SENSE)
Network Ready Sensor Ready
(DONE) (PROCESS)

Network
Ready Network Ready
Networking (PROCESS) processing
(COMMUNE)

Data Ready(SEND)
Family TRX μProcessor Memory On-board Sensors Expandability Notes & Application areas
TELOSB TI [email protected] TI msp430-F1 (16-bit) 10KB RAM, Temperature, 10 GIOs, USB programming interface Open platform.
(functional PHY, 48KB Flash Humidity, Light Environmental and health structural monitoring. PoC research
MAC compatible) projects

Open source software support – Active.


Mica2 TI 802.15.4@868MHz ATMEL AVR 128L (16-bit) 4KB - Dedicated environmental sensor board. One of the oldest platforms.
(functional PHY, RAM/48 KB 51-pin expansion, RS232. Environmental and health structural monitoring. PoC research
compatible MAC) Flash projects
Open source software support – Active (?).
MicaZ TI [email protected] ATMEL AVR 128 (16-bit) 4KB - Dedicated environmental sensor board Environmental and health structural monitoring. PoC research
(functional PHY, RAM/48 KB 51-pin expansion, RS232. projects
MAC compatible) Flash Open source software support – Active (?).
Dipole Antenna
IRIS ATMEL [email protected] ATMEL AVR 1281 8KB - Dedicated environmental sensor board. Environmental and health structural monitoring. PoC research
(functional PHY, RAM/48 KB 51-pin expansion. projects
MAC compatible) Flash Open source software support – Active.
Dipole Antenna
Shimmer TI [email protected] TI msp430-F1 (16-bit) 10 KB RAM, 3-axis Expandability for Accelerometers and ECG, Research platform with commercial support. Excellent support
(functional PHY, 48 KB Flash, accelerometer, EMG. (open source tools & customized applications).
MAC compatible) 2GB μSD Tilt & vibration USB mother board. Healthcare and Sports projects (wearable computing)
Nordic BT Active and expanding.
(fully functional) Rechargeable battery (up to 8hours in fully functional mode)
SUNSPOT TI [email protected] ATMEL ARM (32-bit) 1 MB RAM, 3-axis USB. 4 GIOs. Open platform.
(functional PHY, 8 MB Flash accelerometer, 3- JVM (very easy to program). Emulator is also available.
MAC compatible) color light. Fancy platform with demos for audience with no related
background. Active. For hobbyists 
Built in Li Battery
Zolertia Z1 TI [email protected] TI msp430-F2 8K RAM, 3-axis 52-pin expansion board. All WSN-related. One of the latest platforms.
(functional PHY, 92KB Flash accelerometer, Open source community support & Allows the option for a dipole antenna.
MAC compatible) temperature commercial support (excellent Wiki)
XM1000 TI [email protected] TI msp430-F2 8K RAM, Temperature, 10 GIOs, USB programming interface from a family of open platforms….
(functional PHY, 116 Flash, Humidity, Light SMA connection (dipole antenna)…
MAC compatible) 1MB All WSN-related, perhaps not for healthcare (bulky size and
External design).
Flash Can last up to 3 weeks on low data rate (per minute).

The WSN Core – technologies and platforms…[1-6]


The WSN Core – technologies and platforms…[1-6](cont’)
Family TRX μProcessor Memory On-board Sensors Expandability, Usability & Support Notes & Application areas

Firefly ATMEL ATMega128RFA1 Research platform (CMU).


Dedicated environmental sensor board (inc.
(SoC) [email protected] Not as popular as
8 KB RAM, audio, barometric pressure, PIR sensor,
(functional PHY, - other platforms. (?)
128 KB Flash liquid / relay switch).
MAC compatible)
+ GIOs

WiSMote TI [email protected] TI msp430-F5 16KB RAM, 3-axis 8 Analog, 16 GIO, mini USB Optional support for Power-Line Communications and RS-485
(functional PHY, 128 Flash accelerometer, (candidate for homes automation and industrial monitoring.)
MAC compatible) temperature, light. Research, open platform.
2nd generation
Xbee Digi 868 / 2.4GHz Needs - Serial communication (to μController) or Provide wireless end-point connectivity to devices -> plug-
(SoC) (mother host SCB (arduino, rasbery etc) and-play.
board) AT Commands for accessing the board.
OTAP.
802.1.5.4 on HW
WaspMote xBee-15.4. / ZigBee ATMEL AVR 1281 8 KB RAM, 3-axis Analog, Digital, USB, I2C Built in a torrent style – highly customizable w.r.t. the
WiFi 128 KB accelerometer, application needs.
BT 2.1.0 (BR / EDR) Flash, temperature. GPS optional.
3G 2GB μSD Commercial product – for commercial and very applied
NFC projects.
OTAP
Jennic / NXP Jennic 2.4GHZ (SoC) 128KB - Analog, Digital, ADC, SPI, Digital audio Closed platform.
32-bit μProcessor (ATMEL ?) RAM, 128 interface, UART Proprietary protocol stack – ZigBee / 6LoWPAN
PHY functional. KB ROM Pure commercial platform. Plug-and-play…
support for MAC (HW MAC Accelerator)
WSN Core

What we use…
Product
Name Extras Notes:
Not advisable for industrial
Indoors RF range: ~30 environments due to antenna. SMA
m (without Line-of- connector / Dipole antenna is not
XM1000 Sight). supported.

Similar as XM1000, Advisable for industrial environments,


CM5000- less powerfull. 5dBi due to antenna option. Network
SMA dipole antenna compatible to XM1000
WSN Core
When selecting motes for your applications…

• One size doesn’t fit them all.

• Support by company and open source community

• Power consumption

• Interoperability, Accessibility and tools (μProcessor toolchains, etc)

• Antenna design and antenna performance – standard-compliance &/ implementation is


not panacea to RF problems….
WSN Programming

• Motes selection ↔ Programming environment.

• Open source & Research platforms: Linux-alike environments


• Plug-and-play and closed platforms: wide range of tools.

• When programming a mote → programming its μProcessor to:


• access the peripheral devices (transceiver, leds, sensors etc)
• handle, store, modify the acquired information.
WSN Programming

Direct μProcessor programming Real time Operating Systems

Low-level / Embedded C & Assembly


A level of abstraction between the programmer
Hardware specific
and the hardware platform
Faster (simplified applications & experienced
HW Interoperability of WSN application
programmer)
Allows better control on the platform
Not suitable for sophisticated applications &
Suitable for more complex network topologies
network topologies
WSN Programming
[7-10]

APP

Transport

NWK

MAC

Hardware Abstraction Layer

TRX / PHY
Sensors (MAC)
μProcessor
Other (e.g.
Memory battery monitor,
GIOs,etc)
WSN Programming

First Release 1999 2005

Supported Platforms (in official 17 26


distributions)
Community Support & Forums Yes Yes

Programming Language nesC C

Single / Multiple Thread Single (multithread is optional) Single (multithread – explicitly defined library)
Structure Component-based Protothreads

Simulator / Emulator TOSSIM (python) Cooja / MSPSIm Emulator (java)

OTAP Yes Yes

Protocol Stack (802.15.4) MAC (not fully supported) (802.15.4) MAC (not fully supported)
Collection Tree Radio Duty Cycle & MAC
6LoWPAN RIME / uIP
6LoWPAN
Great flexibility in generating highly customizable protocol With default distribution: RIME or 6LoWPAN (modifiable)
stack

Interfacing with host (Serial Specific format (ActiveMessageC) Flexible


Communication) (but provides tools s.a. SLIP)

Documentation*  

Debugging experience*            
WSN Programming

• Component-based architecture, implementing one single stack


• Event-based, non-blocking design that allows intra-mote concurrency
• Written in NesC
• Structured, component-based C-like programming language

Programming Model:
• Components: encapsulate state and processing – use or provide
interfaces
• Interfaces list commands and events
• Configurations wire components together
WSN Programming

Two components are wired via interfaces.

Component A Component B
(user of I) (provider of I)

Interface I
e.g. Component
Application: Protocol Stack
Uses Send. (a chain of
calls the components):
sendMsg(msg) Provides Send.
command Implements the
sendMsg(msg)
Implements the Interface command
event sendDone
Send
Components are statically linked to kernel
(not reconfigurable after compiling)
The kernel is a chain of components interacting via interfaces GoTo- flow
WSN Programming
Sequential flow control while keeping
a single stack
[11-12]

Event-based → Invoking processes (non-blocking)

Using protothreads: a programming abstraction that User User


combines events and threads Application Application
Process #1 Process #N

Single stack and sequential flow control
Contiki Network Processes
Posting events or polling (Protocol Stack)

Contiki Core processes


(Platform Configuration)
WSN Programming

[29] Each process is essentially a protothread


WSN Programming

Hello-world in WSN programming.

A Blinking-Led Application
• Program a mote to blink a led every T seconds.
#include "Timer.h"

module BlinkC @safe()


{
uses interface Timer<TMilli> as Timer0;
uses interface Timer<TMilli> as Timer1;
uses interface Timer<TMilli> as Timer2;
uses interface Leds;
uses interface Boot;
}
configuration BlinkAppC implementation
{ {
} event void Boot.booted()
{
implementation call Timer0.startPeriodic( 250 );
{ call Timer1.startPeriodic( 500 );
components MainC, BlinkC, LedsC; call Timer2.startPeriodic( 1000 );
}
components new TimerMilliC() as Timer0;
components new TimerMilliC() as Timer1; event void Timer0.fired()
components new TimerMilliC() as Timer2; {
dbg("BlinkC", "Timer 0 fired @ %s.\n", sim_time_string());
call Leds.led0Toggle();
}
BlinkC -> MainC.Boot;
event void Timer1.fired()
{
BlinkC.Timer0 -> Timer0; dbg("BlinkC", "Timer 1 fired @ %s \n", sim_time_string());
BlinkC.Timer1 -> Timer1; call Leds.led1Toggle();
BlinkC.Timer2 -> Timer2; }
BlinkC.Leds -> LedsC; event void Timer2.fired()
} {
dbg("BlinkC", "Timer 2 fired @ %s.\n", sim_time_string());
call Leds.led2Toggle();
}
}
#include "contiki.h"
#include "dev/leds.h"

#include <stdio.h> /* For printf() */


/
*----------------------------------------------------------------
-----------*/
/* We declare the process */
PROCESS(blink_process, "LED blink process");
One main.c for each platform: Core & Network
processes /* We require the processes to be started automatically */
AUTOSTART_PROCESSES(&blink_process);
process_init();
/
process_start(&etimer_process, NULL);
*----------------------------------------------------------------
ctimer_init(); -----------*/
/* Implementation of the process */
init_platform(); PROCESS_THREAD(blink_process, ev, data)
{
set_rime_addr(); static struct etimer timer;
PROCESS_BEGIN();
//-----------------------low level api to phy--------------------------
cc2420_init(); while (1)
{ {
uint8_t longaddr[8]; /* we set the timer from here every time */
uint16_t shortaddr; etimer_set(&timer, CLOCK_CONF_SECOND);
shortaddr = (rimeaddr_node_addr.u8[0] << 8) + rimeaddr_node_addr.u8[1];
/* and wait until the event we receive is the one we're
memset(longaddr, 0, sizeof(longaddr));
rimeaddr_copy((rimeaddr_t *)&longaddr, &rimeaddr_node_addr);
waiting for */
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
} printf("Blink... (state %0.2X).\r\n", leds_get());
cc2420_set_channel(RF_CHANNEL); /* update the LEDs */
memcpy(&uip_lladdr.addr, ds2411_id, sizeof(uip_lladdr.addr)); leds_toggle(LEDS_GREEN);
}
queuebuf_init(); PROCESS_END();
NETSTACK_RDC.init(); }
NETSTACK_MAC.init(); /
WSN Programming
The communication layers in Contiki [29-31]

• The uIP TCP/IP stack


• Lightweight TCP/IP functionalities for low complexity μControllers
• A single network interface (IP, ICMP, UDP,TCP)
• Compliant to RFC but the Application layer is responsible for handling
retransmissions (reduce memory requirements)

• The Rime protocol stack


• A set of communication primitives (keeping pck headers and protocol stacks
separated)
• A pool of NWK protocols for ad-hoc networking
• Best-effort anonymous broadcast to reliable multihop flooding and tree protocols
WSN Programming
How does Rime work
• Rime is a software trick
• A stack of NWK layers

• Each layer is associated with a channel

• 2KB memory footprint

• Interoperability and ease in changing the protocol stack


WSN Programming
How does Rime work – Example

• The Collection Tree Protocol (CTP)


• Tree-based hop-by-hop reliable data collection
• Large-scale network (e.g. environmental or industrial monitoring)

• Reliable Unicast Bulk


• Event-driven data transmission of a large data volume
• Personal health-care
WSN Programming
Layer Description Channel Contribution to Rime
Header
Reliable
Broadcast Best-effort local 129 Sender ID Unicast Bulk Collect
area broadcast
Neighbor Periodic Neighbor 2 Receiver ID, Application
discovery Discovery Channel Reliable unicast
mechanism
Unicast Single-hop unicast 146 Receiver ID
to an identified
single-hop Stubborn unicast
neighbor
Neighbor
Stubborn Repeatedly sends a Receiver ID discovery
unicast packet until
unicast
cancelled by upper
layer
Reliable Single-hop reliable 144 Packet Type and Packet ID
Unicast unicast (ACKs and broadcast
retransmissions)
WSN Programming
• Cooja
• The Contiki emulator for running WSN applications.

• Very useful for debugging your codes – the same


code you test on cooja, the same you upload to your
mote

• Evaluating the network performance (?) – has very


simplifying models for radio propagation….
• Unit disk model: Edges are instantly configured according
to power attenuation w.r.t to distance & success ratio
(configurable)
• Directed graph radio medium: Considers preconfigured
edges, without checking the output power.
• Multipath ray tracer: Simulates reflection and diffraction
through homogeneous obstacles (considers that all
nodes have the same transmission power)
Outline
• Part 1: Applications, Standards and Protocols

• Introduction & Reasoning of Existence

• Sensing, Processing, and Networking Aspects

• Standards, Topologies & Protocols

• Part 2: WSN Programming

• WSN Core and types of nodes

• Real-time Operating Systems

• Examples & Hands on Session


Hands on Session
What we are going to do…
Hello
World

Sensing

Wireless
Sensing
Hands on Session
What we are going to use…in order to upload code to the motes

• FTDI drivers (for Windows machines only) – USB2Serial

• How the host computer reserves a mote:


• COM<No> (Windows – Device Manager)
• /dev/ttyUSB<No> (Linux) [cat /var/log/syslog]
• Make sure that you have access on device (for programming it)
chmod 777 /dev/ttyUSB0
• Serial dump: make TARGET=sky MOTES=/dev/ttyUSB0 login
Hands on Session at Cooja
• Cooja (for emulating the motes behavior)
Guidelines for running the codes at Cooja:

1. From your VM / Instant Contiki run the “cooja” application

2. Follow the instructions given at: http://www.contiki-os.org/start.html (step


3) for creating a new simulation
Select “sky” as the mote type
3. The result of the printf is shown at the “Mote Output” view
Hands on Session at Cooja
Hello

Hands on Session World

Sensing
Hello World  contiki/examples/hello-world
[Code structure & compile] Wireless
Sensing
#include "contiki.h"
Hello-world.c
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process"); /**Process definition**/
AUTOSTART_PROCESSES(&hello_world_process); /**Process Start**/
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data) /**Process implementation**/
{
PROCESS_BEGIN(); /**Always first**/
CONTIKI_PROJECT = hello-world
printf("Hello, world\n"); //process core all: $(CONTIKI_PROJECT)

PROCESS_END(); /**Always last**/


} CONTIKI = ../..
/*---------------------------------------------------------------------------*/ include $(CONTIKI)/Makefile.include
Hello

Hands on Session World

Hello World  contiki/examples/hello-world Sensing

[Code structure & compile]


Wireless
Sensing

Program:
1. Open command terminal.
2. cd contiki/examples/hello-world
3. make TARGET=<platform*> hello-world.upload (compile and program)

Serial Dump
1. At new tab (File/Open new tab).
2. make TARGET=sky MOTES=/dev/ttyUSB0 login

*sky/xm1000
Hello

Hands on Session World

Sensing
Hello World  contiki/examples/hello-world
[How to trigger a process] Wireless
Sensing

• How to wake up from a process

Keep on mind that:

Automatic variables not stored


across a blocking wait

When in doubt, use static local


variables
Hello

Hands on Session World

Sensing
Hello World  contiki/examples/hello-world
[How to trigger a process] Wireless
Sensing

• Timers

• Event timer (etimer) : Sends an


event when expired

• Callback timer (ctimer) : Calls a


function when expired – used by Rime
Hello

Hands on Session World

Sensing
Hello World  contiki/examples/hello-world
[How to trigger a process] Wireless
Sensing

From hello-world.c generate a new application (print-and-blink.c) that:


1. periodically (e.g. per second) prints a message.
2. when the message is printed a led toggles
#include “leds.h”
leds_toggle(LEDS_RED / LEDS_GREEN / LEDS_YELLOW)
macro for time: CLOCK_SECOND
/*---------------------------------------------------------------------------*/
PROCESS(print_and_blink_process, ”Print and blink process");
Hello
AUTOSTART_PROCESSES(&print_and_blink_process); World
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(print_and_blink_process, ev, data)
{ Sensing

static struct etimer et;


Wireless
PROCESS_BEGIN(); /**Always first**/ Sensing

while(1) {

etimer_set(&et, CLOCK_SECOND);

PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

printf(“Echo\n”);

leds_toggle(LEDS_GREEN);

PROCESS_END(); /**Always last**/


}
Hello

Hands on Session World

Sensing
Sensing  contiki/examples/hello-world
[Access a sensor]
Wireless
Sensing
• Sensor: supported by contiki (platform/dev/<platform>)

• const struct sensors_sensor


• @sky: sht11_sensor.value(type) --global
//type = SHT11_SENSOR_TEMP, SHT11_SENSOR_HUMIDITY

light_sensor.value(type) --global
//type = LIGHT_SENSOR_TOTAL_SOLAR, LIGHT_SENSOR_PHOTOSYNTHETIC

battery_sensor.value(type) –global
//type = 0

• ACTIVATE / DEACTIVE (<sensors_sensor>)


Hello

Hands on Session World

Sensing
Sensing  contiki/examples/hello-world
[Access a sensor]
Wireless
Sensing
From the print-and-blink, generate a new application (sense-and-blink.c) that:
1. Periodically sample one or more of the on-board sensors
#include "dev/light-sensor.h” / "dev/sht11-sensor.h” / "dev/battery-sensor.h”

SENSORS_ACTIVATE(<>)

[Sample…]

SENSORS_DEACTIVATE(<>)

2. When done prints the sampled value and toggles a led

Command for serial dump: make TARGET=sky MOTES=/dev/ttyUSB0 login


Hello
World

Hands on Session
1 process 2 processes Sensing

PROCESS(sense_process, "Sense process");


struct sensor_datamsg{ PROCESS(print_and_blink_process, "Print and blink process");
AUTOSTART_PROCESSES(&sense_process, &print_and_blink_process);
uint16_t temp; Wireless
uint16_t humm;
uint16_t batt; static struct sensor_datamsg msg; Sensing
static process_event_t event_data_ready;
}sensor_datamsg;
PROCESS_THREAD(sense_process, ev, data)
{
PROCESS_THREAD(sense_and_blink_process, ev, data)
{ PROCESS_BEGIN(); /**Always first**/
static struct etimer et;
static struct sensor_datamsg msg; SENSORS_ACTIVATE(sht11_sensor);
SENSORS_ACTIVATE(battery_sensor);
PROCESS_BEGIN(); /**Always first**/
while (1) {
SENSORS_ACTIVATE(sht11_sensor); …
SENSORS_ACTIVATE(battery_sensor); process_post(&print_and_blink_process,event_data_ready, &msg);

while (1) {
}
etimer_set(&et, CLOCK_SECOND); PROCESS_END(); /**Always last**/
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
msg.temp= sht11_sensor.value(SHT11_SENSOR_TEMP); /*---------------------------------------------------------------------------*/
msg.humm = sht11_sensor.value(SHT11_SENSOR_HUMIDITY); PROCESS_THREAD(print_and_blink_process, ev, data)
msg.batt = battery_sensor.value(0); {

printf("Sensor raw values: temperature:%d, humidity: %d, battery: %d\n", msg.temp, msg.humm, msg.batt); PROCESS_BEGIN(); /**Always first**/
leds_toggle(LEDS_GREEN);
while (1) {

PROCESS_YIELD_UNTIL(ev==event_data_ready);
} printf("Sensor raw values: temperature:%d, humidity: %d, battery: %d\n", msg.temp, msg.humm, msg.batt);
leds_toggle(LEDS_GREEN);
SENSORS_DEACTIVATE(sht11_sensor);
SENSORS_DEACTIVATE(battery_sensor); }
PROCESS_END(); /**Always last**/ PROCESS_END(); /**Always last**/
} }
Hello

Hands on Session World

Sensing
Wireless Sensing  contiki/examples/hello-world
[Access a sensor & trx] Wireless
Sensing

Communication:
• Each type of connection (rime / uIP / 6LoWPAN) defines a structure

• Each type of rime connection defines a struct for the callback function (rx
events).
Callback function has to have a specific definition…

• Each rime-based connection is associated with a predefined channel (>128)


Hello

Hands on Session World

Wireless Sensing  contiki/examples/hello-world Sensing

[Access a sensor & trx] Wireless


Sensing

@ rime:
• packetbuf module for packet buffer management
• Struct rimeaddr_t for rime addressing…
typedef union {
unsigned char u8[RIMEADDR_SIZE]; //=2
} rimeaddr_t; Unless otherwise
specified,
IP=
@ uip: 176.12.RIME_ADDR[
• uipbuf module for packet buffer management 0]. RIME_ADDR[1]

• Struct ipaddr_t
Hello

Hands on Session World

Sensing
Wireless Sensing  contiki/examples/hello-world
[Access a sensor & trx]
From the sense-and-tx, generate a new application (sense-and-trx.c) that: Wireless
Sensing
1. Periodically samples from on-board temperature sensor
2. When done broadcast the value
3. Upon the reception of a incoming packet, print its contents and the source node id

#include net/rime.h
static const struct broadcast_callbacks broadcast_call = {broadcast_recv}; -- visible outside process
Defined as: static void broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)

static struct broadcast_conn broadcast; -- visible outside process

Inside process:
broadcast_open(&broadcast, 129, &broadcast_call); --connection -- 129: the broadcast rime channel
packetbuf_copyfrom(const void *data, data length); --form tx buffer
broadcast_send(&broadcast); -- send to connection
Hands on Session
PROCESS_THREAD(send_and_blink_process, ev, data)
{

static uint8_t data2send[sizeof(sensor_datamsg)];

PROCESS_EXITHANDLER(broadcast_close(&broadcast);)

PROCESS_BEGIN(); /**Always first**/

broadcast_open(&broadcast, 129, &broadcast_call);

while (1) {
Receive
PROCESS_YIELD_UNTIL(ev==event_data_ready); static void
broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
{
data2send[0] = msg.temp & 255;//lsb
data2send[1] = msg.temp >> 8;//msb uint8_t *appdata;
int i;
data2send[2] = msg.humm & 255;
data2send[3] = msg.humm >> 8; appdata = (uint8_t *)packetbuf_dataptr();

data2send[4] = msg.batt & 255; printf("Data recv:[");


data2send[5] = msg.batt >> 8; for (i=0;i<packetbuf_datalen();i++)
Send packetbuf_copyfrom(data2send,sizeof(sensor_datamsg));
{
printf("%u ",appdata[i]);
broadcast_send(&broadcast);
//printf("Sensor raw values: temperature:%d, humidity: %d, battery: %d\n", msg.temp, msg.humm, msg.batt); }
leds_toggle(LEDS_GREEN);

} //this is the id of the sender (as defined in compile time).


PROCESS_END(); /**Always last**/ printf("], from: %d.%d\n",from->u8[0], from->u8[1]);
} printf("\n");

}
References
1. http://en.wikipedia.org/wiki/List_of_wireless_sensor_nodes
2. www.advanticsys.com
3. www.shimmersensing.com
4. www.jennic.com
5. http://www.libelium.com/products/waspmote/overview/
6. www.digi.com/xbee
7. http://www.nanork.org/projects/nanork/wiki
8. http://mantisos.org/index/tiki-index.php.html
9. www.tinyos.net
10. www.contiki-os.org
11. http://www.ee.kth.se/~mikaelj/wsn_course.shtml
12. http://contiki.sourceforge.net/docs/2.6/index.html

You might also like