PaulStoffregen / OneWire

Library for Dallas/Maxim 1-Wire Chips
http://www.pjrc.com/teensy/td_libs_OneWire.html
579 stars 382 forks source link

DS1820 temperature readings ESP32 in combination with FreeRTOS tasks leads to malfunction of the RMT Module #142

Open sirpete83 opened 1 month ago

sirpete83 commented 1 month ago

ESP32 Wemos Lolin32

sketch with 3 additional FreeRTOS tasks leads to a significant lengthening of the set poriodes of the rmt module. I was able to narrow it down to the Onewire or the Dalles temperature library. If I remove Onewire completely from the sketch, then the times are correct again. which surprises me a bit, because the onewire library doesn't seem to use rmt. And it's just fed with data and then runs in hardware, at least that's my assumption. can someone confirm the problem?

sirpete83 commented 1 month ago

Hallo, I looked at the OneWire code again and saw that this library deactivates the interrupts in order to maintain the timings. It's certainly not a problem for non-RTOS applications. But it will certainly stop all hardware timers and thus halt the tasks. I don't expect a solution to the problem, but perhaps this insight will help others if they encounter timing problems in their RTOs application when using this library.

tshcherban commented 3 weeks ago

There is a RMT-based OneWire library, so if you have a free RMT channel - u can use it for onewire communication

uzi18 commented 2 weeks ago

just try OneWireNg library https://github.com/pstolarz/OneWireNg

It supports OD:

All bus activities are performed respecting open-drain character of the 1-wire protocol.

During normal 1-wire activities, the master MCU GPIO controlling the bus is never set high 
(providing direct voltage source on the bus) instead the GPIO is switched to the reading mode 
causing the high state seen on the bus via the pull-up resistor.