Soil Sensor with ESP Easy

Hi,

I have a couple of nodemcu connected to some soil sensors (yl-69). the readings are showing in the analog input.

below is the settings I have for MQTT from controller section in ESP easy.

can someone tell me how can I get the data passed on over to home assistant.

thank you

You have to define an mqtt: section in your configuration.yaml to define a connection to your broker

and then define an MQTT sensor to receive the information from your topic

I have already got an mqtt server running… where do i get the state topic from esp easy…

If you don’t know what it is sending out, you should connect with a client to listen to all topics, and then watch to see what the sensor sends. I use mosquitto_sub, but I have heard MQTT.FX works well

mosquito_sub -t "#" -v -u user -P password

See also the page on testing your setup

the MQTT topic is generated from the “Controller Publish” section in your second picture.

Try:
/ESP01/SoilSensor1/Analog

%sysname% is the name of your ESP device (ESP01)
%tskname% is the name of your device (SoilSensor1)
%valname% is in the name of the value (Analog? Should be able to change it. I have a NODEMCU and it is under optional settings.)

thank you for your assistance… finally got it to communicate. I am getting the reading in numbers. for eg, 1024 for dry. is there anyway I can convert this to percentage value or some way to tell for what value will it be dry and what value it will be wet.

You can use a value_template to change what is displayed. Something like this will display dry, ok or damp.

value_template:  {% if float(value) < 1000 %}dry{% else if float(value) < 2000 %}ok{% else %}damp{% endif %}

But you can test out various templates in the templates page under Developer Tools on the HA home page.