Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By karman
#24989 DS1820 works fine on older firmware (Feb) but on the new ones you can detect the sensor, but reading it just return 255 every time.

anyone else been able to get to work on latest firmware ?
User avatar
By Midori
#35349 viewtopic.php?f=29&t=2302&start=15

Probably I found the solution of this issue.
Please put the incantation in your code to a trial, like this.

Code: Select allOneWire  ds(2);  // on pin 2 (a 4.7K resistor is necessary)

void setup(void) {
  digitalWrite(2, HIGH);   // <- incantation code: same number as OneWire port
  pinMode(2, OUTPUT);   //<- incantation code: same number as OneWire port
  Serial.begin(9600);
}


It may be that the original library made OneWire port "open drain" mode.

DS18B20 needs 1mA to convert temperature.
But "open drain" mode cannot provide this current.
The "pinMode" function resolves this issue by changeing the port mode to OUTPUT.
If you use parasitic mode, Strong Pull-up is necessary during conversion.
This Strong Pull-up is accomplished by high-side transistor of output port.

I don't know which code in the library causes problem.
But I observed behavior of signal voltage by oscilloscope.
I found the voltage dropping after conversion command.
After I added "digitalWrite" and "pinMode" in setup routine, the voltage dropping didn't occur.
I wish this issue is resolved by correction of the library.
Sorry, I can't.
User avatar
By martinayotte
#35363
Midori wrote:But "open drain" mode cannot provide this current.
The "pinMode" function resolves this issue by changeing the port mode to OUTPUT.
If you use parasitic mode, Strong Pull-up is necessary during conversion.
This Strong Pull-up is accomplished by high-side transistor of output port.

This is a nice work-around !
But, I don't think any libraries will do that kind of hack, because the normal way to do parasitic mode is to have a separate power source using a MOSFET controlled by a separate GPIO, as mentioned in the Dallas specs :
https://datasheets.maximintegrated.com/ ... 20-PAR.pdf
This is espacially true if you have multiple sensors on the same line, therefore, maybe your hack won't be able to provide enough current if there are 10 sensors, GPIO current source been limited with Imax of 12mA.