Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18B20: blocking time to time #230

Open
loraraspi91 opened this issue Oct 19, 2022 · 16 comments
Open

18B20: blocking time to time #230

loraraspi91 opened this issue Oct 19, 2022 · 16 comments

Comments

@loraraspi91
Copy link

I use your library to read periodically the temperature with a 18B20. its works fine but after some time (few hours) the reading is block and I need to reset the 18B20 by calling a reset on the OneWire Bus: _wire->reset() to be able to restart and to read again the temperature.

I think it could be a good idea to add a new "Reset" function, so we can call it to reset time to time the temperature device to prevent possible blocking.

@milesburton
Copy link
Owner

milesburton commented Oct 19, 2022 via email

@loraraspi91
Copy link
Author

I have a peridioc reading temperature on my ESP32 do this :
while (1) {
vTaskDelay(5000/ portTICK_PERIOD_MS);
sensors.begin();
sensors.requestTemperatures();
tmp = sensors.getTempCByIndex(0);
esp_task_wdt_reset();
}

for your information: DallasTemperature sensors(&oneWire);

And for unknown reason, the reading is blocking (the watchdog is activate after 40 seconds), so I need to kill the task, reset the device (_wire->reset()) and restart the task to be able to read again the temperature of my 18B20 device.

@Frans412
Copy link

The program in which this sensor is used keeps crashing.

In a small test setup, I removed various connections one by one several times, including the pullup resistor. The program may then crash and become impossible to restart. Only a reset made the program start again.

What I did do is to place the pullup resistor near the sensor. This was located on the circuit board near the processor (arduino nano). There is a 1 meter cable between them. By placing the pullup resistor near the sensor, I have closed the cable with low impedance, and therefore made it less susceptible to interference, I hope.
I have not yet been able to do a long-term test.

But in general I find it strange that a library of a sensor can block the program.

Does anyone have a solution?
Frans412

@RobTillaart
Copy link
Contributor

The program in which this sensor is used keeps crashing.

I cannot see your code(sketch), your hardware setup (board, parasite power, power supply? how many sensors?) or environment (noise? shielded wires?) so it is difficult to investigate the cause.

As this is one of the most and longest used (and therefor tested) libraries in the Arduino ecosystem I doubt it is a library problem. However that in itself is no guarantee there are no bugs left in it or in the underlying onewire library.

How frequent do you read the sensor? resolution?
Can you identify the blocking call in the library?
Do you have an oscilloscope to analyze the signal quality of the pulses on the data line?
Do you have a logic analyzer to see where the communication stops?

@Frans412
Copy link

Frans412 commented Jan 27, 2024 via email

@RobTillaart
Copy link
Contributor

OK,

What voltage do you power your Nano?

What resistor do you use, for 1 meter I would use a 2200 Ohm.
If the resistor is too large, the signal will not be "square" enough and 0's and 1's could get mixed up.

Can you run the example Timing.ino and post its output?
NB there are counterfeit versions of the DS18B20, some of them can be detected by their timing.

Do you have a multimeter?
Can you measure the voltage at the sensors end?

@Frans412
Copy link

Frans412 commented Jan 27, 2024 via email

@RobTillaart
Copy link
Contributor

The resistance is standard 4k7. Should I lower it to 2k2?

Yes, that will pull the level to 5V roughly twice as fast.

A search for timing.ino on the arduino website yields nothing. I can't find
anything on Google either.

timing .ino is an example of this library.

[image: image.png]
Here is a photo of the data from the SD18B20.

Not uploaded correctly apparently

@Frans412
Copy link

Frans412 commented Jan 27, 2024 via email

@RobTillaart
Copy link
Contributor

Can you run the example Timing.ino and post its output?

I need to see the actual output.

Current time is always approximately 751 millisec.

Timing should give different results for different resolutions.

I have included 2 attachments.
IMG_5247 is with pullup of 4k7,
IMG_5249 is with pullup of 2k2.

No images again.

@Frans412
Copy link

Frans412 commented Jan 28, 2024 via email

@Frans412
Copy link

Frans412 commented Jan 29, 2024 via email

@RobTillaart
Copy link
Contributor

It looks like the sensor is constant in 9 bit mode, it could be counterfeit.

Please have a look at - https://github.com/cpetrich/counterfeit_DS18B20

@Frans412
Copy link

Frans412 commented Jan 29, 2024 via email

@RobTillaart
Copy link
Contributor

RobTillaart commented Jan 30, 2024

Please post the full output of

  • discover_fake_DS18B20.ino and
  • classify_fake_DS18B20.ino

These test several things and help to classify the sensor.
According to https://github.com/cpetrich/counterfeit_DS18B20 the place where you bought it is also an indication.

@Frans412
Copy link

Frans412 commented Jan 30, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants