DS18B20/OneWire and pinMode/digitalRead: PIN stuck HIGH

Hello,

I'm experiencing a strange behavior that I was able to reproduce in two Arduino 2560 boards. I had a Dallas temperature sensor connected to digital pin 30, trying to read values:

DS18B20 ds(30);
define ONEWIRE_SEARCH 0;
// main loop:
Serial.println("Temp: " + String(ds.getTempC()) + " at " + String(millis()) + "ms" );

All working until by mistake I also wrote a pinMode/digitalRead pointed to the same pin where the sensor was.

I was expecting to have a push botton in that ping and wrote the following code:

pinMode(30, INPUT);
// main loop:
Serial.println(digitalRead(30));

I powered the board and the noticed issue. As expected the sensor didn't work. After moving the sensor to another pin I noticed that PIN 30 was always HIGH from this point - even without anything connected to it.

I replicated this "experiment" in another board and got the same result. Now I've two boards with PIN 30 always readingHIGH.

Is there any reason why this happened? Does the GitHub - matmunk/DS18B20: Arduino library for the Maxim Integrated DS18B20 1-Wire temperature sensor. library / 1 wire set anything in the microcontroller that can result in this behavior even after reprogramming with a different program? Is it even fixable?

A new program like this:

void setup() {
  Serial.begin(9600);
  Serial.println("Setup!");
  pinMode(30, INPUT);
}

void loop() {
   delay(1000);
   Serial.println(digitalRead(30));
}

Is always outputting "1" now on that pin, even if nothing is connected to it.

Thank you.

What is the output if you connect pin 30 to GND ?

Connected to ground is always LOW. Thank you.

Do you understand why ?

If you help me understand maybe... In theory I would say that the pin is basically fluctuating because nothing be it 5v or ground is connected to it but...

I'm not sure why the behavior is different with all other digital pins. It's just this one that does this... and only happened after using the sensor in two boards. Was it a coincidence?

It sounds like a coincidence to me