Hello. I have a problem reading the DS18D20 sensor on an Arduino Nano ESP32. The sensor works without any issues on the Leonardo. I have checked all the connections, the voltage on the Vcc and Data lines is correct, and the connection between the Nano and the serial port is all good, but the sensor is not detected at all. The latest libraries are installed, and the Arduino IDE is also up to date. Why is the Dallas sensor not working on the Nano ESP32? Does anyone have any ideas?
Welcome to the forum
What voltage does the sensor require and how is it connected to the Nano ?
I will take a SWAG, I do not have either processor. Is the clock speed to great for the sensor, that would normally be controlled by the library. If you have the wrong library that might explain it.
Hi @bartrcki007, as was previously noted here, the default pin mapping configuration of the Nano ESP32 board definition is not compatible with some libraries which have general ESP32 support, but don't target the Nano ESP32 specifically.
The "DallasTemperature" library (or more specifically DallasTemperature's "OneWire" dependency) is one of these libraries.
You can adjust the configuration of the Nano ESP32 pin mapping for compatibility with this library by selecting Tools > Pin Numbering > By GPIO number (legacy) from the Arduino IDE menus. After doing that, upload the sketch to the Nano ESP32 board again. You should find the sensor is now detected by the board and works as expected.
Please note that when the "By GPIO number (legacy)" option is selected, you can no longer use integer pin numbers matching the labels on the Nano ESP32 board. The pins are now mapped to the integer numbers of the GPIO on the ESP32 microcontroller. If you would like your code to work whichever Tools > Pin Numbering menu item is selected, you can use the names exactly matching the labels on the board in your code instead of integers (e.g., D2
instead of 2
). The values of these macros are automatically adjusted to always match the labeled pin.
More information here: