[SOLVED] ESP8266 flashed with EASY ESP, HC-SR04, MOSQUITTO, OPENHAB2 on Raspberry Pi 3B

I have working with OPENHAB2 for a while running it an an UBUNTU Server. I have recently tried to install a new version of OPENHAB on my Raspberry Pi 3B.
Installation was fine and I also installed MOSQUITTO
For a test I have connected an ESP8266 (12) flashed with EASYESP and a HC-SR04 connected to GPIO pin 12.
(Removed Image)

The installation and configuration seems fine.

When I look at MQTT Fx I can see the various topics.
(Removed Image)

On OPENHAB2 is have configured the following:
mqtt.thing
Bridge mqtt:broker:localBroker [ host=“10.0.0.22”, secure=false, clientID=“openhab2”, username=“dawie”, password=“passwd” ]
{
Thing mqtt:topic:uptime {
Channels:
Type number : uptime “uptime” [ stateTopic=“ESP12/SysInf/uptime” ]
}
Thing mqtt:topic:Distance {
Channels:
Type number : Distance “Distance” [ stateTopic=“ESP12/Dist/Distance” ]
}

}

broker.thing
mqtt:broker:localBroker [ host=“10.0.0.22”,secure=false, clientID=“openhab2”, username=“dawie”, password=“passwd” ]

default.items
Number MQTTuptime “MQTT uptime [%d]” {channel=“mqtt:topic:uptime:uptime”,autoupdate=“false”}
Number MQTTDist “MQTT Dist” {channel=“mqtt:topic:Distance:Distance”,autoupdate=“false”}

default.sitemap
sitemap default label=“Test Sitemap”
{
Frame label=“MQTT Test”{
Text item=MQTTuptime
Text item=MQTTDist}
}

I have also configured the MQTT binding on the paper_ui
(Removed Image)

I still can not see the value from my ESP8266 on the basic_ui
(Removed Image)

looking at netstat
[17:52:26] openhabian@openHABianPi:/etc/openhab2/items$ netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:netbios-ssn 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:microsoft-ds 0.0.0.0:* LISTEN
tcp 0 0 raspberrypi:1883 raspberrypi:46222 ESTABLISHED
tcp 0 0 raspberrypi:1883 10.0.0.131:52613 ESTABLISHED
tcp 0 0 raspberrypi:ssh Dawies-MacBook-Pr:50412 ESTABLISHED
tcp 0 0 raspberrypi:9001 Dawies-MacBook-Pr:49808 ESTABLISHED
tcp 0 172 raspberrypi:ssh Dawies-MacBook-Pr:49813 ESTABLISHED
tcp6 0 0 [::]:8003 [::]:* LISTEN
tcp6 0 0 localhost:8101 [::]:* LISTEN
tcp6 0 0 [::]:netbios-ssn [::]:* LISTEN
tcp6 0 0 [::]:5007 [::]:* LISTEN
tcp6 0 0 [::]:http-alt [::]:* LISTEN
tcp6 0 0 localhost:45365 [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:1883 [::]:* LISTEN
tcp6 0 0 [::]:8443 [::]:* LISTEN
tcp6 0 0 [::]:microsoft-ds [::]:* LISTEN
tcp6 0 0 raspberrypi:http-alt Dawies-MacBook-Pr:50467 ESTABLISHED
tcp6 1 0 raspberrypi:http-alt Dawies-MacBook-Pr:50195 CLOSE_WAIT
tcp6 0 0 raspberrypi:http-alt Dawies-MacBook-Pr:50462 TIME_WAIT
tcp6 0 0 raspberrypi:http-alt Dawies-MacBook-Pr:50471 TIME_WAIT
tcp6 0 0 raspberrypi:http-alt Dawies-MacBook-Pr:50468 TIME_WAIT
tcp6 0 0 raspberrypi:http-alt Dawies-MacBook-Pr:50511 ESTABLISHED
tcp6 0 0 raspberrypi:http-alt Dawies-MacBook-Pr:50509 ESTABLISHED
tcp6 0 0 raspberrypi:46222 raspberrypi:1883 ESTABLISHED
tcp6 0 0 raspberrypi:http-alt Dawies-MacBook-Pr:50491 TIME_WAIT
[17:57:00] openhabian@openHABianPi:/etc/openhab2/items$

it does seem as if the mqtt binding from openhab is talking to the mqtt server

Looking at the LOG file

My mqtt.cfg file
localBroker.url=tcp://10.0.0.22:1883
localBroker.clientId=openhab2
localBroker.user=dawie
localBroker.pwd=passwd
localBroker.qos=0
localBroker.retain=false
localBroker.async=true

Can anybody please help, it looks like this new mqtt binding is taking me to the cleaners.
Tx Dawie

Please code fences. Thanks

which version of OH are you running?

openHAB 2.4.0-1 (Release Build)

also keep in mind ESPEasy by default has a leading “/” to the system name so double check that you in fact removed it

[ stateTopic=“ESP12/Dist/Distance” ]

Thank you very much, IT WORKED…

I added the / to the front and it immediately picked up the topic

1 Like

And FYI, HA auto device discovery is not working in OH2.4. Fixed in 2.5 AFAIK.

Hallo,
I’m new to openhab. I have spend hundrens of hours to find the reason why the value from an SR04 is not shown at BASICUI. So I decide to ask a help.
At first, iI use openhab 2.4 with the new MQTT. My project is a switch and the SR04. The switch is working fine. But the sensor does not. The values are subscribed at mqtt fx with topic “broker:tele/sonoff1/SENSOR” and appeared
{“Time”:“2019-06-30T09:23:59”,“SR04”:{“Distance”:205.158}}.
My item file is:
Number Sensor1 “Sensor1 [%.1f cm]” {mqtt="<[broker:tele/sonoff_1/SENSOR:state:JSONPATH($.SR04.Distance)]" }
and my sitemap:
Text item= Sensor1 icon=“meter”
Can you please give me a help?
Thanks!