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

DS18B20 Library Using an ATTiny1604 #31

Closed
renejeanmercier opened this issue Apr 26, 2024 · 14 comments
Closed

DS18B20 Library Using an ATTiny1604 #31

renejeanmercier opened this issue Apr 26, 2024 · 14 comments
Assignees
Labels
question Further information is requested

Comments

@renejeanmercier
Copy link

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 RobTillaart self-assigned this Apr 26, 2024
@RobTillaart RobTillaart added the question Further information is requested label Apr 26, 2024
@RobTillaart
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

renejeanmercier commented Apr 26, 2024 via email

@renejeanmercier
Copy link
Author

renejeanmercier commented Apr 26, 2024 via email

@renejeanmercier
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

renejeanmercier commented Apr 26, 2024

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):
/*

  • If defined: only one sensor device is allowed to be connected to the bus.
  • The library may be configured with 1-wire search activity disabled to
  • reduce its footprint.
    */
    #define SINGLE_SENSOR
    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: [== ] 23.1% (used 473 bytes from 2048 bytes)
    Flash: [== ] 19.4% (used 6256 bytes from 32256 bytes)

=========

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
Copy link
Owner

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

@RobTillaart
Copy link
Owner

RobTillaart commented Apr 27, 2024

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
Copy link
Owner

As the original problem is solved I close the issue.

@renejeanmercier
Copy link
Author

renejeanmercier commented May 10, 2024 via email

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

No branches or pull requests

2 participants