Go Down

Topic: How to handle a chinese bluetooth LE sensor (Read 550 times) previous topic - next topic

robypez

Hello everybody, I have a problem.
I'm trying to trigger some events with Arduino using some bluetooth LE sensor by a chinese manufacturer, Kaipule. I buy this sensor on Alibaba and I'm trying to understand how can I interface them in my sketch.

The are magnetic contact sensors and I know that they have just the BLE broadcasting mode (no GATT, profile etc): they send information when the contact is open.

I try to scan them with a BLE scanner and this is the log

Code: [Select]

kCBAdvDataIsConnectable : 0
Local Name : iSensor
Manufacturer Data : <beca2c02 4602f9f7>


I notice that

1) the scanner can see the sensor just when I open the contact, so to save battery he broadcast data just when the contact is open

2) every time you open and close the contact the code change a little. Here is a sequence

<beca2c02 46025856> - > open
<beca2c02 46005955> - > close
<beca2c02 46025a58> - > open
<beca2c02 46005b57> - > close
<beca2c02 46025c5a> - > open
<beca2c02 46005d59> - > close
<beca2c02 46025e5c> - > open
<beca2c02 46005f5b> - > close

etc

3) I assume that 02 is the status open, 00 is the status close and I see also a pattern for other bytes.

I have the paper the company send to me, but I cannot find any useful reference.

Assuming that I need to use this sensor as a switch for Arduino, have you seen a sample to understand how can I manage a bluetooth LE broadcasting?

robypez

Ok I just understand that "beca2c02" is a sort of identification for every sensor.



So I think I can use this code to register the sensor in the eprom.

PaulS

Quote
2) every time you open and close the contact the code change a little. Here is a sequence
It looks to me like the 1st value is the sensor number and the second is simply an increasing number. So, you'd have to keep track of the actual state of the sensor, and toggle it each time the sensor sent an event.

How did you get that data?
The art of getting good answers lies in asking good questions.

ChrisN-AU

robypez,

did you ever work this out. I have some of these sensors (different brand but documentation looks identical). I am assuming you extract data form the 31 bits in the advertising packet as per the spec

ChrisN-AU

I am sure the OP has moved on to more interesting things but to help people like my self two days ago googling Arduino iSensor BLE here goes.

The documentation works but is a little confusing

the data  is is in the manufacturer data section of the BLE advertising package

In my case I ignore the first first 4 bytes  (they are good for you)

So start at byte 5

1   2  3  4   5   6   7   8
be ca 2c 02 46 02 58 56


So the first byte to care about is byte 5 (0x46) (0bx1000110)

bit7
单双向设备标记
Uni and Bi-direction device tagging
1,双向设备,0,单向设备
1, Bi-direction device; 0, Uni-direction device

so 0 in this case

bit6
是否发送状态报告
send status report
1,固定间隔时间发送报告,0,无状态报告
1, fixed time interval sending; 0, stateless repo

so 1 in this case as the door sensor reports every hour to say it is alive

bit5 device code. In this case 0 bit5=0 为报警类设备 for alarm units

bit 4 not used i think

bit 0 - 3 (I think although not documented is deviceType) in this case 0b0110 = 0x6 门磁(door contact)


So byte 6

 0x02 = 00000010

which is

anti tamper 0
alarm 1 (i think open)
battery report 0
status report 0 (this was real not a status)

which brings us to byte 7

A incremental counter (i guess so you know if you have missed messages)

and finally byte 8 a CRC which I have worked out but is assume is the sum of the previous 7 bytes

I hope tis helps someone



Go Up