Hello,
first thank to all for ESPhome configuration.
my esphome with nomeMCU esp 32 was working for 1 day.
today stop to work, when i activate the switch, the ble will be ON , but the BLE gateway canāt find the blueconnect.
i will try to reboot the blueconnect, or searching on internat also to put in stanby and resume it.
iām requesting data every hourā¦mabe there is some limitation on readingā¦if you exceed the bluetooth will block it to save battery maybe, make sense?
I am only trying to connect every 2h. And even after 12h I get no connect. So dont think this is the issue. When i reboot the esp, i then get often a connect. Also the mobile app can connect whenever I want. So for me it looks like a bug in the esp ble stack or so.
Ok i am a step further now. I am getting a log message for the scan start, but even it is configured, no scan end message. So somewhere in the middle of the scan there is a bug, which stops the scan.
P.S.: I have massively reduced my code to only have the blueriiot code.
substitutions:
name: atom-lite-1
# name: atom-lite-1-de0ce8
roomname: Wohnzimmer
staticip: 192.168.1.145
yourname: Lukas
# erster Blueconnect
blueriiot1_mac: '00:A0:50:C7:46:XX'
blueriiot1_name_prefix: 'whirlpool'
blueriiot1_id_prefix: 'pl'
# send true 0x01 to this service ID
blueriiot_send_service_uuid: 'F3300001-F0A2-9B06-0C59-1BC4763B5C00'
blueriiot_send_characteristic_uuid: 'F3300002-F0A2-9B06-0C59-1BC4763B5C00'
# notification is recieved on this Service ID
blueriiot_recieve_service_uuid: 'F3300001-F0A2-9B06-0C59-1BC4763B5C00'
blueriiot_recieve_characteristic_uuid: 'F3300003-F0A2-9B06-0C59-1BC4763B5C00'
esphome:
name: ${name}
name_add_mac_suffix: True
platformio_options:
build_flags:
- -Wno-maybe-uninitialized
packages:
esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/m5stack-atom-lite.yaml@main
esp32:
board: m5stack-atom
framework:
type: arduino
# type: esp-idf
# Enable logging
logger:
level: VERY_VERBOSE
#level: DEBUG
# Enable Home Assistant API
api:
password: ""
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
# Set this to the IP of the ESP
static_ip: $staticip
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.1.3
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Atom-Lite-1 Fallback Hotspot"
password: "Pol8GUJw7wTe"
#captive_portal:
bluetooth_proxy:
active: true
#web_server:
# port: 80
# auth:
# username: admin
# password: Quatschkopf01
esp32_ble_tracker:
scan_parameters:
#interval: 300ms
#window: 50ms
active: true
interval: 1000ms
window: 1000ms
#active: false
#on_ble_advertise:
# - then:
# - lambda: |-
# ESP_LOGD("ble_adv", "New BLE device");
# ESP_LOGD("ble_adv", " address: %s", x.address_str().c_str());
# ESP_LOGD("ble_adv", " name: %s", x.get_name().c_str());
on_scan_end:
- then:
- lambda: |-
ESP_LOGD("ble_auto", "The scan has ended!");
ble_client:
# erster Sensor
- mac_address: ${blueriiot1_mac}
id: ble_client_${blueriiot1_id_prefix}
on_connect:
then:
- lambda: |-
ESP_LOGD("ble_client_on_connect", "Connected to blueriiot ${blueriiot1_mac}");
id(binary_sensor_${blueriiot1_id_prefix}_connected).publish_state(true);
- delay: 3s
- button.press: button_${blueriiot1_id_prefix}_doreading
on_disconnect: [lambda: "id(binary_sensor_${blueriiot1_id_prefix}_connected).publish_state(false);"]
switch:
# erster Sensor
- platform: ble_client
ble_client_id: ble_client_${blueriiot1_id_prefix}
name: "${blueriiot1_name_prefix} Enable"
id: switch_${blueriiot1_id_prefix}_enable
restore_mode: ALWAYS_OFF
sensor:
# erster Sensor
- platform: template
id: sensor_${blueriiot1_id_prefix}_temperature
name: ${blueriiot1_name_prefix} Temperature
# Optional variables:
unit_of_measurement: "Ā°C"
icon: "mdi:water-percent"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
id: sensor_${blueriiot1_id_prefix}_ph
name: ${blueriiot1_name_prefix} PH
# Optional variables:
#unit_of_measurement: "Ā°C"
#icon: "mdi:water-percent"
#device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
id: sensor_${blueriiot1_id_prefix}_orp
name: ${blueriiot1_name_prefix} Chlor
# Optional variables:
#unit_of_measurement: "Ā°C"
#icon: "mdi:water-percent"
device_class: "voltage"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
id: sensor_${blueriiot1_id_prefix}_bat
name: ${blueriiot1_name_prefix} Battery
# Optional variables:
#unit_of_measurement: "Ā°C"
#icon: "mdi:water-percent"
device_class: "battery"
state_class: "measurement"
accuracy_decimals: 1
binary_sensor:
# erster Sensor
- platform: template
id: binary_sensor_${blueriiot1_id_prefix}_connected
name: ${blueriiot1_name_prefix} Status
device_class: connectivity
entity_category: diagnostic
button:
- platform: template
id: button_${blueriiot1_id_prefix}_doreading
name: ${blueriiot1_name_prefix} do reading
internal: true
on_press:
then:
- ble_client.ble_write:
id: ble_client_${blueriiot1_id_prefix}
service_uuid: ${blueriiot_send_service_uuid}
characteristic_uuid: ${blueriiot_send_characteristic_uuid}
# A lambda returning an std::vector<uint8_t>.
value: !lambda |-
return {0x01};
- platform: template
id: button_start_scan
name: Start BLE Scan
on_press:
then:
- esp32_ble_tracker.start_scan:
continuous: false
- platform: restart
id: room_restart
name: "$yourname $roomname restart"
text_sensor:
# erster Sensor
- platform: ble_client
id: ${blueriiot1_id_prefix}_reading_data
name: ${blueriiot1_name_prefix} reading data
internal: true
ble_client_id: ble_client_${blueriiot1_id_prefix}
service_uuid: ${blueriiot_recieve_service_uuid}
characteristic_uuid: ${blueriiot_recieve_characteristic_uuid}
notify: true
update_interval: never
on_notify:
then:
lambda: |-
std::string rawhex = format_hex_pretty((uint8_t *) x.c_str(), x.size()).c_str();
ESP_LOGD("raw_hex", "%s", rawhex.c_str());
float temperature = (float)((int16_t)(x[2]<< 8) + x[1])/100;
ESP_LOGD("temp", "%f", temperature);
id(sensor_${blueriiot1_id_prefix}_temperature).publish_state(temperature);
float raw_ph = (float)( (int16_t) (x[4]<< 8) + x[3]) ;
float ph = (float)( (int16_t) (2048 - raw_ph)) / 232 + 7 ;
ESP_LOGD("ph", "%f", ph);
id(sensor_${blueriiot1_id_prefix}_ph).publish_state(ph);
float orp = (float)( (int16_t) (x[6]<< 8) + x[5]) / 3.86 ;
ESP_LOGD("orp", "%f", orp);
id(sensor_${blueriiot1_id_prefix}_orp).publish_state(orp);
float bat = (float)( (int16_t) x[11]) ;
ESP_LOGD("bat", "%f", bat);
id(sensor_${blueriiot1_id_prefix}_bat).publish_state(bat);
id(switch_${blueriiot1_id_prefix}_enable).turn_off();
# ENDE erster Sensor
the only difference from mine yaml.
for my problem i discover that also blueconnect app canāt connect. i decided to open the blue connect go, and disconnect the battery. After disconnection and reconnect ion, the app and the ble gateway start go work. today are 2 days without problem.
i also decide to receive the raw data, only for PH, and wrote a DSL rule in openhab to transform raw data to real ph
rule "piscina graph"
when
Item pump_dosing_controll received command or
Item ph_level received update or
Item esphome_blueconnect_pH_raw received update or
Item esphome_blueconnect_temperature received update
then
if(receivedCommand == ON) g_pump.postUpdate(pump_on)
else g_pump.postUpdate(pump_off)
g_set.postUpdate(ph_level.state)
var Number ph_raw = esphome_blueconnect_pH_raw.state as Number
var Number temp = esphome_blueconnect_temperature.state as Number
var Number slope = 54.2 + temp * 0.1984
var Number ph_calc = ph_raw / (slope * 4) + 7 + ph_offset
g_ph.postUpdate(ph_calc)
ph_ave.postUpdate(ph_calc)
esphome_blueconnect_pH.postUpdate(ph_calc)
end
Hi, I will also try a reboot of the device.
Questions regarding your cool calculation of the real ph value.
First: That you recalculate the value assumes, that the blue connect is not calculating it himself - right?
Second: You use a variable called āph_offsetā, which is not defined. Whats the value of it?
yes correct. i was think this because the guys that make the first attempt, the resuls was ever near and not precise as for the APP. i also try to ask at the blueriiot support, we will see what they are saying.
is a variable that i will use in future , when i will try to calibrate the ph with buffer solution, is just for future integration.
The Blue Connect itself incorporates Automatic Temperature Compensation (ATC) as part of its design. This means that the Blue Connect device hardware is equipped with sensors that can detect changes in water temperature and adjust the measurements of parameters such as pH and chlorine levels accordingly. The ATC function does not depend on the Android application, but is an integral part of the device technology. This ensures accurate readings directly from the device, regardless of the platform or app used to access the data.
In meanwhile I dont get any connection from my esp. With the app I can connect without any problems. Not sure, if it is usefull, to reconnect the battery for me, but I saw, that you need to remove the tape to do this, not sure if this is a good idea. I have really no idea, why the esp cant connect. I am using a atom lite here.
While the bluetooth connect is not possible I felt back using the mqtt based solution.
My guess is that the bluetooth_proxy has something to do with it. Looks like it keep the connection going. In my setup (first version of the yaml) I had the same issue as the BT stayed connected to the sensor. I had to disable BT in the esp to disconnect from the sensor.
For just the sensor reading you donāt need the proxy, as I understood correctly is more used as a relay to regular temp sensors.
Did you try to disable it?
Maybe just connect to the blueriiot
āor my problem i discover that also blueconnect app canāt connect. i decided to open the blue connect go, and disconnect the battery. After disconnection and reconnect ion, the app and the ble gateway start go work. today are 2 days without problem.ā
The sensor only allows 1 connection, the app connects request a reading, waits for the data and then disconnects. After that it sends the raw data to the cloud for conversion where the app then gets the reply. Using the lordmike integration the same result is retrieved.
Reading up on the conversation, i had my notification wrongly configured and missed out on the conversation. Good work!
Where are you now with the values? Is your yaml conversion more inline with the app?