Blue Connect pool measurements

I was just about to change the id_prefix so it’s not the same as the name_prefix, when I noticed the ESP device got one measurement to HA. However, it was from the day before, so I couldn’t get the logging back. I think I was playing around with the enable button at the time, so perhaps that’s the solution to my problem.

From what I understand, when enabling the ble_client (setting the switch in HA to enabled), the measurement should show up within minutes. How did you setup the automation? I played around with this a bit yesterday, turning it on every hour for 30 minutes, or turning it on every 10 minutes for 5 minutes. Both without result.

@Peerke I solved my issue by adding the ble scan_parameters from @oxident yaml file to my configuration. My final esphome file can be found here:

Hi Peter, sorry for the delay, I had time today to tinker with ESPHome and had to learn some things before configuring the device. Luckily, it was easier than I expected. I’m using an M5Stack Atom Lite device, and the platform is supported by esphome. I’ll tag @JosePortillo in case he wants to take a look at data.

Here’s the log lines you asked for, I hope the fourth sensor regarding the salinity can be decoded:

INFO Starting log output from blueconnect-m5.axel.dom using esphome API
INFO Successfully connected to blueconnect-m5.axel.dom
[15:26:16][I][app:102]: ESPHome version 2023.5.5 compiled on Jun  4 2023, 15:25:35
[15:26:17][I][main:266]: Reading Blueconnect
[15:26:29][I][raw_hex:152]: 33.FC.08.75.07.80.03.CC.00.C4.0D.19 (12)
[15:26:29][I][temp:155]: 23.000000
[15:26:29][I][ph:160]: 7.599138
[15:26:29][I][orp:164]: 232.124359
[15:26:29][I][bat:168]: 25.000000
[15:26:29][I][ble_client:041]: [00:A0:50:A6:76:DC] Disabling BLE client.
[15:26:29][W][ble_text_sensor:040]: [Pool reading data] Disconnected!
[15:26:49][I][esp32_ble_client:064]: [0] [00:A0:50:A6:76:DC] 0x00 Attempting BLE connection
[15:26:49][I][ble_text_sensor:034]: [Pool reading data] Connected successfully!
[15:26:51][I][esp32_ble_client:196]: [0] [00:A0:50:A6:76:DC] Connected
[15:26:51][I][main:232]: Connected to Blueconnect
[15:26:53][I][main:266]: Reading Blueconnect
[15:27:37][I][raw_hex:152]: 33.F2.08.71.07.81.03.CC.00.C4.0D.1A (12)
[15:27:37][I][temp:155]: 22.900000
[15:27:37][I][ph:160]: 7.616379
[15:27:37][I][orp:164]: 232.383423
[15:27:37][I][bat:168]: 26.000000
[15:27:37][I][ble_client:041]: [00:A0:50:A6:76:DC] Disabling BLE client.
[15:27:37][W][ble_text_sensor:040]: [Pool reading data] Disconnected!
[15:50:37][I][esp32_ble_client:064]: [0] [00:A0:50:A6:76:DC] 0x00 Attempting BLE connection
[15:50:39][I][ble_text_sensor:034]: [Pool reading data] Connected successfully!
[15:50:42][I][esp32_ble_client:196]: [0] [00:A0:50:A6:76:DC] Connected
[15:50:42][I][main:232]: Connected to Blueconnect
[15:50:44][I][main:266]: Reading Blueconnect
[15:50:55][I][raw_hex:152]: 33.F2.08.4F.07.3C.03.CC.00.C4.0D.19 (12)
[15:50:55][I][temp:155]: 22.900000
[15:50:55][I][ph:160]: 7.762931
[15:50:55][I][orp:164]: 214.507767
[15:50:55][I][bat:168]: 25.000000
[15:50:55][I][ble_client:041]: [00:A0:50:A6:76:DC] Disabling BLE client.
[15:50:55][W][ble_text_sensor:040]: [Pool reading data] Disconnected!

Hi @nheinemans,

Below is my automation.
What I do is just enable the switch, the esp device does the disabling. With me, the reading takes around 10sec.

alias: Swimmingpool reading every 2 hours
description: ""
trigger:
  - platform: time_pattern
    hours: /2
condition:
  - condition: state
    entity_id: switch.blueconnect_pool_sensor_enable
    state: "off"
    for:
      hours: 0
      minutes: 1
      seconds: 0
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.blueconnect_pool_sensor_enable
mode: single

Yes, that should be possible.
Make sure that the id and name are unique for both devices and that the HA sensors are also unique.
Then you can enable them 1 by 1 in HA
or
you could do that in the code at the end of text_sensor 1 and activate the second button after turning the first off. They should then go 1 by 1. I would add a small delay allowing the BLE to really disconnect.

Maybe the scan_parameters are needed here to control better timing. Not sure as with my hardware those are not needed, for 2 others they where needed.

I will see what comes out of the calculation using the one provided earlier in this thread. What does you app give for reading so there is a reference to calculate towards?

Here is a repo for the MQTT integration, they reversed-engineered the API. In there should also be a calculation of the received data.
GitHub - LordMike/MBW.BlueRiiot2MQTT: Utility to map between Blue Riiots pool API, and Home Assistant MQTT ( is have it installed to compare the API vs ESP32 data. Never figured out how they get the data back/converted with that integration

Salinity: 2.7 g/l

I was looking for methods to convert conductivity to salinity, it seems it’s not really linear because temperature affects it: Linear Conversion Of Conductivity To Salinity | Environmental ...

I tested this calculator, using values reported by Jose with his assumptions on the linear formula, and it seems to be close to the expected values:

The formulas are in the source code of that page, but it’s not a simple formula, I don’t know if we can do that stuff in ESPHome…maybe in HA we could…

This is a linear equation with a 5% error range for the estimate (good enough if you ask me), the conductivity provided by the device seems in micro, so it has to be first divided by 1000 I guess.

I’ve been using that one since it was released. The problem is that it’s cloud-based, it gets the values from the blueriiot cloud service (didn’t look at the code deeply). From what I understand, it doesn’t reverse engineer the values, it gets them straight from the API. It works beautifully, but it’s cloud based so I prefer to read them locally, if possible.

I think there might be a small design issue with the yaml: It will automatically connect to the Blueconnect upon boot, won’t it?

In this case, it tries to get a reading and if it somehow fails, it tries repeatedly to re-connect.

Does someone know if it’s possible to start the connection manually after boot up?

As far as I can tell, the switch will be reverted to false automatically after the measurement is done and the connection has been closed (hopefully).

If it doesn’t then you’ve got a problem :frowning:

I think you can add this option to the ble_client switch:

restore_mode: ALWAYS_OFF

Edit: This doesn’t seem to work with this particular switch, the restore_mode is already ALWAYS_OFF by default. This is probably just the way ble_client works, it tries to connect to the mac address after boot up.

@oxident , @nheinemans ,

There doesnt seem to be a on_failure. Maybe something that can be requested?
Don’t know where we can file for an enhancement, do you?

@Peerke Hi Peter, was wondering if you had the chance of taking a look at that conductivity/salinity conversion. Thank you very much.

Hi @alexdelprete,
Sorry, no not yet. some unexpected things popped up.
Its on my radar

-Peter

Thank you Peter. Don’t worry, just wanted to know if it was in your list. :slight_smile:

hi @alexdelprete,

Did a few test with the data and looked at the earlier calculations. Looks like the new firmware (indicated with the 33 instead of the 23 as first 2 digts) the dividing by 25 is now somewhere in the 75.xx to get the salinity straight out of the raw value.

Do you have 1 more reading with the salinity from the app where the salinity is not 2.7?

if its doable a few with different values would be great, 1 at time of low salinity and then maybe some at adding and somewhere in the middle. Dont need them straight away, if you could send them to me when you have them. Dont need the full log just the line with [raw_hex[ will do together with the salinity level from the app.

meanwhile is will work with the value you send me and see if the linear conversion delivers the same value as straight from the raw measurement. Will then update the ESP code to add the results in HA.

if its works for you starting with just the salinity from raw data, so you can test the conversion with your pool

Hi Peter,

my pool pump and chlorinator are broken, and I ordered new stuff but it’ll be here in a couple of weeks, so right now the pool is out of service. Luckily though, the salinity level has dropped significantly (1.4 g/l) now, so I am able to provide you the different value you asked (lower than last data I provided).

Here’s the log and the screenshot of the app. Once my pool will be ready again, I will be able to provide medium level data too.

INFO Successfully connected to espblueconnect.axel.dom
[03:32:46][I][main:235]: Connected to Blueconnect
[03:32:48][I][main:269]: Reading Blueconnect
[03:32:59][I][raw_hex:157]: 33.00.0A.44.07.80.02.75.01.B9.0D.1B (12)
[03:32:59][I][temp:160]: 25.600000
[03:32:59][I][ph:165]: 7.810345
[03:32:59][I][orp:169]: 165.803116
[03:33:00][I][bat:173]: 27.000000

@JosePortillo ,

Could you help out, seems that the new software version also changed the SAL value
related to this (post 203) Blue Connect pool measurements - #203 by JosePortillo

            raw hex        # (SW) ---- ->  INT  <-> APP == calulated devider
SAL 23AB093207AB0A7800240E # (23) 0078 -> 120.0 <-> 4.9 == 24.489795918367346
SAL 23A6093007B70A78001E0E # (23) 0078 -> 120.0 <-> 4.9 == 24.489795918367346
SAL 23AB093407980A7B00240E # (23) 007b -> 123.0 <-> 4.8 == 25.625
SAL 33FC0875078003CC00C40D19 # (33) 00CC -> 204.0 <-> 2.7 == 75.55555555555556
SAL 33F20871078103CC00C40D1A # (33) 00CC -> 204.0 <-> 2.7 == 75.55555555555556
SAL 33F2084F073C03CC00C40D19 # (33) 00CC -> 204.0 <-> 2.7 == 75.55555555555556
SAL 33000A440780027501B90D1B # (33) 0175 -> 373.0 <-> 1.4 == 266.42857142857144

Hi, Thank you for the great work integrating Blue Connect. I bought Blue Connect mainly beacuse esphome integration exist. I am new to Blue Connect and I have a question about its readings: I get big differences in readings so I wonder if this is normal. Please ckeck this picture. I did not added any chemicals yet still a big variations in readings for ORP. Ph is stabilised 7. 1 - Screenshot 2023-06-29 at 14.29.00
7.2

I took another measurement today:

[14:59:00][I][main:235]: Connected to Blueconnect
[14:59:02][I][main:269]: Reading Blueconnect
[14:59:13][I][raw_hex:157]: 33.C8.0A.3F.07.6A.02.65.01.CC.0D.1F (12)
[14:59:13][I][temp:160]: 27.600000
[14:59:13][I][ph:165]: 7.831897
[14:59:13][I][orp:169]: 160.103622
[14:59:13][I][bat:173]: 31.000000

What does the APP say when you do the reading just after esphome gets the data back?
With no chemicals the orp should be like with alexdelprete (around 150 - 160)