The basic problem is simple, have battery operated system to keep deer out of garden (motion sensor, LED spotlights, sprinkler valve, all 24VDC) and need to enable/disable a couple times a day. BLE device is simple on/off switch (MOSFET transistor is a ‘relay’ for DC, uses zero power) developed with $12 Silicon Labs kit. Only 1mA? Well, 1000 hours = 40 days is a full Amp-hour which drains battery, I have six of these scattered in the yard. I set advertising interval (when transmitter & receiver are on) to 500ms so overall current draw is like 0.04mA. Now esp32 bluetooth proxy connects and sets advertising interval to like 30ms and BLE device is now 1mA. Solution: BLE Client shows clear example to Connect to device, send data (1 or 0 = on/off), then disconnect. When BLE device gets ‘client disconnected’ callback I reset advertising interval to 500ms.
But it won’t connect! Here is log file and my olimex-bluetooth-proxy-90448c.yaml and corresponding Log:
ble_client:
- id: blinky_example
mac_address: 80:4B:50:56:B6:95
auto_connect: false
switch:
- platform: template
name: “Blinky Switch”
turn_on_action:- esp32_ble_tracker.stop_scan:
- ble_client.connect: blinky_example
- ble_client.ble_write:
id: blinky_example
service_uuid: DE8A5AAC-A99B-C315-0C80-60D4CBB51224
characteristic_uuid: 5b026510-4088-c297-46d8-be6c736a087a
value: [0x01] - ble_client.disconnect: blinky_example
- esp32_ble_tracker.start_scan:
turn_off_action: - esp32_ble_tracker.stop_scan:
- ble_client.connect: blinky_example
- ble_client.ble_write:
id: blinky_example
service_uuid: DE8A5AAC-A99B-C315-0C80-60D4CBB51224
characteristic_uuid: 5b026510-4088-c297-46d8-be6c736a087a
value: [0x00] - ble_client.disconnect: blinky_example
- esp32_ble_tracker.start_scan:
[10:12:07][D][switch:012]: ‘Blinky Switch’ Turning ON.
[10:12:07][D][esp32_ble_tracker:249]: Stopping scan.
[10:12:07][I][esp32_ble_client:110]: [3] [80:4B:50:56:B6:95] 0x00 Attempting BLE connection
[10:12:07][D][esp-idf:000][BTU_TASK]: E (5981025) BT_APPL: bta_gattc_process_api_open Failed, unknown client_if: 0