Here’s how I configured this a couple of months ago. It has been working flawlessly since:
Let’s look at the Tasmota side first:
-
wire the DS18B20 to the tasmota device as documented e.g. here: DS18x20 temperature sensor - Tasmota. The documentation claims you can connect multiple sensors to one pin and I can confirm this. On my device four DS18b20 are connected to the same pin.
-
Configure the Tasmota device. Here is my hardware configuration:

-
At this point you should see the temperature on the Tasmota main screen.
-
Go to Tasmota Web Interface → Configuration → MQTT and configure your MQTT broker. If your MQTT broker uses Username/password, enter them here and skip the next step
-
If your MQTT does NOT use Username/password, go to Tasmota Console and enter the command backlog mqttuser 0; mqttpassword 0;
. You should see a successful connection to your MQTT Broker in the console.
-
In the Tasmota Web Interface go to “Console” and enter the command TelePeriod 10
. You should now see output in the Tasmota Console containing text similar to this: MQT: tele/YourModuleName/SENSOR = {"Time":"2025-01-26T00:17:28","DS18B20-1":{"Id":"3C15E381206C","Temperature":49.4}...
every 10 seconds!
-
Adjust TelePeriod
to whatever suits you best. Mine is set to 180 (seconds)
This should be all that is required to configure Tasmota to report DS18B20 temperature on MQTT every TelePeriod
seconds.
Note that Tasmota will report temperature in °Celsius. Conversion to Fahrenheit will be handled by openHAB later. You could also change the Tasmota output instead, using the command SetOption8 1
in the Tasmota console, but I never tried that myself (what is this Fahrenheit thing, anyway?
)
On to the openHAB configuration:
openHAB uses THINGS to represent (or connect to) physical, well, things. Like your Tasmota device. See Concepts | openHAB.
You first need to create an MQTT thing. This requires having the MQTT Binding installed in openHAB (MainUI → Administration → Add-on Store). There is a good description here: Adding Things - Advanced | openHAB.
In your particular case, in openHAB MainUI go to Administration → Settings → Things and click the blue, round ‘+’ button in the lower right of the window. Select the MQTT Binding. If you have not configured a connection between openHAB and your MQTT broker yet you need to do so first. Follow the chapter “Create the Bridge Thing” here: Adding Things - Advanced | openHAB
If the bridge is configured correctly it should show up as “Online” in your “Things” list.
Add the Tasmota thing: “+” button on the “Things” page → MQTT Binding → “Generic MQTT Thing”. Pick your previously configured bridge and click “Create”.
The “Thing” exists now, and can listen to topics from MQTT, but we now need to tell it, which topics and which data from these topics (here: temperature values) should be used. Every required data point (i.e. every temperature value, in my case I have 4 sensors which send 4 temperature values) will be extracted by openHAB and will be sent over a “Channel” to the respective openHAB “item” (which we have not created yet; We’ll do so after a few steps).
So create a “Channel” as described in the documentation page. The channel configuration needs these parameters (check the “Show advanced” checkmark in the upper right to see all options):
- MQTT state topic: tele/YourTasmotaName/SENSOR
- Unit of Measurement:
°C
- Note: This is really important if you want openHAB to convert the value to °F later!
- Incoming value transformations:
JSONPATH:$.DS18B20-1.Temperature
- Note: I’m not sure about the part “DS18B20-1”. If you have only one sensor connected Tasmota may send “DS18B20” here, instead. Verify this in the Tasmota console.
The “incoming value transformation” is use the extract the value we are actually interested in (the temperature) from the long JSON string which Tasmota sends.
This completes your “Thing” configuration. You now have an openHAB “Thing” which will receive a temperature value from MQTT whenever it is updated from Tasmota and provide it in a “Channel” for you to use.
Finally, let’s create an “ITEM” to finally be able to actually use the temperature value in openHAB:
Still in the Thing configuration screen you should now see your channel. At the bottom there is a button “Add points to Model”. Click it and select your newly created channel. Fill out all the fields but pay special attention to “Unit”: Enter “°F” there and the item will always return the temperature in °F. The conversion from °C (which was the unit of the value provided to the Thing by Tasmota) to °F is handled by openHAB.
You should also configure “Semantic Class: Measurement” and “Semantic Property: Temperature” beside the mandatory other fields.
If you defined your Semantic Model | openHAB well after installing openHAB you can now go to your openHAB Dashboard, select the “Properties” tab, click on “Temperatures” and your temperature should be visible there. There is even a chart if you click the temperature item.
Done. Not exactly a one-step procedure, but that is mostly due to using an MQTT “Thing”: These are by design very generic and provide no info to allow openHAB to assist in configuring the “Thing”. But it’s not rocket science, either 
Everything else (using the temperature in a rule to automate things, creating a widget to show the temperature directly on the dashboard, …) is described in the documentation and in many posts here in the forum. Enjoy the openHAB experience 