diff --git a/.gitignore b/.gitignore index 89cc49cbd652508924b868ea609fa8f6b758ec56..7e3e834df379f35810b8096dd0cd337d8f95e9c8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +/.vscode/settings.json diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..05665e194d1f5b77367705032242df7287834889 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# PH-260BD + +## Description +This PlatformIO project allows you to get the pH, EC and temperature values from the cheap online water quality monitor PH-260BD + +## Usage +Open this project in PlatformIO and write it to an ESP32. No further hardware or wiring needed. +You'll get the values from the PH-260BD, which it sends every second, written to the serial monitor every 5 seconds. + +## Hints +* The EC values are calculated based on the currently selected display unit, because that's what the PH-260BD sends. +* The PH-260BD uses the factor `700` for `mS` <-> `ppm` calculation, which seems to be the standard in the Australian (and most likely Asian) part of the world. +* You can change that factor at the top of the code to `500` (US) or `640` (EU), but that will of course only affect the calculated values, not the display on the PH-260BD. +* The most accurate units to chose on the display for the calculation are probably `uS` and `ppm`. +* The calculated values are properly rounded as expected. +* The temperature value is truncated when the device is set to display `ppt`, which is why it's ignored from that data packet (but taken from `pH`). + +## Credits +* [Bo Jeanes](https://bjeanes.com/), for his [ESPHome implementation](https://gist.github.com/bjeanes/4310d30393a093bc2f1f2bd113fa820bm) of this (which i read less than i really should have) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 02c27c7fc5bfca893c84dcb244c687b319d5b771..f0cff78d4b060bc6599b8e16d0d7551a78779e14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,7 +44,7 @@ void bleDataCallback(const char *match, } else if (unit == "uS") { - sensorData->put("ec_ms", value.toFloat() / 1000); + sensorData->put("ec_ms", (double) value.toFloat() / 1000); sensorData->put("ec_us", value.toFloat()); sensorData->put("ec_ppm", value.toFloat() / 1000 * factorMsToPpm); sensorData->put("ec_ppt", value.toFloat() / 1000 * factorMsToPpm / 1000);