# DS18B20 sensor\[s\] on ESP

**URL:** <https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239>\
**Category:** General\
**Created:** [25 January 2026 17:29 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239 "2026-01-25T17:29:19Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [25 January 2026 17:29 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/1 "2026-01-25T17:29:19Z")

</div>

Does anyone have experience getting DS18B20 sensors to work on ESPs?

I have tried Tasmota on a Wemos D1 Mini and a Tenstar Robot C3 Supermini.  
When I connect the DSB1820 and 4.7K pull-up resistor, the ESP fails to boot, or at least it no longer connects to wifi, nor does it start it's own access point.  
Connecting the pull-up resistor but no temperature sensor, the ESP starts up so it does seem to be something specific to the sensor.

To verify that the DS17B20s are good, I connected them to a Raspberry Pi GPIO4 and they work, accessed by command line rather than by a contrib node.:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/4219aa7dc9fa27b3ea9b36acb37c2dd9b93dfeee.png)

Any ideas why the ESP won't start up?  
Do you have DS18B20s working on ESP32 using diifferent firmware?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 January 2026 18:11 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/2 "2026-01-25T18:11:54Z")

</div>

How exactly have you connected it?

---

<div class="post-metadata">

**Author:** ![Jibun-no-Kage](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jibun-no-kage/32/99316_2.png) [@Jibun-no-Kage](https://discourse.nodered.org/u/Jibun-no-Kage)\
**Post date:** [25 January 2026 18:41 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/3 "2026-01-25T18:41:59Z")

</div>

@Colin has it right, you need to validate the wiring. You should review the following...

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

Confirm that the default Tasmota interface sees and reports the sensor data. You have to load the 'sensors' Tasmota firmware variant typically.

I tend of use i2c based sensors, but single wire is comparable, is simpler to implement, but I find harder to debug/resolve issues.

Once you have the ESP via Tasmota working correctly reporting sensor data. Then I would use NR MQTT support to 'talk' to the ESP, i.e. receive data, send commands to the ESP via MQTT, which is well documented via Tasmota references.

---

<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:** [25 January 2026 18:51 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/4 "2026-01-25T18:51:09Z")

</div>

> [@Colin](#):
>
> How have you connected it?

First I used a perfboard and soldered the connections

```auto
ESP 3.3V => DS18B20 orange wire
               4K7 resistor between orange and yellow
ESP GPIO 9 => DS18B20 yellow wire
ESP GND => DS18B20 black wire

```

Having little faith in my soldering skill I switched to using a 3 way connector block. This is the current connection, to the Pi. I don't think it's a terribly smart way of doing it, but it does work for the Pi.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6bde56701f9a87411de3ba25081a216bb28e866c.jpeg)

> [@Jibun-no-Kage](#):
>
> Confirm that the default Tasmota interface sees and reports the sensor data.

Not sure I know how to do that?  
Using the Tasmota web installer I can select the device (My PC does see a device connected to USB)  
Instead of flashing again, I can open the console but it gives no output until I press the reset button. It never shows sensor data.

---

<div class="post-metadata">

**Author:** ![Jibun-no-Kage](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jibun-no-kage/32/99316_2.png) [@Jibun-no-Kage](https://discourse.nodered.org/u/Jibun-no-Kage)\
**Post date:** [25 January 2026 19:07 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/5 "2026-01-25T19:07:20Z")

</div>

Did you look at the link I provided about how Tasmota documentation states the wiring should be done? You should see 'something' coming in on the GPIOx pin you are using for input.

---

<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:** [25 January 2026 19:54 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/6 "2026-01-25T19:54:42Z")

</div>

I have indeed pored over that page.

I tried various GPIO pins, no difference. Also 5 different sensors. Some with leads, some in transistor style packaging.

The Wemos D1 Mini is flashed with tasmota-sensors, which is not explicitly listed on the DS18x20 page. It was v12, I tried upgrading to v15.

The Blakadder supported devices page says to flash the ESP32-C3 Super Mini with tasmota32c3-cdc. That option is not offered by the web installer so I used "Unofficial: Tasmota32-C3 2M (English)" which does work, until I connect the sensor.  
This firmware is not listed on the page you linked either.

With no sensors connected but the pull-up in place, this is the web console output

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

And the web installer console when I reset

```auto
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x42063e86
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x98
load:0x403cc710,len:0x824
load:0x403ce710,len:0x2204
SHA-256 comparison failed:
Calculated: 2d2da256600f8197a1e023a984a8a04d9f4bff674c6fe424c23f3c4a08f3a513
Expected: 20a97ffec3706e960069d93e80a000d0dacf7624e7f9baf65a320b4f487a7902
Attempting to boot anyway...
entry 0x403cc710

00:00:00.001 CMD: Using USB CDC
00:00:00.001 HDW: ESP32-C3 v0.4 
00:00:00.016 UFS: FlashFS mounted with 2224 kB free
00:00:00.024 CFG: Loaded from File, Count 35
00:00:00.026 SER: Set to 8N1 115200 bit/s
00:00:00.026 SER: HWCDC supports 115200 bit/s only
00:00:00.030 QPC: Count 1
00:00:00.062 BRY: Berry initialized, RAM used 3889 bytes
00:00:00.073 Project tasmota - Tasmota Version 15.2.0.4(0f16270-tasmota32_2M)-3.3.6(2026-01-24T17:18:16)
00:00:01.001 WIF: Connecting to AP1 GreyWagtail561 Channel 6 BSSId B4:FB:E4:62:00:67 in mode HT20 as esp32c3-1-2888...
00:00:03.359 WIF: Connected
00:00:03.566 HTP: Web server active on esp32c3-1-2888 with IP address 192.168.1.100
20:42:06.539 MQT: Attempting connection...
20:42:06.571 MQT: Connected

```

And this is the console with the sensors connected

> ESP-ROM:esp32c3-api1-20210207  
> Build:Feb 7 2021  
> rst:0x15 (USB\_UART\_CHIP\_RESET),boot:0x7 (DOWNLOAD(USB/UART0/1))  
> Saved PC:0x40047ab6  
> waiting for download

ps I just reflashed the C3 using a firmware that is explicitly listed on the Tasmota guide page. Identical results..  
All the evidence seems to be that these two ESPs cannot boot with the DS18B20 sensor connected, which is why I asked if anyone had had success with them, perhaps with different firmware.  
I think @waldbaer's post is about using a different firmware, but hardware too?

---

<div class="post-metadata">

**Author:** ![waldbaer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/waldbaer/32/74212_2.png) [@waldbaer](https://discourse.nodered.org/u/waldbaer)\
**Post date:** [25 January 2026 20:07 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/7 "2026-01-25T20:07:09Z")

</div>

I just developed in the last months a open source 1-Wire interface which can be accessed via ethernet/ MQTT protocol. It supports also the DS18B20 temperature sensor.

The board is based on the WT32-ETH01 using an ESP32.

> **[GitHub - waldbaer/1w-If: ESP32-based 1-Wire interface supporting access...](https://github.com/waldbaer/1w-If)**
>
> ESP32-based 1-Wire interface supporting access with physical ethernet and MQTT protocol

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [25 January 2026 20:35 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/8 "2026-01-25T20:35:50Z")

</div>

When I had these I used the Arduino IDE etc. using this [Guide for DS18B20 Temperature Sensor with Arduino | Random Nerd Tutorials](https://randomnerdtutorials.com/guide-for-ds18b20-temperature-sensor-with-arduino/) as a guide. (bog standard ESP32s not Arduino) Not sure if this will work for an ESP32C3

---

<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:** [26 January 2026 02:54 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/9 "2026-01-26T02:54:32Z")

</div>

> [@jbudd](#):
>
> (DOWNLOAD(USB/UART0/1))

That looks like the ESP is being set to flash mode, and not booting up.

So probably not an issue with the sensor as such, but more likely to do with which pins are being held high/low.

I have a few of those sensors connected to D1 minis, not sure I have any on an ESP32 as yet, but do plan to do so.

Check which pins you are using, on the ESP not all are suitable.

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [26 January 2026 05:14 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/10 "2026-01-26T05:14:51Z")

</div>

Although not considered de rigueur these days, in situations like this I would always build a simple few lines of firmware from bare metal. That way you can reduce as many variables as possible.

---

<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:** [26 January 2026 09:10 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/11 "2026-01-26T09:10:33Z")

</div>

> [@Sean-McG](#):
>
> That looks like the ESP is being set to flash mode, and not booting up.

Good point. Yes, it does look like the board is stuck in flash mode.  
I did take some care over which gpio pin to use, and the resistor is set to pull up, not down.  
I wonder if the initial current through the sensor is enough to pull down the voltage overall and thus start up in flash mode?

> [@Buckskin](#):
>
> When I had these I used the Arduino IDE etc.

I have now experimented with the Arduino ide and a larger development board, the Adafruit Feather32. It works fine,

> [@Bobo](#):
>
> build a simple few lines of firmware from bare metal.

I think that's outside of my skill set!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 January 2026 12:50 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/12 "2026-01-26T12:50:03Z")

</div>

> [@jbudd](#):
>
> > [@Bobo](#):
> >
> > build a simple few lines of firmware from bare metal.
> 
> I think that's outside of my skill set!

Personally, I use ESPHome rather than Tasmota these days. I've found it a lot more reliable and it is so easy to modularise sensor config so that you can reuse standard configs across many different board types. The modularisation also makes it easy to turn off/on different sensors which can help isolate issues. It has enormous hardware support and yet it still lets you easily dip into C++ should you need something custom. Configuration/build for any board is simply some YAML, no code required. MQTT is simple and customisable if you want it. An admin web interface is also available.

---

<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:** [26 January 2026 15:55 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/13 "2026-01-26T15:55:30Z")

</div>

> [@TotallyInformation](#):
>
> a lot more reliable

Objection - Hearsay and Subjective Evidence are not admissible  
🤣

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 January 2026 15:59 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/14 "2026-01-26T15:59:33Z")

</div>

> [@Sean-McG](#):
>
> Hearsay and Subjective Evidence are not admissible

How about tangible, real-world evidence then?!

I used to get regular device firmware crashes (requiring turning off and back on again) when using Tasmota, never had a single crash with ESPHome. Of course, this might no longer be the case, perhaps Tasmota has improved since I last tried it some years ago. And maybe newer ESP devices are less prone to crashing.

But even without that, I much prefer the specific configuration with ESPHome, I find it infinitely easier to work with and I get a lot of flexibility.

Still, each to their own of course.

---

<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:** [26 January 2026 16:16 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/15 "2026-01-26T16:16:14Z")

</div>

> [@TotallyInformation](#):
>
> I last tried it some years ago

That's my point really.

> [@TotallyInformation](#):
>
> Still, each to their own of course.

Absolutely true, and that's why I would advocate for Tasmota.

The berry scripting is very powerful, and combined with LVGL / OpenHasp compatibility, its not too hard to create a complete "product" with its own touch screen interface and logic.

Initial setup Comparison

| Feature | Tasmota (Sensors Binary) | ESPHome (YAML Config) |
| --- | --- | --- |
| **Initial Setup** | **Easier** (Flash once, use Web UI) | **Harder** (Write YAML, then compile) |
| **Adding Sensors** | **Point-and-click** in browser | **Edit YAML** and reflash |

😜

---

<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:** [26 January 2026 16:22 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/16 "2026-01-26T16:22:37Z")

</div>

I took a brief look at ESP Home a while back. Didn't get much further than the phrase "tightly integrated with Home Assistant".  
However, I like the thought that it permits changing devices connected to the ESP without reprogramming (as Tasmota does too of course)

I have a BME680 sensor on Tasmota which has sailed through a couple of years' power cuts and regular reboots of the wireless router.

But I went back to Arduino for this particular project and now I clearly recall why I abandoned it. Five minutes plus for each compilation, and that's only achievable after turning off my antivirus.

I do now have the ESP-C3 super mini working with two DS18B20s connected so I shall put it in a project box and stop struggling with Tasmota.

Thanks for all the suggestions. 😃

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 January 2026 16:44 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/17 "2026-01-26T16:44:45Z")

</div>

> [@Sean-McG](#):
>
> Initial setup Comparison

We can agree to differ. 😃

ESPHome also supports some none-ESP MC's.

ESPHome has documented support for nearly 600 peripherals, Tasmota has around 150 or so as best I can tell.

So yes, your initial platform setup is slightly more complex but then you are mostly creating a small device YAML and including any peripheral YAML from your ever-growing standard config files, most of which are simply copy/paste from the documentation.

ESPHome uses standard C++ embedded either as a header file or via a simple lambda statement, no need to learn another script language (only useful if you know a bit of C++ though I suppose). You very rarely need any scripting anyway in ESPHome as interactions between components is mostly already catered for.

The other advantage for ESPhome - coming back to my original comments. You only include what you absolutely need for each device so memory usage can be considerably lower.

So, use ESPhome for maximum flexibility and device efficiency. Use Tasmota for ease of initial use.

---

<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:** [26 January 2026 16:53 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/18 "2026-01-26T16:53:26Z")

</div>

> [@jbudd](#):
>
> ESP-C3 super mini working with two DS18B20s

It might be helpful to get to the bottom of this, as I do need to swap out a D1 for an ESP32, more likely to be an S2 mini, but will depend on price and availability I guess.

Can you tell me what gpios you used and exactly how it was wired up ?

---

<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:** [27 January 2026 01:28 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/19 "2026-01-27T01:28:07Z")

</div>

> [@Sean-McG](#):
>
> Can you tell me what gpios you used and exactly how it was wired up ?

Yes of course.

### Board
The device I used is an ESP32-C3 Super Mini. It's the cheapest of the ESP32 boards in this postage stamp size. I paid £1.40 each from Aliexpress. It has a USB C connector. They also do a dedicated "expansion board" with three dupont wire friendly pins for each of the board pins.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/855fdb01edb8d93234c9e310f78daf41de9c546f.jpeg)

### Wiring
Each DS18B20 has a unique id and you can connect multiple sensors, all wired to the same GPIO. There also has to be a single 4.7kOhm pull-up resistor. I connected two DS18B20s, using 3.3V & Gnd pins and GPIO 9

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/26516509cbf8a0dc6a150581e9000527aec6e9e0.jpeg)

Soldering less than ideal! Should have put the sensor wires through the holes and the resistor legs in the castellations.

### Arduino code
In order to flash the board over USB from the Arduino IDE I had to enable the option USB CDC On Boot, as explained at https://docs.espressif.com/projects/arduino-esp32/en/latest/tutorials/cdc\_dfu\_flash.html

Apparently this is not required for the S2 or S3 variant.

Temperature readings are sent via MQTT every 5 seconds.

The code was developed with the assistance of chatgpt and undoubtedly needs a good deal of fettling.

> **Click to see the current state of the code, not yet cleaned up**
>
> ```auto
> #include <WiFi.h>
> #include <PubSubClient.h>
> #include <OneWire.h>
> #include <DallasTemperature.h>
> #include <ArduinoJson.h> 
> 
> // ================= WiFi =================
> const char* ssid = "wifissid";
> const char* password = "password1";
> 
> // ================= MQTT =================
> const char* mqttServer = "192.168.1.11";
> const int mqttPort = 1883;
> const char* mqttUser = "mqttuser";
> const char* mqttPass = "password1";
> // topic "esp32c3/ds18b20" should be declared here
> 
> // ================= DS18B20 =================
> #define ONE_WIRE_BUS 9 // GPIO 9
> 
> OneWire oneWire(ONE_WIRE_BUS);
> DallasTemperature sensors(&oneWire);
> 
> DeviceAddress sensor1;
> DeviceAddress sensor2;
> 
> // ================= MQTT Client =================
> WiFiClient espClient;
> PubSubClient client(espClient);
> 
> // ---------- WiFi ----------
> void connectToWiFi() {
> Serial.print("Connecting to WiFi...");
> WiFi.begin(ssid, password);
> 
> while (WiFi.status() != WL_CONNECTED) {
> delay(1000);
> Serial.print(".");
> }
> Serial.println("\nConnected to WiFi");
> }
> 
> // ---------- MQTT ----------
> void connectToMQTT() {
> while (!client.connected()) {
> Serial.print("Attempting MQTT connection...");
> String clientId = "ESP32C3-" + WiFi.macAddress();
> 
> if (client.connect(clientId.c_str(), mqttUser, mqttPass)) {
> Serial.println("connected");
> } else {
> Serial.print("failed, rc=");
> Serial.println(client.state());
> delay(5000);
> }
> }
> }
> 
> void mqttCallback(char* topic, byte* payload, unsigned int length) {
> // Not used
> }
> 
> // ---------- Helper: print sensor address ----------
> String addressToString(DeviceAddress deviceAddress) {
> String addr = "";
> for (uint8_t i = 0; i < 8; i++) {
> if (deviceAddress[i] < 16) addr += "0";
> addr += String(deviceAddress[i], HEX);
> }
> return addr;
> }
> 
> void setup() {
> Serial.begin(115200);
> delay(1000);
> Serial.println("BOOTING");
> 
> // WiFi
> connectToWiFi();
> 
> // MQTT
> client.setServer(mqttServer, mqttPort);
> client.setCallback(mqttCallback);
> connectToMQTT();
> 
> // DS18B20
> sensors.begin();
> 
> int deviceCount = sensors.getDeviceCount();
> Serial.print("DS18B20 devices found: ");
> Serial.println(deviceCount);
> 
> if (deviceCount < 2) {
> Serial.println("ERROR: Less than 2 DS18B20 sensors detected!");
> }
> 
> // Get sensor addresses
> if (sensors.getAddress(sensor1, 0)) {
> Serial.print("Sensor 1 ID: ");
> Serial.println(addressToString(sensor1));
> }
> 
> if (sensors.getAddress(sensor2, 1)) {
> Serial.print("Sensor 2 ID: ");
> Serial.println(addressToString(sensor2));
> }
> 
> sensors.setResolution(12); // 12-bit resolution
> }
> 
> void loop() {
> if (!client.connected()) {
> connectToMQTT();
> }
> client.loop();
> 
> static unsigned long lastPublish = 0;
> if (millis() - lastPublish >= 5000) {
> lastPublish = millis();
> 
> sensors.requestTemperatures();
> 
> float temp1 = sensors.getTempC(sensor1);
> float temp2 = sensors.getTempC(sensor2);
> 
> // Create a JSON document
> DynamicJsonDocument doc(1024);
> 
> // Create an array in the JSON document
> JsonArray sensorData = doc.createNestedArray("sensors");
> 
> // Add sensor data to the JSON array
> JsonObject sensor1Data = sensorData.createNestedObject();
> sensor1Data["sensor"] = addressToString(sensor1);
> sensor1Data["temperature"] = temp1;
> sensor1Data["millis"] = lastPublish;
> 
> JsonObject sensor2Data = sensorData.createNestedObject();
> sensor2Data["sensor"] = addressToString(sensor2);
> sensor2Data["temperature"] = temp2;
> sensor2Data["millis"] = lastPublish;
> 
> // Serialize JSON document to a string
> String output;
> serializeJson(doc, output);
> 
> // Publish the JSON data
> if (output != "[]") {
> client.publish("esp32c3/ds18b20", output.c_str(), true);
> Serial.println("Published sensor data:");
> Serial.println(output);
> } else {
> Serial.println("No valid data to publish.");
> }
> }
> }
> 
> ```

---

<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:** [27 January 2026 01:46 UTC](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239/20 "2026-01-27T01:46:00Z")

</div>

> [@jbudd](#):
>
> ESP32-C3 Super Mini

OK that explains the problem, a bad choice of GPIO 😀

| GPIO9 Input | Mode |
| --- | --- |
| Low/GND | ROM serial bootloader for esptool |
| High/VCC | Normal execution mode |

The DS18B20 waits 15–60µs and then pulls the line low for 60–240µs to indicate it is present on the bus, this is likely why you get stuck in flash mode when its connected.

The best pins to use are **GPIOs 0, 1, 3, 4, 5, 6, 7, and 10** for general-purpose use, while pins **GPIO2, GPIO8, GPIO9, GPIO20, and GPIO21** should be used with caution or avoided due to their roles as strapping pins, onboard components, or default UART communication

[Next page](https://discourse.nodered.org/t/ds18b20-sensor-s-on-esp/100239.md?page=2)
