I have run into some problems with the use of esp32 and dallas ds18B20 temperature sensors, as I can’t get readings out of them.
The esp32 is a DOIT ESP32 devkit v1 and the sensors are the standard type through the hole and/or the ones that have 1-1.5 meter cable and are watertight.
I suspect that it is library issue with the esp32 as the same libs work fine with arduino uno, mini etc. Cable connections have been checked many times. I have used the following libraries installed from inside arduino IDE:
- OneWire by Paul Stoffregen v.2.3.6 (https://www.pjrc.com/teensy/td_libs_OneWire.html)
- DallasTemperature by Miles Burton v.3.9.0 (https://github.com/milesburton/Arduino-Temperature-Control-Library)
Could somebody please point out to me a working set of libraries that have been successful for you?
Edit: There is a similar question here:ESP32: dsb1820 temperature sensor giving constant negative 127 reading but I don't think that it is solved.
Here is my includes and pin definition:
/************************* Dallas Temperature probes ********************************/
#include <OneWire.h>
#include <DallasTemperature.h>
const int oneWireBus = 26; // GPIO5 in esp32
const int TEMPERATURE_PRECISION = 12; //12bit precision 0.01 steps
The resistor and setup is the same.