ESP8266 can't detect DS18B20 Temperature Sensor

OP has "generic esp8266 board" selected, afaik it doesn't map D-pins anywhere.

If you use the pin number without the 'D' prefix, it will be always referring to the 'actual' GPIO pin number, so never to the silk DX printing. But as i said. Plug one in and test for yourself.

So simple.
Whole Dx / Ax mapping was maybe good idea 20years ago, but nowadays with hundreds of boards, to my opinion, it's just confusing at best.

Since you don't a DMM, let's use use the ESP8266 to measure the voltage on the DS18b20 output.
Temporarily connect the DS18b20 output (your yellow wire) to A0 and run this code. The ADC value should be close to 1023.


const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0

int ADCValue = 0;

void setup() {

  Serial.begin(115200);
}

void loop() {
  // read the analog in value
  ADCValue = analogRead(analogInPin);

  // print the readings in the Serial Monitor
  Serial.print("ADC = ");
  Serial.println(ADCValue);

  delay(1000);
}

Because of external pull-up resistor, the output of DS18B20 may be 0V or 3.3V; as a result, your experiment my produce 0 or 1023.

You have several topics ESP-related, the common theme being "not working". It looks like you should do some "blink" stuff, get a handle on the GPIO v. "D" schemes.

Uhm, yes because I'm doing my Uni project about this. What do you mean about "blink" stuff and "D" schemes?

I wonder what the subject is.

A blink an LED sketch - so you know where the blink comes from when you're using GPIO numbers and your 'board' is marked up with D2, D5, and so on, programming for fundamental understanding.

are pin D2 D4 etc defined? it depends on the Tools>Board selected
try the following code

// ESP8266 are D2 and D4 defined ???

// NO  -Tools>Board select Generic ESP8266 module
// YES -Tools>Board select NodeMCU 1.0 (ESP-12 Module)

void setup() {
  Serial.begin(115200);
  Serial.println("\n\nESP8266 D2 and D4");
  Serial.println(D2);
  Serial.println(D4);
}

void loop() {}

if compiled with Tools>Boards "Generic ESP8266 module" selected the following compile time errors are displayed

F:\Ardunio\Networking\WiFi\ESP8266\Pins_Defined\Pins_Defined.ino: In function 'void setup()':
F:\Ardunio\Networking\WiFi\ESP8266\Pins_Defined\Pins_Defined.ino:9:18: error: 'D2' was not declared in this scope
    9 |   Serial.println(D2);
      |                  ^~
F:\Ardunio\Networking\WiFi\ESP8266\Pins_Defined\Pins_Defined.ino:10:18: error: 'D4' was not declared in this scope
   10 |   Serial.println(D4);
      |                  ^~
exit status 1

Compilation error: 'D2' was not declared in this scope

if compiled with Tools>Boards "NodeMCU 1.0 (ESP-12 Module)" selected it compiles, links, uploads and runs - serial monitor displays

ESP8266 D2 and D4
4
2

I generally use GPIO numbers not D2, D4 etc

Really, I thought it would be 100V and 10000V.
Thanks for clarifying.

100V and 10000V?

The confusion tends to be in the ESP8266 nodeMCU boards where the silk print uses Dx and this just doesn't match the GPIO count of the ESP8266 unit. I think other ESP8266 devboards copied that, resulting in a 'Dx != GPIO x' which is super confusing. I don't know of any other board series with similar issues.

agreed!
for ESP8266 boards I tend to refer to esp8266-pinout-reference-gpios and use the GPIO numbers

The Uno
D8 != PB8

Never owned one, but Nano Esp32 pinout looks pretty confusing to me. For example SDA pin is Gpio11 aka A4 aka D21...

Eh yeah, well that is not what i mean. The silk says 8 which = D8, PB0 is simply the location in the register.

One not even do

digitalWrite(PB0, HIGH) and does that actually result

(it compiles but does not have the intended outcome)

The Nano ESP32 is confusing in general, but the designers were attempting to keep the pinout correspond with the classic Nano.

They almost succeeded with the exception of the analog input pins not matching their digital pin numbers compared to the Classic Nano (where A0 == D14) I anyway don't think you can reference the pins with their GPIO nr, if i remember correctly Dx == x

Have you defined the direction of PB0 as output?

Yep, on top of that you can choose between arduino mode and legacy mode for pin numbering. And if I open pins_arduino.h I get even more confused..

Well it is a completely different processor and the pinNrs of the ESP may be what you want for certain libraries. I think they added it afterwards to compensate for a whole bunch of libraries not working anymore.