Hello everyone,
I don’t use HomeAssistant, but maybe you can still help me.
I also bought the BLE-YC01 pool meter and wrote an ESP32 Arduino sketch.
I read the value of the characteristic, but cannot decode it.
I used the code snipps from the forum, also read the positions from the string. However, the correct data is not displayed to me.
greeting
think
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLEClient.h>
static BLEAddress serverAddress("c0:00:00:01:da:1e");
static BLEUUID serviceUUID("0000ff01-0000-1000-8000-00805f9b34fb");
static BLEUUID charUUID("0000ff02-0000-1000-8000-00805f9b34fb");
BLEClient* pClient;
boolean doConnect = false;
boolean connected = false;
BLERemoteCharacteristic* pRemoteCharacteristic;
class MyClientCallbacks : public BLEClientCallbacks {
void onConnect(BLEClient* pclient) {
Serial.println("Verbunden mit BLE-YC01...");
}
void onDisconnect(BLEClient* pclient) {
Serial.println("Verbindung zum BLE-YC01 getrennt...");
connected = false;
pRemoteCharacteristic = nullptr;
}
};
// Dekodierungsfunktion für Temperatur
float decodeTemperature(uint8_t highByte, uint8_t lowByte) {
int16_t rawTemp = (highByte << 8) | lowByte;
float temperature = rawTemp / 100.0; // Beispielhafte Dekodierung (angenommen, die Temperatur wird in Hundertsteln von Grad übertragen)
return temperature;
}
void setup() {
Serial.begin(115200);
Serial.println("Starte Verbindung mit BLE YC01...");
BLEDevice::init("");
pClient = BLEDevice::createClient();
pClient->setClientCallbacks(new MyClientCallbacks());
doConnect = true;
}
void loop() {
if (connected) {
if (!pRemoteCharacteristic) {
pRemoteCharacteristic = pClient->getService(serviceUUID)->getCharacteristic(charUUID);
}
if (pRemoteCharacteristic->canRead()) {
std::string value = pRemoteCharacteristic->readValue();
String hexValue = "";
uint8_t tempHighByte = value[13];
uint8_t tempLowByte = value[14];
float Temperatur = decodeTemperature(tempHighByte, tempLowByte);
Serial.print("Temperatur: ");
Serial.println(Temperatur);
// ... (Dekodierung und Anzeige von pH, ORP, Batteriestatus)
//int ph = ((value[3] << 8) + value[4]);
//float pHWert = (ph);
//Serial.print("pH-Wert: ");
//Serial.println(pHWert);
//int orp = ((value[7] << 8) + value[8]);
//Serial.print("ORP-Wert: ");
//Serial.println(orp);
//int battery = ((value[5] << 8) + value[6]);
//float battStatus = (battery / 45);
//Serial.print("Batterie: ");
//Serial.println(battStatus);
for (size_t i = 0; i < value.length(); i++) {
if (i > 0) hexValue += ":";
hexValue += String(value[i], HEX);
}
Serial.print("Charakteristik Wert (Hex): ");
Serial.println(hexValue);
delay(20000);
}
}
if (!connected && doConnect) {
if (pClient->connect(serverAddress)) {
connected = true;
} else {
connected = false;
doConnect = false;
}
}
}
hello,
I’m facing a new problem with the device but not the code.
Actual temperature is 20.2°C but a classic meter indicate 25.5°C
Also battery is 58% in the esp sensor, but 0% on the Yinmik app
I’d like to know if any of you have seen this problem ?
I haven’t seen a problem with the temperature reporting. The pH and other values seem very inaccurate but the temperature is the only thing I did trust.
The above recipes have different multipliers for the battery, and I’ve used 31.9 which seemed about right, but it’s a bit weird. Doesn’t explain the app reporting zero though. Do you believe it? Is the battery almost flat?
Hi,
this is exactly the behavior I’m seeing. When the battery approaches 60%, it can’t sustain enough voltage anymore and the temperature reading drops dramatically. You need to replace the battery.
This means that the battery reading is not really a percentage of the full charge, but it’s related to the voltage. One would have to check at what voltage it usually breaks down, and the renormalize the percentage to that range…
On another note: my device suddenly started to report a pH of around 8.5 out of nowhere (the water is still at 7.4 or so with other test equipment). I wonder whether there is a way to reset it to the previous calibration values…
Thanks for this feedback. I will go change my battery and measure it.
For the Ph, I’m afraid the only option is to recalibrate with the special pouder you received with it.
Thanks. meanwhile ordered it from amz since I wanted it soon. As they also sell these solutions in bottles, I guess they must be good for some more time once mixed…
I also got an orp solution, but couldn’t find an affordable TDS one yet (although that’s probably not too important)…
Just wondering if I need to remove the plastic cap at the bottom, I saw a video on YouTube where the person removes it for calibration and I left it without. Readings are weird sometimes, mainly chlorine. Does anyone have the same?
So this is weird. I now set it to enable the ble_switch every 30min, and upon reading it turns it off immediately. Still, battery goes down like crazy, like 1% every hour… But the device isn’t even connected, and no attempts at connection are made by the ESP32 (only the regular scans). Also, the display is off, as it always is when there is no active connection…
Made a basic native homeassistant integration here: https://github.com/jdeath/BLE-YC01
I only made the native integration, I copied all the parsing and hard work posted in this thread!
Mine has not been calibrated or even in the pool yet, but at least temperature and pH match the display. Please post a github issue with any changes needed (PRs are appreciated). There is no error checking for invalid lines and I used a simple EC * .55 to get Salt. Not sure if that is correct.
This updates every 30 minutes, but that can be changed. Supports native bluetooth and ESPHome proxies. No need for manual setup, it will find the device automatically. Only supports branded BLE-YC01 for now.
Cood idea indeed, do the code can be improved and all managed in one place!!
I still sometimes have issues connecting to it, I need to turn on manually the meter and turn on then the switch, then it works… Untill a few hours later… It happened even that there was a freeze on the device, had to remove battery
I have my schedule on 60 min, instead of 30, could that be the reason?
The icon has to be submitted to homeassistant and approved to show up. I may do it eventually, but it is a pain: https://developers.home-assistant.io/blog/2020/05/08/logos-custom-integrations/