Hy439 Sensor Nets Part2
Hy439 Sensor Nets Part2
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)
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
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.
• Power consumption
APP
Transport
NWK
MAC
TRX / PHY
Sensors (MAC)
μProcessor
Other (e.g.
Memory battery monitor,
GIOs,etc)
WSN Programming
Single / Multiple Thread Single (multithread is optional) Single (multithread – explicitly defined library)
Structure Component-based Protothreads
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
Documentation*
Debugging experience*
WSN Programming
Programming Model:
• Components: encapsulate state and processing – use or provide
interfaces
• Interfaces list commands and events
• Configurations wire components together
WSN Programming
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]
A Blinking-Led Application
• Program a mote to blink a led every T seconds.
#include "Timer.h"
Sensing
Wireless
Sensing
Hands on Session
What we are going to use…in order to upload code to the motes
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)
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
Sensing
Hello World contiki/examples/hello-world
[How to trigger a process] Wireless
Sensing
Sensing
Hello World contiki/examples/hello-world
[How to trigger a process] Wireless
Sensing
• Timers
Sensing
Hello World contiki/examples/hello-world
[How to trigger a process] Wireless
Sensing
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
printf(“Echo\n”);
leds_toggle(LEDS_GREEN);
Sensing
Sensing contiki/examples/hello-world
[Access a sensor]
Wireless
Sensing
• Sensor: supported by contiki (platform/dev/<platform>)
light_sensor.value(type) --global
//type = LIGHT_SENSOR_TOTAL_SOLAR, LIGHT_SENSOR_PHOTOSYNTHETIC
battery_sensor.value(type) –global
//type = 0
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(<>)
Hands on Session
1 process 2 processes Sensing
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
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…
@ 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
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)
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)
{
PROCESS_EXITHANDLER(broadcast_close(&broadcast);)
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();
}
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