# Esp8266 and multiple ds18b20's with mqtt

**URL:** <https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556>\
**Category:** General\
**Tags:** http-request, mqtt\
**Created:** [30 March 2022 17:47 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556 "2022-03-30T17:47:18Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [6 April 2022 18:05 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/121 "2022-04-06T18:05:06Z")

</div>

Well at least you know ESP is OK.

The toggle is for an attached relay (if you have one)

---

<div class="post-metadata">

**Author:** ![tonylane26](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tonylane26/32/9272_2.png) [@tonylane26](https://discourse.nodered.org/u/tonylane26)\
**Post date:** [6 April 2022 18:06 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/122 "2022-04-06T18:06:07Z")

</div>

Hi @9toejack sorry, I've only just seen this message chain. It might be too late for you to backtrack, but I just wanted to let you know that there was nothing inherently wrong from where you started out.

I have a system in my basement using a WEMOS mini D1 which has an esp8266 processor running the standard Arduino firmware.

I collect the data from there and send it to a Raspberry PI3B running Node-Red and using MQTT. It's been running for about 2 years now.

I used code from this tutorial to get started, but depending on how you are getting on with Tasmoto, you are welcome to have a look at my Arduino code.

> **[ESP32 with Multiple DS18B20 Temperature Sensors | Random Nerd Tutorials](https://randomnerdtutorials.com/esp32-multiple-ds18b20-temperature-sensors/)**
>
> This guide reads temperature from multiple DS18B20 temperature sensors with ESP32 using Arduino IDE. We’ll wire the sensors on the same data bus to the ESP32

I think the only 2 tricky things I found were firstly that the unique HEX code for each sensor required an initial scanning of the network to see what was connected, and then pasting them into an ID array so that I could relate them to a specific temperature. If you swap out a sensor, you have to run it and see what the new code is and paste it into the array. I do this scan on power-up so I can just monitor the serial debug port to see the sensor codes.

The second one (my ignorance) was formatting the sensor value as a string, since that's what MQTT sends, and then converting it back to a number in NODE-RED.

After that it has worked well, and I am more comfortable in 'C' than using yet another OS. One day I might try Tasmoto though.

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [6 April 2022 18:06 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/123 "2022-04-06T18:06:34Z")

</div>

ah that makes sense, so i can use it to turn a solenoid on or off from there , or use mqtt to trigger it on or off right?

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [6 April 2022 18:08 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/124 "2022-04-06T18:08:10Z")

</div>

Thats correct, you have a number of GPIO which can be connected to relays sensors etc.  
Have you connected any sensors to the ESP yet ?

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [6 April 2022 18:09 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/125 "2022-04-06T18:09:36Z")

</div>

I appreciate that ill read that one again,  
right now its a connectivity issue  
getting connected to the wifi has been a pain in the ARSE to say the least.  
all the while its been a good learning experience. also a good reminder to pause and reflect instead of pushing on and destruct!

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [6 April 2022 18:15 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/126 "2022-04-06T18:15:24Z")

</div>

> **[DS18x20 temperature sensor - Tasmota](https://tasmota.github.io/docs/DS18x20/)**
>
> Documentation (Wiki) for Tasmota

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [6 April 2022 18:16 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/127 "2022-04-06T18:16:34Z")

</div>

The other reality i have is ,  
i ordered 5 more esp's that arrive today.  
i could actually use a single esp with each kettle.  
collecting temp and then possibly adding my pressure transducers as well.  
eliminating all the wires I have connecting everything. it will make the complete "package" more eye candy  
however baby steps are needed,  
my new esp's just delivered so im going to tamotize another.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [6 April 2022 18:18 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/128 "2022-04-06T18:18:42Z")

</div>

Have fun 😉

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [6 April 2022 18:31 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/129 "2022-04-06T18:31:49Z")

</div>

Your ESP thinks it's a Sonoff Basic, which is a smart switch with a relay built in. So Toggle on a Sonoff would switch the relay.

You probably need to tweek the configuration so Tasmota recognises all the available GPIO functions.  
There is a tutorial on [Tasmota with a NodeMCU ESP development board](https://iotcircuithub.com/tasmota-nodemcu-esp8266-home-automation/), and the Tasmota docs go through [configuring a device](https://tasmota.github.io/docs/Configuration-Procedure-for-New-Devices/) not already in the [repository](https://templates.blakadder.com).

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [6 April 2022 18:32 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/130 "2022-04-06T18:32:51Z")

</div>

one done and working at home.  
I'm adding the brewery credentials for second wifi info.  
so hopefully everything works great when i get it there.

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [6 April 2022 18:51 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/131 "2022-04-06T18:51:26Z")

</div>

so I had connection issues with the esp's at first with my cell phone.  
but I figured out to turn autoconnection off on other WIFI's so it wouldn't try to connect to another service because of the internet issue.  
I have a feeling that was my problem at the brewery.  
I'll test that theory latter today.

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [6 April 2022 19:19 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/132 "2022-04-06T19:19:19Z")

</div>

i set up 4 of the new ones.  
also did firmware update on all 5  
so far so good.  
Rabbit hole is shrinking, but possibilities are expanding.  
Awesome

---

<div class="post-metadata">

**Author:** ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)\
**Post date:** [6 April 2022 21:10 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/133 "2022-04-06T21:10:49Z")

</div>

> [@9toejack](#):
>
> so I had connection issues with the esp's at first with my cell phone.  
> but I figured out to turn autoconnection off on other WIFI's so it wouldn't try to connect to another service because of the internet issue.  
> I have a feeling that was my problem at the brewery.

Yes, some phones just do that silently and fast, while you are still still busy entering the configuration of the tasmo device and without your browser "complaining" that you are not connected to it anymore. Could well be the case. Disabling auto-connect for the other SSIDs is a good option. My Android phone also complains, that the native tasmo AP has (obviously) no internet and then asks, whether you want it (the phone) to stay or move away.  
But you said, that you entered the wifi credentials in the tasmotizer so they will be added during the flashing of the ESP.

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [6 April 2022 22:52 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/134 "2022-04-06T22:52:00Z")

</div>

Home router worked great.  
Took them to brewery. No good!  
It's the same exact router.  
Maybe it's the guest wifi causing issue but they have different ssid

Also doing testing in an area with no interferences.

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [7 April 2022 01:08 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/135 "2022-04-07T01:08:26Z")

</div>

All i have to say is holycrap really!

so i once again reset my router at brewery but got to thinking.  
House wifi was only caps for the first letter of the name.  
brewery wifi was all caps  
so i pluged in same ssid as at my house and BAM  
all good. now i have readig to figure out the mqtt stuff  
and the ds18b20 stuff  
 ![omgreally](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d9f7b237fd2cf4375d793175a678d986307ff09.png)

 ![whatnow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f7267708999b14b892394eef9ab76d664fc38a5f.png)

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [7 April 2022 07:47 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/136 "2022-04-07T07:47:09Z")

</div>

Gotta love networking stuff - different vendors implementations of how SSIDs are broadcast can drive you nuts.

Must say i have not had all caps cause me an issue before - but definitely get case right along the way as the ESPs can be finicky with that.

Hopefully you are on track now

Check some of my earlier posts about relevant commands to set at the console also for Tasmota

Craig

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [7 April 2022 14:20 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/137 "2022-04-07T14:20:43Z")

</div>

Odd I also have all caps SSIDs with tasmota and no problems - still at least its working now 😉

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [8 April 2022 18:14 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/138 "2022-04-08T18:14:44Z")

</div>

@craigcurtin hey so i need help with network and port forwarding through NAT  
is that part of your network expertise?  
may be better to go over privately, i dont want all my ip's on the  
www

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [9 April 2022 07:42 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/139 "2022-04-09T07:42:03Z")

</div>

disregard @craigcurtin, my issue was human error.lol  
now im going to read the stuff above  
but so i dont go down a rabbit hole.  
do i start with mqtt with pi and understand that or do i start with tasmota and learn it.  
cheers.

---

<div class="post-metadata">

**Author:** ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)\
**Post date:** [9 April 2022 13:45 UTC](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556/140 "2022-04-09T13:45:35Z")

</div>

start with mqtt on the pi, as this will be the integration part between future Node-Red and Tasmota-devices. Install mosquitto mqtt broker on the pi and download mqtt-explorer on your Client PC ([https://mqtt-explorer.com/](https://mqtt-explorer.com/)), then have mqttExplorer to connect to your broker.  
I suggest to not bother with user/pwd and TLS security on your broker for a start, as all your setup is inside your LAN/VPN (I hope).  
Then enable mqtt on your tasmota devices.

Here is an example how it looks like with a set of three sensors on one device:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7efc06de0024450f8af92dd9e0558bd76ab64f6c.png)

once you have that, you can add NR to the game.

[Previous page](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556.md?page=6)

[Next page](https://discourse.nodered.org/t/esp8266-and-multiple-ds18b20s-with-mqtt/60556.md?page=8)
