RobTillaart / DS18B20_RT

Arduino library for the DS18B20 sensor - restricted to one sensor per pin.
MIT License
24 stars 9 forks source link

DS18B20 Library Using an ATTiny1604 #31

Closed renejeanmercier closed 5 months ago

renejeanmercier commented 5 months ago

Hello Mr. Tillaart.

I remembered your good advice in august last year on how to distinguish between a MAX6675 and a MAX31855 mounted in a same circuit. Thank you again.

This time I come to you with an awkward problem. I try to use your library on an ATTiny1604 without success. I have no problem running the library on an ATTiny85, but with the ATTiny1604 , I cannot even see any activity on the pin PIN_PB0 (...I tried all the other pins as well). The circuit is the usual one with an active external 4k7 pullup to +5V. HardwareSerial connected (on pin PIM_PB2/PIN_PB3) works fine. I can use digitalWrite and digitalRead without any problems (the pin toggles fine, and reports the right values). I tried the library of Mr. Burton and the one of Mr. Stoffregen without success and with the same symptom (i.e. the pin stays high and does not show any activity on the oscilloscope).

I use the jtag2UPDI device built with and Arduino Nano that work flawlessly. I tried using both the Arduino IDE (1.8.19 and 2.3.2) and PlatformIO. The examples you give are loading fine and no load error is reported.

Was the problem reported to you before my present message?

Would you have a suggestion or solution or request for troubleshooting for me?

Thank you very much for your help.

Regards,

Rene-Jean Mercier

RobTillaart commented 5 months ago

Welcome back, Never used the specific device so I need to do some reading tomorrow. Which onewire lib do you use? Have you tried onewire-ng as replacement?

To be continued

RobTillaart commented 5 months ago

You could try the onewirescanner.ino example sketch. Also try ds18b20_int library, this uses no floating point math so preserves memory. In case it is a runtime memory problem.

renejeanmercier commented 5 months ago

Thank you for your quick reply.

I use this one lib_deps = paulstoffregen/OneWire@^2.3.8

But I will try the one you suggest tomorrow.

Regards,

RJMercier

Le jeu. 25 avr. 2024, à 21 h 47, Rob Tillaart @.***> a écrit :

Welcome back, Never used the specific device so I need to do some reading tomorrow. Which onewire lib do you use? Have you tried onewire-ng as replacement?

To be continued

— Reply to this email directly, view it on GitHub https://github.com/RobTillaart/DS18B20_RT/issues/31#issuecomment-2078484963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGFVP36RFQ4YBPBG4GGJ6GLY7GW3VAVCNFSM6AAAAABGZ3ML26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZYGQ4DIOJWGM . You are receiving this because you authored the thread.Message ID: @.***>

renejeanmercier commented 5 months ago

In fact I tried both. _INT and _RT. Same result. No activity on the pin.

I also tried the scanner. Same result. No activity on the pin.

Le jeu. 25 avr. 2024, à 22 h 02, Rob Tillaart @.***> a écrit :

You could try the onewirescanner.ino example sketch. Also try ds18b20_int library, this uses no floating point math so preserves memory. In case it is a runtime memory problem.

— Reply to this email directly, view it on GitHub https://github.com/RobTillaart/DS18B20_RT/issues/31#issuecomment-2078495831, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGFVP3YFQ2MPMDQT2K3T7F3Y7GYSPAVCNFSM6AAAAABGZ3ML26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZYGQ4TKOBTGE . You are receiving this because you authored the thread.Message ID: @.***>

renejeanmercier commented 5 months ago

Hello Mr. Tillaart.

I could not go to bed before having tested your recommendation (i.e. the OneWire-Ng). I have been working on this for four days without success. :-(.

And your suggestion was GOOD ! It works !!!!!

I used the example in the library of Mr. PStolarz called Dallas Temperature.ino (compiled and loaded by PlatformIO).

It is "heavy" on flash memory though. Here is what PlatformIO reports; Checking size .pio/build/ATtiny1604/firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [== ] 19.2% (used 197 bytes from 1024 bytes) Flash: [=== ] 34.3% (used 5617 bytes from 16384 bytes) Building .pio/build/ATtiny1604/firmware.hex

You might want to adapt it to your _INT version --that I used on another project-- using the ATTiny85. It has a little footprint and it is very well adapted for ATTiny application.

If you do something in that route, You can count on me for testing it on the ATTiny1604.

Best regards,

René-Jean Mercier

renejeanmercier commented 5 months ago

Mr. Tillaart,

I also found that the one from SpencerKone (https://github.com/SpenceKonde/OneWire/tree/master) also works !!!! The person who wrote jtag2UPDI.

Using the example of his library : DS18x20_Temperature.pde, PlatformIO reports : Checking size .pio/build/ATtiny1604/firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [== ] 20.4% (used 209 bytes from 1024 bytes) Flash: [==== ] 38.7% (used 6333 bytes from 16384 bytes) Building .pio/build/ATtiny1604/firmware.hex

Thank you so much. And as mentioned before, if you do any adaptation to reduce the footprint, I will test for you.

Regards,

René-Jean Mercier

RobTillaart commented 5 months ago

Goodmorning,

Thanks for testing in the middle of the night. At least I should make a section about these findings in the readme.md file of the DS18B20_INT library which was written with small footprint in mind.

Possibly in all onewire related libs, sort of general statement on memory usage, including the links.

It might also mean that the dependency mentioned in the library.json file could change.

RobTillaart commented 5 months ago

I also found that the one from SpencerKone (https://github.com/SpenceKonde/OneWire/tree/master) also works !!!! The person who wrote jtag2UPDI.

This is a fork of the onewire library from Paul Stoffregen, several commits behind which might explain the smaller footprint. A quick check shows that there are about 380 forks of Paul's work so probably there are a few dozen more that might work.

My libraries that refer to oneWire: DS1821, DS18B20_INT, DS18B20, DS2401, DS2438, MAX31850 (some updating todo)

RobTillaart commented 5 months ago

Did a test run for Arduino UNO and OneWireNg resulted in a larger footprint for DS18B20_INT. So depending on the platform footprint "winner" differs.

OK, that said I think this issue is solved for now and can be closed.

renejeanmercier commented 5 months ago

Hello Mr. Tillaart,

In trying to reply to your last question, here are the results that I got on PlatformIO UNO (an original and a clone).

I believe that if you decide to optimize and integrate the Mr. Konde and/or Mr. Stolarz OnWire library by taking the best of both and making it in the style of your functions (like requestTemperatures(void); getTempC(void); ...easier to visualize), working on both 328 and the recent ATTiny series-0/1/2 and a smaller footprint, that would be winner. My offer to test still stands.

==========

Uno 328P (original Arduino and a Clone)_With Piotr Stolarz OneWire : Dependency Graph |-- OneWireNg @ 0.13.3 Building in release mode Checking size .pio/build/uno_mini/firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [== ] 22.8% (used 466 bytes from 2048 bytes) Flash: [== ] 21.4% (used 6892 bytes from 32256 bytes)

=========

Uno 328P (original Arduino and a Clone)_With Piotr Stolarz OneWire (one sensor option): /*

=========

Uno 328P (original Arduino and a Clone)_With Spence Konde OneWire  Dependency Graph |-- OneWire @ 2.3.5 Building in release mode Checking size .pio/build/uno/firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [== ] 19.6% (used 402 bytes from 2048 bytes) Flash: [== ] 16.3% (used 5266 bytes from 32256 bytes)

(updated layout)

RobTillaart commented 5 months ago

Thanks for the measurements. It gives extra context and food for thoughts.

RobTillaart commented 5 months ago

Had a look at the oneWire code, about 1300 lines, written over last 17 years. Quite optimized per processor already, it will be hard and time consuming to even match this level. So not my challenge.

The library may be configured with 1-wire search activity disabled to reduce its footprint.

You can do that with the (Paul Stoffregen) onewire library too

See onewire.h about line 30

// you can exclude onewire_search by defining that to 0
#ifndef ONEWIRE_SEARCH
#define ONEWIRE_SEARCH 1
#endif

Might be worth a try to reduce footprint.

RobTillaart commented 5 months ago

As the original problem is solved I close the issue.

renejeanmercier commented 5 months ago

Hello Mr. Tillaart,

Thank you so much.

I will try and let you know.

Regards,

René-Jean Mercier

Le ven. 10 mai 2024, à 10 h 26, Rob Tillaart @.***> a écrit :

Closed #31 https://github.com/RobTillaart/DS18B20_RT/issues/31 as completed.

— Reply to this email directly, view it on GitHub https://github.com/RobTillaart/DS18B20_RT/issues/31#event-12770488230, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGFVP3ZEFDI7MKCVCFFPW5TZBTKKVAVCNFSM6AAAAABGZ3ML26VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSG43TANBYHAZDGMA . You are receiving this because you authored the thread.Message ID: @.***>