I'm trying to get sensor data from ti sensortag using matlab, my work is based on the work posted in github site :
https://github.com/sid5291/SensorTag-Matlab
I'm trying to get accelorometer data instead of temperature and humidity data (in the original work)
Here is my code, the connection between matlab and sensortag is established and
when I request the temprature information the result is correct and
when I request the acceloremeter or the gyroscop data the result wrong
GAP_initialise = ['01';'00';'FE';'26';'08';'05';'00';'00';'00';'00';'00';'00';'00'
'00';'00';'00';'00';'00';'00';'00';'00';'00';'00';'00';'00';'00'
'00';'00';'00';'00';'00';'00';'00';'00';'00';'00';'00';'00';'01'
'00';'00';'00'];
GAP_DeviceDiscovery = ['01';'04';'FE';'03';'03';'01';'00'];
SCAN_TYPE = 1;
GAP_connect = ['01'; '09'; 'FE'; '09'; '00'; '00'; '00' ;'52';'DE'; 'AB' ;'29' ;'6A' ;'BC'];
CONNECT_TYPE = 2;
% Reference http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf
GATT_AccOn = ['01'; '92'; 'FD'; '05'; '00'; '00'; '34'; '00'; '01'];
GATT_AccOff = ['01'; '92'; 'FD'; '05'; '00'; '00'; '34'; '00'; '00'];
WRITE_TYPE = 3;
GATT_AccRd = ['01'; '8A'; 'FD'; '04'; '00'; '00'; '30' ;'00' ];
READ_TYPE = 4;
disp('Going to Intialize');
HCI_TXRX(GAP_initialise);
disp('Going to Scan');
disp('Make Sure Led D1 is blinking on Sensor Tag');
disp('Wait for Scan To End');
input('Press any key to continue');
HCI_TXRX(GAP_DeviceDiscovery,SCAN_TYPE);
disp('Going to Connect to Sensor Tag');
disp('LED D1 will turn off when Connected, if doesnt there is an error');
input('Press any key to continue');
HCI_TXRX(GAP_connect,CONNECT_TYPE);
disp('Going to Turn On Acc');
input('Press any key to continue');
HCI_TXRX(GATT_IRTAccOn,WRITE_TYPE);
disp('Going to Read from Sensors');
input('Press any key to continue');
while(1)
result = HCI_TXRX(GATT_AccRd,READ_TYPE);
x = hex2dec(result(1,:))/64;
y = hex2dec(result(2,:))/64;
z = hex2dec(result(3,:))/64;
char = input('Press any key to continue (x to exit)','s');
if(char == 'x')
break;
end
end
Can any one help me to solve this problem please
i have found the error : just you need to put the right value of the accelerometer service which is :'31' for configuration, '2D' for reading data