Open SFeli opened 1 year ago
Hi, I am happy to hear that you find the component useful. Your proposal sounds like a nice enhancement. Actually I have been thinking about transformations for some time. Your example would be a transformation and another one would be converting a measured battery voltage to an uint8 percentage between 0 and 100. Maybe I should work on that a bit. But I am not sure when I will find the time. ;-)
To clarify, if I wanted to use this component to broadcast standard BLE GATT temperature and humidity, what would be the service and characteristic IDs I would use? and will the solution automatically provide the right data format or is that the purpose of this GATT_Format
addition?
Hello the UUID's and Formats for the Environmental Services are link: BLE ServiceUUID 181A : BLEService environmentService BLE CharacterUUID 2A6E : Temperature sint16 (dec -2) BLE CharacterUUID 2A6F : Humidity uint16 (dec -2) BLE CharacterUUID 2A6D : Pressure uint32 (dec -1) and unfortunaltly you have to look and check them on https://www.bluetooth.com/specifications/assigned-numbers/. If you use the App nRF Connect as client the decoding will be done according those formats. As far as I know the setValue() accepts several formats and there is no conversion. There is one issue open on espressif which mention a csv-file for the definition which can be used to generate a bin-file which should be flashed in the ESP. https://github.com/espressif/esp-at/issues/169 - but this is still open.
Could you post a full example of your working ESPHome .yaml file that publishes a value like temperature into a environmental sensing service, and a temperature characteristic? please and thank you :)
substitutions:
deviceno: "02"
devicename: esp
upper_devicename: Bluetooth Low Energy 02
esphome:
name: $devicename-$deviceno
friendly_name: ${upper_devicename}
comment: ESP32-Dev BLE-Controller und Arduino 207
platformio_options:
board_build.flash_mode: dio
upload_speed: 115200
external_components:
- source: github://sfeli/esphome-ble-controller
esp32:
board: esp32dev
framework:
type: arduino
version: 2.0.8
platform_version: 6.1.0
logger:
level: DEBUG
api:
encryption:
key: "your own key"
reboot_timeout: 0s
ota:
password: "your own pw"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: True
captive_portal:
i2c:
sda: 32
scl: 33
scan: false
sensor:
- platform: bmp280
id: s_bmp280
temperature:
name: "BMP280 Temperature"
id: "s_BMP_T"
accuracy_decimals: 1
oversampling: 16x
pressure:
name: "BMP280 Pressure"
id: "s_BMP_P"
accuracy_decimals: 1
address: 0x76
update_interval: 30s
- platform: adc
pin: GPIO36
id: "i_Batt"
attenuation: 11db
update_interval: 30s
name: "Battery"
filters:
- multiply: 10
esp32_ble_controller:
services:
- service: "0000181A"
characteristics:
- characteristic: "00002a6e-0000-1000-8000-00805f9b34fb"
exposes: s_BMP_T
use_BLE2902: true
GATT_Format: '16_2'
- characteristic: "00002a6f-0000-1000-8000-00805f9b34fb"
exposes: s_BM_H
GATT_Format: '16_2'
- characteristic: "00002A6D-0000-1000-8000-00805f9b34fb"
GATT_Format: '32_1'
exposes: s_BMP_P
commands:
security_mode: none
maintenance: false
on_connected:
- logger.log: "Hi I'm connected. :-)"
Hello WiFiuCite,
nice developtment and thx for you pubishing. the code handles all values of sensors in the same format. Some clients are expecting GATT - Format so Temperature GATT-ID 2A6E like uint 16 with exp -2 - so 2343 for 23.43 °C. If you are open for futher features you I can support you with another parameter on characteristics like
Temperature
I have implemted in the fork sfeli if you are courios.
Thanks another time for the well done 99% of the solution.