I've tried almost everything but the sensor is still showing -127 degrees. No matter which diagram or code i use it doesn't change anything at all. I downloaded the libraries and used diagrams with and without resistance. I also tried using 2 temperature sensors because my professor said so. I tried using analog pins as well as digital ones. Still nothing works.
Your sketch with little modification is working fine with my ESP8266 based NodeMCU.
Output:
Temperature is: 25.56
Temperature is: 25.50
Temperature is: 25.56
Temperature is: 25.88
Temperature is: 25.63
Temperature is: 25.94
1. Connect Data-pin of sensor with D4-pin of the board. 2. (1) Change this line: int oneWireBus = 3; to the following: int oneWireBus = 2; (2) Use direct one jumper for one connection. (3) Use 2.2k to 4.7k resistor between Data-pin and Vcc (3.3V). (4) Do not use TX (GPIO-1) and RX (GOPIO-3) pins of the ESP8266 as they are engaged with PC/IDE/SM. (5) Pin diagram (Fig-1) of DS18B20 temperature sensor.
Figure-1: