Hi @scout01 .
First make sure your jumpers are good and that they are wired as per your schematic.
If you have a multimeter, measure the resistance between the OUTPUT pin and the +VCC and see if you find the value equal to or less than 4K7.
If not, then for testing connect a 4K7 resistor between arduino pin 2 and +VCC of arduino.
I have checked my cables and also changed them out to eleminate this posibility.
I only have a pretty cheap old multimeter that couldn't really get an exact reading.
I will try to lend one which is better.
@Nick_Pyner in which way do you mean that i could have abused it?
Another concern of mine is the code.
My lecturer from University said that there could be something wrong with the librarys.
But because the code came with the module, i didn't consider it to be the problem.
I disagree. It might just as well be a current limiting resistor for the smd LED that's right beside it.
@scout01, get a digital multimeter and measure the resistance between pins 2 & 3 on your module (while it's not connected to anything else). If you get a reading that's higher than 4700Ohms or even an out of range value ('infinite' resistance), you need to add a pullup resistor.
//12-bit default resolution; external power supply
byte addr; //to hold 64-bit ROM Codes of DS1
byte data; //buffer to hold data coming from DS18B20
ds.search(addr); //collect 64-bit ROM code from sensor
ds.reset(); //bring 1-Wire into idle state
ds.select(addr); //slect with DS-1 with address addr1
ds.write(0x44); //conversion command
delay(1000); //data ready withinh DS18B20 or poll status word
ds.select(addr); //selectimg the desired DS18B20
ds.write(0xBE); //Function command to read Scratchpad Memory (9Byte)
ds.read_bytes(data, 9); //data comes from DS and are saved into buffer data
int16_t raw = (data << 8) | data; //---data and data contains temperature data : 12-bit resolution-----
celsius = (float)raw / 16.0; //12-bit resolution
Thanks for all your help and suggestions.
Turns out that the module itself does need the extra pullup resistor.
The existing resistor really is only for the LED above it.
But also i got the oppurtunity to test my code and setup with another module like mine and as i suspected my sensor is simply dead. Probaly from the factory itself because another sensor from the set also turned out to be defect.
With the new sensor my code worked perfectly and immediately sends data.
That means the -127 also could mean that the sensor is broken.
Its common with multidrop busses like the OneWire bus to not include termination or pullup resistors in every module, since termination resistors should only be at the ends of a bus, and there should only be one pullup resistor so that its value is correct - having 12 modules on the same bus each with a 4k7 resistor would give 391 ohms, far too low...
God yes, I should have seen that. .... The idea of having a pullup for every sensor is stupid and should never happen. I guess I was suckered by the resistor value. And what's a LED doing there anyway?