Post on 20-Dec-2015
Tutorial
How to use sensors
Reporter: Jensen Vinson
2/42
Outline Equipment Install TinyOS Programming Concept Install Sensor Create A Sensor Network Example--Light Example--Accelerometer
3/42
Equipment OS: Linux/Windows (cygwin), TinyOS 2.x PC: USB serial port Sensor: TAROKO
5/42
Install TinyOSStep2:Windows only. Install Cygwin --download cygwin-files.zip and unzip it under
some local folder say c:/cygwin-files and start the setup
http://www.cygwin.com/
6/42
Install TinyOSStep2:Windows only. Install Cygwin
7/42
Install TinyOSStep2:Windows only. Install Cygwin
then, complete the rest of installation process
8/42
Install TinyOSStep3: Install native compilers
Command: rpm –ivh –ignoress <file name>
9/42
Install TinyOSStep4: Install the nesC compiler & TinyOS toolch
ain
10/42
Install TinyOSStep5: Install the TinyOS source tree
11/42
Install TinyOSStep5: Install the TinyOS source tree --Configure the environment in the end of the fil
e C:\cygwin\home\Administrator\.bash_profile
12/42
Install TinyOSStep6: Install the Graphviz visualization tool--download and install from the website below : http://webs.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/graphviz-1.10.ex
e
13/42
Install TinyOS Check if setup is correct using this command
# tos-check-env
14/42
Programming Concept xx.h
Header file xxAppC.nc
Configuration file xxC.nc
Module file
15/42
Install SensorStep1: motelist
16/42
Install SensorStep2: install sensor● go to the directory of the file you want to instal
l● # make telosb install,<logic_ID> bsl,<COM port-1>PS: In linux, the COM port needn’t minus 1
17/42
Create a sensor network One is the BaseStation (logic_ID=0) which co
llects data and transmits to PC Others are for sensing data with IEEE 802.15.
4
BaseStation
Sensor node
Sensor node
USB serial
PC
data
data data
N_1
N_2
N_0
18/42
Example– Sensing lightStep1:Base on Oscilloscope in tinyos2.xStep2:Some main files below
Oscilloscope.h
19/42
Example (Cont.)OscilloscopeAppC.nc
// configure components
// creates connection between components and modules
20/42
Example (Cont.)OscilloscopeC.nc
// define the interfaces it needs
21/42
// green light// yellow light// red light
22/42
23/42
24/42
25/42
26/42
Sensing data collection
INPUT_CHANNEL_A4 LightINPUT_CHANNEL_A5 Temperature/Humidity
C:\cygwin\opt\tinyos-2.x\tos\chips\msp430\sensors
27/42
Example—Light (Cont.)Step3:Install BaseStation (N_0)
# cd /opt/tinyos-2.x/apps/BaseStation # make telosb install,0 bsl,<COM port-1>
Step4: Enable forwarder on BaseStation # java net.tinyos.sf.SerialForwarder –comm serial
@<COM port>:telosb&
28/42
Example—Light (Cont.)Step5:Install Oscilloscope (N_1, N_2)
# cd /opt/tinyos-2.x/apps/Oscilloscope # make telosb install,<logic_ID> bsl,<COM port-1>
Step6: Sensing data with GUI on BaseStation # cd /opt/tinyos-2.x/apps/Oscilloscope/java # make # ./run
29/42
how to interpret the sensor readings
30/42
Example--AccelerometerStep1:Base on Oscilloscope in tinyos2.xStep2:Enable X,Y,Z axes
Create TarokoAccel0C.nc、 TarokoAccel0P.nc for X axis Create TarokoAccel1C.nc、 TarokoAccel1P.nc for Y axis Create TarokoAccel2C.nc、 TarokoAccel2P.nc for Z axis
INPUT_CHANNEL_A0 X axisINPUT_CHANNEL_A1 Y axisINPUT_CHANNEL_A2 Z axis
31/42
Example--AccelerometerStep3: Modify the critical codes
32/42
Example--AccelerometerStep3: Modify the critical codes
33/42
Example--AccelerometerStep3: Modify the critical codes
34/42
Example—Accelerometer (Cont.)
Step4:Design GUIStep5: Install BaseStation
# cd /opt/tinyos-2.x/apps/BaseStation # make telosb install,0 bsl,<COM port-1>
Step6:Open the SerialForwarder function # java net.tinyos.sf.SerialForwarder –comm serial@<
COM port>:telosb&
35/42
Example—Accelerometer (Cont.)
Step7:Install Oscilloscope # cd /opt/tinyos-2.x/apps/Oscilloscope # make telosb install,<logic_ID> bsl,<COM port-1>
Step8: Sensing data with GUI # cd /opt/tinyos-2.x/apps/Oscilloscope/java # make # ./run
36/42
Example—Accelerometer (Cont.)
Step9: Physical meaning of sensor reading ● The output depends on value g (-1~1)
when g=-1, the output is around 1,650 when g=0, the output is around 2,048 when g=1, the output is around 2,500
● There are 6 main orientations (more details as following pages)
37/42
(1) X-out(red)=1g Y-out(white)=0g Z-out(green)=0g
Physical meaning of sensor reading(cont.)
38/42
(2) X-out(red)=0g Y-out(white)=1g Z-out(green)=0g
Physical meaning of sensor reading(cont.)
39/42
(3) X-out(red)=-1g Y-out(white)=0g Z-out(green)=0g
Physical meaning of sensor reading(cont.)
40/42
(4) X-out(red)=0g Y-out(white)=-1g Z-out(green)=0g
Physical meaning of sensor reading(cont.)
41/42
(5) X-out(red)=0g Y-out(white)=0g Z-out(green)=1g
Physical meaning of sensor reading(cont.)
42/42
(6) X-out(red)=0g Y-out(white)=0g Z-out(green)=-1g
Physical meaning of sensor reading(cont.)
43/42
Q & A