A discussion started at https://forums.homeseer.com/forum/li...y-ble-scanning on the subject of BLE scanning. I did some prototype work with ESP32 to address the author's question and have decided that the project is interesting enough to continue. The intent of this thread is for discussion on the design characteristics of the project.
The development will be targeted to ESP32 which has built-in BLE capability. The interface with HS is via MQTT protocol.
My prototype was a sketch using Arduino IDE. This was fine for a quick and dirty evaluation, but porting it for use by others would require that each user have development capability using Arduino tools. My next step is to continue porting of Tasmota to ESP32 (from ESP8266) so that the documented capabilities provided by Tasmota can be used. This is primarily associated with setup of the SSID, subsequent OTA updates of firmware and general configuration for each user's environment. It would also allow users to use other capabilities of the ESP32 so the installed devices can serve multiple purposes.
A user installation will consist of one or more ESP32 development boards which sell for $5 from China shipment such as https://www.aliexpress.com/item/ESP3...7-321be24a2d87 or $10 from USA shipment such as https://www.amazon.com/Xiuxin-Develo...-2-spons&psc=1 . I do not have either of these specific units with links just provided as examples. I have several ESP32/LoRa modules that I will be using for my development.
The prototype evaluation scanned for whatever BLE devices that were in my or close neighbor's houses. I did not attempt location determination, but only focused on present/not-present reporting. For this development I ordered two Bluetooth tracking beacons. One based upon Apple and one based upon Android. I should be able to determine if both are compatible.
Position determination will be based upon the RSSI signal reported by the beacon. There is also a TxPower parameter that can be set on the beacons that may be used at a later time. To assess a reasonable X/Y location at least three ESP32 devices will be installed at strategic locations that provide desired range and separation. My current thinking is to define an arbitrary grid of 100 x 100 and each ESP32 position would be characterized as an X/Y location on this grid. Beacon location would then be calculated with respect to the ESP32 locations so would also fall somewhere on the grid.
I saw much variation of one form or another in the prototype evaluation in the reported RSSI over time. This implies that filtering will be needed. Kalman filter was discussed in the other thread and this is likely a good final solution. Initially I will be doing a simple weighted average which is in effect a low pass filter. Once the project is determined to be viable then better filtering approach can be implemented to improve stability.
The prototype ran at one minute samples with thirty second scan per sample to find which BLE devices were advertising. While the ESP32 likley will be powered from USB, I do not know what the duty cycle effects are on battery life of bluetooth devices. For example, will it drain the battery of a nearby smartphone?
The ESP is a powerful microcontroller so should be able to easily handle the computational burden. My intent is that each ESP32 subscribes to the measurements being made by the other ESP32s. Each will then independently calculate every beacon position. While HS can get information from all ESP32s, the information about beacon location should be identical. In essence this is a redundant system where a fallback could be done by HS should the LWT of the primary ESP32 show it going offline.
Any discussion that will help this project along and be something useful is welcome.
The development will be targeted to ESP32 which has built-in BLE capability. The interface with HS is via MQTT protocol.
My prototype was a sketch using Arduino IDE. This was fine for a quick and dirty evaluation, but porting it for use by others would require that each user have development capability using Arduino tools. My next step is to continue porting of Tasmota to ESP32 (from ESP8266) so that the documented capabilities provided by Tasmota can be used. This is primarily associated with setup of the SSID, subsequent OTA updates of firmware and general configuration for each user's environment. It would also allow users to use other capabilities of the ESP32 so the installed devices can serve multiple purposes.
A user installation will consist of one or more ESP32 development boards which sell for $5 from China shipment such as https://www.aliexpress.com/item/ESP3...7-321be24a2d87 or $10 from USA shipment such as https://www.amazon.com/Xiuxin-Develo...-2-spons&psc=1 . I do not have either of these specific units with links just provided as examples. I have several ESP32/LoRa modules that I will be using for my development.
The prototype evaluation scanned for whatever BLE devices that were in my or close neighbor's houses. I did not attempt location determination, but only focused on present/not-present reporting. For this development I ordered two Bluetooth tracking beacons. One based upon Apple and one based upon Android. I should be able to determine if both are compatible.
Position determination will be based upon the RSSI signal reported by the beacon. There is also a TxPower parameter that can be set on the beacons that may be used at a later time. To assess a reasonable X/Y location at least three ESP32 devices will be installed at strategic locations that provide desired range and separation. My current thinking is to define an arbitrary grid of 100 x 100 and each ESP32 position would be characterized as an X/Y location on this grid. Beacon location would then be calculated with respect to the ESP32 locations so would also fall somewhere on the grid.
I saw much variation of one form or another in the prototype evaluation in the reported RSSI over time. This implies that filtering will be needed. Kalman filter was discussed in the other thread and this is likely a good final solution. Initially I will be doing a simple weighted average which is in effect a low pass filter. Once the project is determined to be viable then better filtering approach can be implemented to improve stability.
The prototype ran at one minute samples with thirty second scan per sample to find which BLE devices were advertising. While the ESP32 likley will be powered from USB, I do not know what the duty cycle effects are on battery life of bluetooth devices. For example, will it drain the battery of a nearby smartphone?
The ESP is a powerful microcontroller so should be able to easily handle the computational burden. My intent is that each ESP32 subscribes to the measurements being made by the other ESP32s. Each will then independently calculate every beacon position. While HS can get information from all ESP32s, the information about beacon location should be identical. In essence this is a redundant system where a fallback could be done by HS should the LWT of the primary ESP32 show it going offline.
Any discussion that will help this project along and be something useful is welcome.
Comment