Chat here about code rewrites, mods, etc... with respect to the github project https://github.com/esp8266/Arduino

Moderator: igrr

User avatar
By jh1995
#20891 Hello.
A sketch that uses OneWire to talk with a DS18B20 worked fine with IDE 1.6.1 downloaded on May 5th, 2015. When I recompiled the same sketch with 1.6.4 add-on downloaded on June 17th, 2015, 1wire bus could not be read properly anymore. All I could get was the sensor ID/MAC address but not temperatures.

I investigated the ESP8266 OneWire library and found a commit to activate the internal pullup resistor just a couple of days after my working compile:
https://github.com/esp8266/Arduino/blob/esp8266/libraries/OneWire/OneWire.cpp

Why? Why has Links2004 forced the pin as INPUT_PULLUP? The OneWire bus specification requires a well defined pull-up resistor, 4k7. With the ESP8266 pullup active, the resistor value becomes chip dependant, somehow unknown and hard to define for complex installations with many 1wire slaves. Not counting that existing implementations with an external resistor need a hardware mod to work with newer code.

I invite "Links2004" to roll back the definition at line 122 and restore pinMode as INPUT. Then add an optional parameter, a function() or a #define that lets the programmer override the default INPUT value.

I am now using the old library version and everything is fine again.
User avatar
By martinayotte
#20927 I don't understand why activating an internal pullup can disturb an OneWire bus.
Generally, internal pullups are weak, usually around 10K or even more such 47K, having those in parallel with an 4K7 external one should not have any effect.
I'm suspecting more the core code itself or SDK, maybe the INPUT_PULLUP is not activating the pin pullup properly and create a short instead. It needs to be verified ...