MQTT and BHT1750

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

MQTT and BHT1750

#1 Post by CENG » 08 Mar 2021, 13:54

I´v setup my 8266 with a SI7021/HTU21D and a BH1750 Sensor. On EasyESP everything works well (Device Dashboards shows both sensors and values). But for my IOBroker MQTT there seems to be a problem. I´ll get only the values from the SI7071 Sensor.

Could anybody help me to troubleshoot EasyESP and MQTT?

------

Build:⋄
20112 - Mega
System Libraries:⋄
ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support
Git Build:⋄

Plugin Count:⋄
47 [Normal]
Build Time:⋄
Feb 23 2021 12:29:15
Binary Filename:⋄
ESP_Easy_mega_20210223_normal_ESP8266_4M1M
Build Platform:⋄
Linux-5.4.0-54-generic-x86_64-with-glibc2.29
Git HEAD:⋄
mega-20210223_9054eb3

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#2 Post by Ath » 08 Mar 2021, 20:08

A few questions:
- Have you checked the correct controller checkbox on the BHT1750 Device configuration page?
- How is your controller configured?
/Ton (PayPal.me)

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#3 Post by CENG » 08 Mar 2021, 21:04

Hi Ath,
thx for your questions.

The controller config should be fine, because the SI7021/HTU21D information from the same device is shown on the mqtt Server.

Find the settings attached. I don´t know if there is a missconfiguration.
screen.PNG
screen.PNG (26.51 KiB) Viewed 14762 times

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#4 Post by Ath » 08 Mar 2021, 21:52

Did you leave the Controller topics untouched, or are they changed? they should best (at least) include %tskname% and %valname% to send with names as defined at the sensors.

Does IOBroker have any logging available, so you can debug the messages sent from your ESP? (Don't know squat about IOBroker :? )
/Ton (PayPal.me)

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#5 Post by CENG » 12 Mar 2021, 15:40

Find attached the config for the mqtt. This works for the SHT Sensor. I´ve deleted the BHT Sensor and added it again. Still no connect to iobroker/mqtt Server
Attachments
mqtt.PNG
mqtt.PNG (20.32 KiB) Viewed 14693 times
Last edited by CENG on 12 Mar 2021, 16:32, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#6 Post by Ath » 12 Mar 2021, 16:22

This looks OK to me, except for 1 remark:
- You haven't configured your Unit number. It is strongly advised to give that a value between 1 and 254, and unique per ESP unit. This setting is on the Config tab. (You should un-check the 'Append Unit Number to hostname' checkbox)

NB: I don't think this is of influence to the MQTT behavior, unless you have another ESP with the same name and unit number (0).
NB2: Sending data to a controller is a global ESPEasy feature, and not implicitly implemented in a plugin, so that's why I think it should have worked already. I'm really surprised it still doesn't.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT and BHT1750

#7 Post by TD-er » 12 Mar 2021, 16:38

In the screenshot I do see the IDX field of one controller is set to "1".
For example Domoticz uses the IDX field and you have to have that value unique for each sensor you plan on using in Domoticz.

Can you also show the controller queue settings?
If you're posting always to the same topic, the value gets overwritten.
You can also add %tskname% to the publish topic if that may be helpful for your application?

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#8 Post by CENG » 12 Mar 2021, 17:38

I´ve enabled the unit number... Same..

Some Log from IOBroker:

sonoff.0 2021-03-12 17:36:55.975 info (1178) new object created: sonoff.0.NodeMCU_12345134_1_1.alive
sonoff.0 2021-03-12 17:36:55.954 info (1178) new object created: sonoff.0.NodeMCU_12345134_1_1
sonoff.0 2021-03-12 17:36:55.948 warn (1178) State "sonoff.0.NodeMCU_12345134_1_1.alive" has no existing object, this might lead to an error in future versions

But my NodeMCU would not send the BHT Information.

Where could I find the MQTT Queue on my nodemcu?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT and BHT1750

#9 Post by TD-er » 12 Mar 2021, 17:42

It is part of the controller settings.

See also its documentation: https://espeasy.readthedocs.io/en/lates ... parameters

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#10 Post by CENG » 12 Mar 2021, 17:57

Find attached the settings

PS: I do not understand, why the SHT Sensors sends like it should, but the bht sensor not.
Attachments
mqtt.PNG
mqtt.PNG (20.7 KiB) Viewed 14680 times

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#11 Post by CENG » 13 Mar 2021, 13:39

I have tried another MCU and another BHT Sensor.

Same Problem...

Has anybody a BHT1750 and MQTT working?

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#12 Post by Ath » 13 Mar 2021, 14:36

I'm quite sure there is some configuration mishap, not a sensor or ESP error.

Can you see any MQTT messages for this device when viewing the MQTT subscription '#' ? That should show all traffic to and from your MQTT enabled devices (and server(s)).

What controllers are configured on your ESP? (Names should be enough)
/Ton (PayPal.me)

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#13 Post by CENG » 13 Mar 2021, 14:38

Only the BH1750 Sensor is connected.


IOBroker Log:
2021-03-13 10:02:44.927 - warn: sonoff.0 (1178) State "sonoff.0.NodeMCU_15568697_1_1.alive" has no existing object, this might lead to an error in future versions
2021-03-13 10:02:44.928 - info: sonoff.0 (1178) new object created: sonoff.0.NodeMCU_15568697_1_1
2021-03-13 10:02:44.945 - info: sonoff.0 (1178) new object created: sonoff.0.NodeMCU_15568697_1_1.alive
2021-03-13 12:40:55.090 - info: sonoff.0 (1178) Client [NodeMCU_15568697_1_1] reconnected. Old secret 1615626164895_6938. New secret 1615635655088_112
2021-03-13 12:41:05.149 - info: sonoff.0 (1178) Client [NodeMCU_15568697_1_1] reconnected. Old secret 1615635655088_112. New secret 1615635665147_2045
2021-03-13 14:34:18.322 - info: sonoff.0 (1178) Client [NodeMCU_15568697_1_1] reconnected. Old secret 1615635665147_2045. New secret 1615642458320_4787

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#14 Post by Ath » 13 Mar 2021, 15:10

Ath wrote: 13 Mar 2021, 14:36 What controllers are configured on your ESP? (Names should be enough)
You haven't answered this question yet.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#15 Post by Ath » 13 Mar 2021, 19:35

I've just set up an ESP8266 with a BH1750 Lux sensor, (that took the most time, finding that sensor in the pile of sensors :shock:), configured the Domoticz MQTT controller, created a new dummy device (Lux) in Domoticz, configured the ESP with the BH1750, enabled the device for the controller with the correct IDX (with interval 2 sec.), and as long as I keep the sensor in the light it immediately shows the reading in Domoticz. So all I can say is: it works.
/Ton (PayPal.me)

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#16 Post by CENG » 13 Mar 2021, 19:44

Only one controller: Home Assistant (openHAB) MQTT

I´ve tried also the "Demoticz" Controller -> also nothing on my iobroker

BTW: THX very much for your support

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT and BHT1750

#17 Post by TD-er » 13 Mar 2021, 20:25

Please be aware you can only have one enabled MQTT controller.
So if you need some platform that needs MQTT using a message format that differs from what Domoticz expects then you should use Domoticz HTTP controller.

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#18 Post by Ath » 13 Mar 2021, 20:30

The OpenHab MQTT controller is probably the most generic/universal MQTT controller available in ESPEasy, and as it is sending other sensors fine, you may need to check your setup, please remind that MQTT topics are case-sensitive, so maybe your filtering is using the wrong name? The sensor is named 'LightSensor', and the value 'Lux', so you may need to filter on '#/LightSensor/Lux' (without the quotes, of course).
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT and BHT1750

#19 Post by TD-er » 13 Mar 2021, 21:53

And also keep in mind a topic with leading slash actually means the first topic level is "".
For example "/mytopic" is actually different from "mytopic"

So when subscribing to "/#" you get different results compared to "#".

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#20 Post by CENG » 14 Mar 2021, 09:08

Could anybody send me an example config?

To remind, for the SHT my config has worked. But for the bh1750 not. How could that be?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT and BHT1750

#21 Post by TD-er » 14 Mar 2021, 10:28

That's really strange indeed, so it makes me think you're maybe looking at the MQTT broker topics in the wrong way?

Can you use some MQTT client tool like MQTT explorer (Windows store) or MQTT.fx to subscribe to "#" as topic to see what is all being processed at the broker?
Maybe that will give some more insights to what is happening?

CENG
Normal user
Posts: 10
Joined: 08 Mar 2021, 13:45

Re: MQTT and BHT1750

#22 Post by CENG » 15 Mar 2021, 17:54

Hi Guys,
I´ve given up.

Now I use the open HAB MQTT Controller on EasyESP and the "MQTT Broker Adapter" instead of "Sonoff MQTT Adapter" in IoBroker. Now it works.

Think there´s is a bug in the "iobroker sonoff adapter".

Thank your very much for your support.

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT and BHT1750

#23 Post by Ath » 17 Mar 2021, 20:55

CENG wrote: 15 Mar 2021, 17:54 Now I use the open HAB MQTT Controller on EasyESP and the "MQTT Broker Adapter" instead of "Sonoff MQTT Adapter" in IoBroker. Now it works.

Think there´s is a bug in the "iobroker sonoff adapter".
What may be happening here is that the Sonoff MQTT Adapter plugin for ioBroker *only* supports switches, relays and the HTU21D/BMx280 sensors, as that is what is supported to be connected to Sonoff devices. That would sound somewhat logical to me, for being the cause. But I fail to understand why one would limit MQTT message types in a specific adapter, if other adapters will support the full set of sensors. Feels a bit silly to me.

Glad you got it sorted ;)
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests