@@ -11,14 +11,11 @@ This program decodes the bluetooth advertising packets for the following BLE tem
1111// 6 = Govee H5074 (type 4 advertising packets)
1212// 99 = Display raw type 0 and type 4 advertising packets for this BLE MAC address
1313```
14-
15- The program uses the bluetooth and mqtt client libraries, which may need to be installed to compile and possibly run the program.
14+ The program uses the bluetooth and mqtt client libraries, steps to image Raspberry Pi and install necessary libraries to compile program are show at bottom of this readme:
1615
1716To compile:
1817
19- ```
2018gcc -o ble_sensor_mqtt_pub ble_sensor_mqtt_pub.c -lbluetooth -l paho-mqtt3c
21- ```
2219
2320To run:
2421```
@@ -207,3 +204,83 @@ mac address = E0:12:1D:33:82:11 location = H5074 test unit device type = 99 ad
207204rssi = -64
208205=========
209206```
207+
208+
209+ steps to set up raspberry pi as bluetooth sensor MQTT collector
210+
211+ imaged with:
212+ 2020-08-20-raspios-buster-armhf-full.img
213+
214+ ```
215+ sudo apt-get update
216+ sudo apt-get full-upgrade
217+
218+ reboot
219+ uname -a
220+ Linux pi-ble-02 5.4.79-v7+ #1373 SMP Mon Nov 23 13:22:33 GMT 2020 armv7l GNU/Linux
221+ Pi Model 2B V1.1
222+ Revision : a21041
223+ SoC : BCM2836
224+ RAM : 1024Mb
225+
226+ git clone https://github.com/deepcoder/bluetooth-temperature-sensors.git
227+
228+ sudo apt-get install libbluetooth-dev
229+
230+ git clone https://github.com/eclipse/paho.mqtt.c.git
231+ cd paho.mqtt.c/
232+ make
233+ sudo make install
234+
235+ cd /home/pi/bluetooth-temperature-sensors
236+ gcc -o ble_sensor_mqtt_pub ble_sensor_mqtt_pub.c -lbluetooth -l paho-mqtt3c
237+
238+ pi@pi-ble-02:~/bluetooth-temperature-sensors $ lsusb
239+ Bus 001 Device 005: ID 0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0
240+
241+ pi@pi-ble-02:~/bluetooth-temperature-sensors $ hciconfig
242+ hci0: Type: Primary Bus: USB
243+ BD Address: 00:02:72:DC:31:2F ACL MTU: 1021:8 SCO MTU: 64:1
244+ UP RUNNING
245+ RX bytes:980 acl:0 sco:0 events:51 errors:0
246+ TX bytes:2446 acl:0 sco:0 commands:51 errors:0
247+
248+ pi@pi-ble-02:~/bluetooth-temperature-sensors $ sudo ./ble_sensor_mqtt_pub 0 1 100 1000
249+ ble_sensor_mqtt_pub v 2.11
250+ 1 Bluetooth adapter(s) in system.
251+ Reading configuration file : ble_sensor_mqtt_pub.csv
252+ MQTT server : tcp://172.168.2.22:1883
253+ MQTT topic : homeassistant/sensor/ble-temp/
254+ Header |MAC Address |Type|Location |
255+ Unit : 0 |58:2D:34:3B:44:16| 99|MJ_HT_V1_LYWSDCGQ |
256+ Total devices in configuration file : 1
257+ MQTT client name : ble_sensor_mqtt_pub-2F:31:FC:13:02:00
258+ Bluetooth Adapter : 0 has MAC address : 2F:31:FC:13:02:00
259+ Advertising scan type (0=passive, 1=active): 1
260+ Advertising scan window : 100, 62.5 ms
261+ Advertising scan interval : 1000, 625.0 ms
262+ Scanning....
263+ current hour (GMT) = 23
264+ last hour (GMT) = 22
265+
266+ =========
267+ Current local time and date: Sun Dec 6 15:30:29 2020
268+ mac address = 58:2D:34:3B:44:16 location = MJ_HT_V1_LYWSDCGQ device type = 99 advertising_packet_type = 000
269+ ==>0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6
270+ ==>0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
271+ ==> 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2
272+ ==> 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
273+ ==>043E230201000056723B342D5817020106131695FE5020AA015456723B342D58061002CD01B9
274+ ==>__________ad________________________mmmmmmmmmmmmtttthhbbzbzbccrr
275+ rssi = -71
276+ =========
277+ Current local time and date: Sun Dec 6 15:30:29 2020
278+ mac address = 58:2D:34:3B:44:16 location = MJ_HT_V1_LYWSDCGQ device type = 99 advertising_packet_type = 004
279+ ==>0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6
280+ ==>0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
281+ ==> 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2
282+ ==> 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
283+ ==>043E260201040056723B342D581A09094D4A5F48545F563105030F180A180916FFFFC3FB2C6D28B1B9
284+ ==>__________ad________________________mmmmmmmmmmmmtttthhbbzbzbccrr
285+ rssi = -71
286+ ```
0 commit comments