How to configure MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Duci
New user
Posts: 7
Joined: 29 Dec 2016, 15:41

How to configure MQTT

#1 Post by Duci » 05 Jan 2017, 22:05

Hi guys,

Fairly new to ESP2866 tinkering and electronics in general, but I have had some good success with ESPeasy in combination with Domoticz so now I have had the taste I would like to try the following. I hope you can give me a push in the right direction. :)

I have in my network a MQTT server running. It also has InfluxDB and Grafana running on it. I am planning to have ESPeasy post temperature data from a DS18B20 temperature sensor to MQTT, so that I can then put it in InfluxDB and visualize in Grafana. However I am having trouble getting ESPeasy to post the data to MQTT.

In ESPeasy I have now configured the MQTT server as my controller (protocol MQTT Openhab) and I have a DS18B20 sensor hooked up to the ESP, which is working.

In the log I see this, so I assume the connection with the MQTT server is fine?
1611808 : WD : Uptime 26 ConnectFailures 0 FreeMem 28160
1631004 : DS : Temperature: 20.25 (28-ff-92-8a-47-16-3-51)
The question: for the life of me I cannot find out how to configure ESPeasy so that it posts the temperature to my MQTT client. Or maybe it is posting it and I just don't know how I can check with the Mosquitto client?

Would appreciate if anyone can tell me how to do this.

Duci
New user
Posts: 7
Joined: 29 Dec 2016, 15:41

Re: How to configure MQTT

#2 Post by Duci » 06 Jan 2017, 08:47

Replying to myself.. but for the next person wanting to do this:

In the config page I set the protocol to OpenHAB MQTT and set "Locate Controller" and "Controller Port" with the address and port of my MQTT server. Then you setup your device (IDX/Var does not seem to matter) and if in the device tab you see it works go to the tools tab and click "Advanced".

In "Publish Template" you set the name of the topic you want to create for MQTT. So for example "Temperaturesensors/sensor1/temp". You can then subscribe to the same topic in your MQTT client, where you will see the sensordata being posted.

No idea what happens if you have multiple sensors connected to one ESP. Will test later.

Only thing now is that no matter what I do it posts the temperature once per minute, even if I set "Sensor Delay" to 15.

User avatar
lucaberta
Normal user
Posts: 59
Joined: 09 May 2016, 11:26
Location: Lausanne, Switzerland
Contact:

Re: How to configure MQTT

#3 Post by lucaberta » 22 Jan 2017, 15:45

Hi Duci,

Thanks for your messages, this is very much what I would like to achive too, as I am about to learn some InfluxDB in order to leverage the Grafana dashboards like you said.

Have you progressed any further in your project? MQTT works well for me, but I have not yet tackled the MQTT-to-InfluxDB bridge, though the forum user tozett did address this in the past:

viewtopic.php?f=4&t=731&p=7090&hilit=influxdb#p7094

It would be of course nice if we could have ESPEasy also talk directly to InfluxDB via the HTTP API, but it looks it doesn't work, or at least it did not when tozett tried it a while ago.

Let's see if he picks up this message, maybe he has an update to share too.

Thanks,

Luca

Duci
New user
Posts: 7
Joined: 29 Dec 2016, 15:41

Re: How to configure MQTT

#4 Post by Duci » 07 Feb 2017, 12:20

lucaberta wrote:Hi Duci,

Thanks for your messages, this is very much what I would like to achive too, as I am about to learn some InfluxDB in order to leverage the Grafana dashboards like you said.

Have you progressed any further in your project? MQTT works well for me, but I have not yet tackled the MQTT-to-InfluxDB bridge, though the forum user tozett did address this in the past:

viewtopic.php?f=4&t=731&p=7090&hilit=influxdb#p7094

It would be of course nice if we could have ESPEasy also talk directly to InfluxDB via the HTTP API, but it looks it doesn't work, or at least it did not when tozett tried it a while ago.

Let's see if he picks up this message, maybe he has an update to share too.

Thanks,

Luca
Hi Luca,

Sorry to reply so late! I have progressed, but after a whole lot of fiddling and failing in the end I decided to go with Node Red. As I am simply not experienced enough with this kind of stuff, and totally not a programmer I have to make do by combining existing bits and pieces I find on the internet. :D

So I now have Node Red + InfluxDB + Grafana on a RPi3, which still puts no strain on the RPi3 at all. Not even that sad that I could not do it without Node Red by the way, as I found out there is quite some nice functionality in there.

User avatar
lucaberta
Normal user
Posts: 59
Joined: 09 May 2016, 11:26
Location: Lausanne, Switzerland
Contact:

Re: How to configure MQTT

#5 Post by lucaberta » 07 Feb 2017, 14:35

Duci wrote:So I now have Node Red + InfluxDB + Grafana on a RPi3, which still puts no strain on the RPi3 at all. Not even that sad that I could not do it without Node Red by the way, as I found out there is quite some nice functionality in there.
that's probably the most reasonable thing to do all in all. I shall probably go down that path myself too.

Thanks for your answer!

Luca

OMJ
New user
Posts: 3
Joined: 10 Apr 2017, 17:38

Re: How to configure MQTT

#6 Post by OMJ » 10 Apr 2017, 19:45

Hi, i'm a newcomer to this forum and also new to the firmware.
But thanks to the good wiki, i have already a nodeMCU up and running with Openhab MQTT and a dallas temperature sensor.
I installed sensor number two and realized that they publish the values under same MQTT name :( :(

Has anyone solved this? I tried to search this forum and google the topic, but found sofar no other indications than this topic. So i hope you have a solution and are willing to share?

BR Ole.

PS. the ESPEASY firmware is awesome! Thanks a lot to those of you that have spend hours of coding and contributing. Opensource is great :)

PSS. I was reading a bit more and found this WIKI pake on the dallas sensor: https://www.letscontrolit.com/wiki/inde ... ValueNames
"Value names have a descriptive function but are also used if you select a MQTT type protocol. These names will appear in the published topic."
This is exactly what one could expect, however, it seems not to work in my case ( i did already assign different sensor names). Any idea why?

OMJ
New user
Posts: 3
Joined: 10 Apr 2017, 17:38

Re: How to configure MQTT

#7 Post by OMJ » 10 Apr 2017, 20:16

SOLVED:

I messed up the controlelr settings. Instead of leaving the original codes under MQTT publish (/%sysname%/%tskname%/%valname%) i changed the names.
Now it works. Absolutely fantastic :-)

Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests