I'm using Atlas Scientific Hydroponic kit, previously I wrote my own Arduino code, because with ESPhome there's no way to do calibrations, but here I learned about Tasmota so I tried it and it worked flawlessly (not needing the serial for calibration) BUT there's the compensated reading issue. Considering I'm using a chiller I thought that the variation wasn't that big. I was wrong. The water temperature range is 1.4°C, and in this range the reading drifts more than 200µS, with very unconsistent readings, so I had to find a solution, and at the end I did. I learned a lot here and now it's time to share something, so here there's the flow.
I'm using the Hydroponic kit from Atlas, but actually it could work fine with any temperature sensor and with just the pH or EC EZO.
Code: Select all
[{"id":"ab12abbd.da61f8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"9b01bcd.554e24","type":"inject","z":"ab12abbd.da61f8","name":"RT EC","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"0.1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-2 RT,","payloadType":"str","x":360,"y":260,"wires":[["cd981553.958df8","7c7c6289.dce7fc","a979de5.c24232"]]},{"id":"6d99af9f.0903c","type":"mqtt out","z":"ab12abbd.da61f8","name":"","topic":"","qos":"1","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"57ba50fe.6e951","x":970,"y":280,"wires":[]},{"id":"cd981553.958df8","type":"function","z":"ab12abbd.da61f8","name":"","func":"var watertemp = global.get(\"global_watertemp\");\nwatertemp.toString();\nmsg.payload += watertemp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":280,"wires":[["848defde.0f32d"]]},{"id":"83834a47.81be28","type":"mqtt in","z":"ab12abbd.da61f8","name":"","topic":"stat/tasmota_atlas/RESULT","qos":"2","datatype":"auto","broker":"57ba50fe.6e951","nl":false,"rap":true,"rh":0,"x":1480,"y":280,"wires":[["a15ac89.1393b38"]]},{"id":"a15ac89.1393b38","type":"function","z":"ab12abbd.da61f8","name":"Purge message","func":"msg.payload = msg.payload.substring(11, msg.payload.length - 2)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":280,"wires":[["eb598572.93f448","efd2eb92.cc5768"]]},{"id":"9fb3622c.abccf","type":"ha-entity","z":"ab12abbd.da61f8","name":"EC Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"EC Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:beaker-outline"},{"property":"unit_of_measurement","value":"µS"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":240,"wires":[[]]},{"id":"cdd568b1.1a0458","type":"ha-entity","z":"ab12abbd.da61f8","name":"pH Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"pH Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:eyedropper"},{"property":"unit_of_measurement","value":"pH"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":320,"wires":[[]]},{"id":"eb598572.93f448","type":"switch","z":"ab12abbd.da61f8","name":"ECrecON ?","property":"ECrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":240,"wires":[["9fb3622c.abccf"]]},{"id":"efd2eb92.cc5768","type":"switch","z":"ab12abbd.da61f8","name":"pHrecON ?","property":"pHrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":320,"wires":[["cdd568b1.1a0458"]]},{"id":"c3cf258e.c4c2f8","type":"inject","z":"ab12abbd.da61f8","name":"RT pH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"3. 1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-1 RT,","payloadType":"str","x":360,"y":300,"wires":[["cd981553.958df8","7c7c6289.dce7fc","519487bf.cbd088"]]},{"id":"3ecea826.681158","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":180,"wires":[["2827ec99.159f44"]]},{"id":"2827ec99.159f44","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"ECrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":180,"wires":[[]]},{"id":"7d2b262c.1406d8","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":360,"wires":[["3e69f4d7.8bbffc"]]},{"id":"3e69f4d7.8bbffc","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pHrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":360,"wires":[[]]},{"id":"2ee894dc.25e67c","type":"comment","z":"ab12abbd.da61f8","name":"Compensation","info":"","x":130,"y":280,"wires":[]},{"id":"1638580e.5c2838","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pollingON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":460,"wires":[[]]},{"id":"7c7c6289.dce7fc","type":"api-current-state","z":"ab12abbd.da61f8","name":"","server":"da5e77a8.b1b498","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.polling","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":680,"y":460,"wires":[["1638580e.5c2838"]]},{"id":"848defde.0f32d","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":790,"y":280,"wires":[["6d99af9f.0903c"]]},{"id":"a979de5.c24232","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":180,"wires":[["3ecea826.681158"],["321a4ad3.00dfe6"]]},{"id":"519487bf.cbd088","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":360,"wires":[["7d2b262c.1406d8"],["8dddd3dd.18812"]]},{"id":"321a4ad3.00dfe6","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":220,"wires":[["3ecea826.681158"]]},{"id":"8dddd3dd.18812","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":400,"wires":[["7d2b262c.1406d8"]]},{"id":"57ba50fe.6e951","type":"mqtt-broker","name":"MQTT_Broker","broker":"192.168.16.76","port":"1883","clientid":"","usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"da5e77a8.b1b498","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
What I do is to continuosly and asynchronally ask to the Tasmota the compensated readings (pH and EC) using the temp reading coming from the Tasmota telemetry (the command is RT,temperature and the function add the temperature to the request). The problem is that the answer is always something like "{"Sensor":"5.753"}" or "{"Sensor":"1423.0"}" and always in the same topic. So first there's a function that purges the payload, and then what I did to split the messages to pH and EC is to create 2 variables and trigger each one for 2 seconds when the request is sent, double checking and blocking the wrong reading in the mqtt in, and then store the values in 2 virtual entities. The polling entity is created to temporary stop the requests during calibrations.
I hope it can be helpful for someone.