-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
180 lines (133 loc) · 6.82 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Author: Aditya Dani
Email ID: [email protected]
Directed Research: CSCI 590 - USC
Prof Young Cho
This is a repository for my Directed Research under Prof Young Cho
for the Fall 2013 semester.
===================
Project Description
===================
Main aim of this Directed Research was to implement a logging utility
that would log the different sensor measurements measured by the
sensorTag instrument. The sensorTag has the following sensors and this logging
utility provides support for all these measurements:
1] Temperature
2] Accelerometer
3] Gyroscope
4] Magnetometer
5] Humidity
6] Barometer
All these measurements are stored with their timestamps when the measurement was
received from the instrument in their respective csv file.
======
Design
======
This logging functionality consists of three main parts viz.
[A] Binary Utility Functions
These are the binaries which get generated when you run the "make_script.sh".
One binary utility gets created for each of the above sensorTag measurements.
The primary function of these binaries is to convert the hex data returned by
the sensorTag into actual readings/measurements.
[B] Scripts to get Data and process Data from sensor Tag.
There are a group of scripts which are used to get and process data from sensorTag.
In order to recieve a particular sensor readings we need to write a specific value into
one of the memory addresses for the sensorTag.
Also, we use the notification mode of the sensor Tag wherein all the sensor readings are sent
to the bluetooth connected laptop/device periodically. Currently the three sensor measurements
which matter the most and their sampling rates are as follows:
1] Temperature - 10 samples/sec
2] Accelerometer - 10 samples/sec
3] Gyroscope - 1 sample/sec
Following are the memory locations for each sensor:
Temperature
-----------
To start sensing:- Write 01 at 0x29
To enable notification mode:- Write 0100 at 0x26
Accelerometer
-----------
To start sensing:- Write 01 at 0x31
To enable notification mode:- Write 0100 at 0x2E
To increase sampling rate to 10 samples/sec :- Write 10 at 0x34 (default is 1Hz)
Gyroscope
-----------
To start sensing:- Write 01 at 0x5B
To enable notification mode:- Write 0100 at 0x58
Following are the scripts and their functionalities.
1] sensorTag.sh
---------------
This is the starter script which takes the MAC address of the sensorTag to connect
your laptop to. It basically runs the run_gatttool script and appends timestamp
to each sensor reading received from the sensorTag. You redirect the output for this
script to a text file with name of your choice.
2] run_gatttool.sh
------------------
This script is called from the sensorTag.sh script. It basically performs the core
functionality of connecting the laptop to the sensorTag device using bluetooth. It also
writes appropriate values in sensorTag memory addresses using gatttool to enable the
sensors and start the notification of the sensor readings.
3] aggregate_data.sh
--------------------
After runnning the sensorTag.sh you will get a file which will contain the output returned
by the gatttool appended with timestamps. You give this file as an input to this script. This
script basically aggregates the data and removes the unecessary texts from the file and just outputs
the hex Data measurements received from the semsorTag into a file. This intermediate file is then
processed and each hex Data reading is given to the appropriate binary utility functions
described above. The binary utility functions then outputs the obtained measurements into
separate csv files.
[C] Audio processing
The third part to this project is to record an audio along with the sensorTag readings that
have been taken and then process that audio. The audio recording device records the audio
and stores it into .wav file. We use the linux commandline tool "sox" which can take an .wav file
as input and output a data file consisting of amplitudes time sorted. You can also specify the
sampling rate too. Following is the format
$ sox -r <sampling rate> <*.wav file> <*.dat file>
The output file name extension should be "*.dat" in order for sox to recognize what kind of operation
needs to be done on the input file.
The sox command has been included in the aggregate data script. And thus that script additionally
takes two extra inputs vizz Input Audio File and the sampling rate.
===========
Compilation
===========
To compile all the C programs and generate the binary utility functions.
$ ./make_script.sh
============
Requirements
============
1] Bluetooth supported laptop. Must support Bluetooth Low Energy (BLE)(aka Bluetooth 4.0
or Bluetooth Smart)
2] Kernel Version 3.9.11 or higher.
3] Note that this directory/repository also contains an empty directory which has been names "empty"
It is required by the bash and expect scripts. Ensure that your working directory has this
directory.
======================================================
Execution and Genrating sensor measurement .csv files
======================================================
1] To obtain the MAC address of the sensorTag run the following command
and press the button present on the sensorTag on its side panel.
$ sudo hcitool lescan
Ensure that the bluetooth of your laptop is enabled.
2] To obtain the hexData from the sensorTag for each sensors. Run the following
command.
$ ./sensorTag.sh <MAC Address> > <Hex-Dump Filename>
Use the MAC address obtained from step 1]. Also use any filename with any extension
as the <Hex-Dump Filename> parameter.
3] To aggregate and obtain the final sensor measurements/readings.
$ ./aggregate_data.sh <MAC address> <Hex-Dump Filename> <Audio Filename> <Sampling Rate>
Use the MAC address obtained frm step 1]. Use the same filename for <Hex-Dump Filename>
as used in step 2]. The third parameter is the input audio file 'a .wav file' obained
from the audio recorder. While the fourth parameter is the sampling rate at which the
audio file should be sampled. As all the other measurements are done at 10Hz it is
advisable to give the 4th parameter as 10.
The final measurements and the output files generated are:-
Temperature Measurements --> temp_MAC-Address
Accelerometer Measurements --> accel_MAC-Address
Gyroscope Measurements --> gyro_MAC-Address
Audio Measurements --> audio_MAC-Address.dat
==================
Output File Format
==================
All the output files are of the csv or Comma-Seprated File format.
The general format is:-
[Timestmap1, Reading1-PartA, Reading1-PartB, Reading1-PartC]
[Timestmap2, Reading2-PartA, Reading2-PartB, Reading2-PartC]
[Timestmap3, Reading3-PartA, Reading3-PartB, Reading3-PartC]