0
\$\begingroup\$

I would like to make a simple thermal switch with attiny25 but first I need to read the temperature values from the ds18b20 sensor. I found some codes, here are the sources: DS18B20 lib UART lib

I need to use this uart implementation because the attiny25 does not have. The UART function works well if I send characters but with the temperatures from the sensor it fails. I use the default 1MHz clock speed and 2400 baudrate.

I think the schematic is good, there is the 4,7kOhm pullup, and the data wire is connected. Vdd is 5V.

Could somebody help me please where to find the problem? All of "my" code is here

Here is the onewire communication, is it good? onewire communication

EDIT1:

Raised clock speed to 8Mhz, here is the 1Wire communication: enter image description here And the uart: enter image description here

_delay_ms(1000) function is actually 0,9813s. Is it possible, that the _delay_us() function is not very accurate so i got wrong timings?

EDIT2:

The reset condition was not enough, but that's not solved the problem. Output of the onewire communication: enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ the DS18B20 lib comes with an example .... does the example work for you? \$\endgroup\$
    – jsotola
    Jan 31, 2019 at 23:50
  • 1
    \$\begingroup\$ A very much doubt anyone on this website is dedicated enough to download that archive and try to debug it. Could you create a small self-contained example that shows the issue, and then post the code in the question? (Even if you get no answer, having a small bug reproducer helps a lot when debugging) \$\endgroup\$
    – domen
    Feb 1, 2019 at 9:27
  • \$\begingroup\$ Going just by the described question, it's apparent there's an issue when soft 1-w and soft uart are interacting. I'm guessing, possibly one or both have interrupts that well ... interrupt the other, and introduce some delay in transfer, making it fail. \$\endgroup\$
    – domen
    Feb 1, 2019 at 9:29
  • \$\begingroup\$ @jsotola no it does not work, the problem is that i get an error because of the low baud rate but i can't raise this, because of the 1MHz F_CPU clock speed. \$\endgroup\$
    – toma3757
    Feb 1, 2019 at 10:40
  • \$\begingroup\$ @domen yes i will add more information to my question Is it a good solution if i disable the interrupts before i send the data over the uart? \$\endgroup\$
    – toma3757
    Feb 1, 2019 at 10:45

2 Answers 2

1
\$\begingroup\$

Solved, if you are interested in: https://github.com/toma3757/ATtiny25-DS18B20-UART

\$\endgroup\$
0
\$\begingroup\$

Have you tried just using Arduino? I'm pretty sure the ATtiny board support package for ATtiny by David Mellis supports the ATTiny25. https://github.com/damellis/attiny

And then you could just use the tried and true Arduino library for the DS18B20 and OneWire. https://github.com/milesburton/Arduino-Temperature-Control-Library

These libraries are pretty hardware agnostic as far as I know. With a try if you ask me. I think they bit-bang, possibly with some timer support.

\$\endgroup\$
1
  • \$\begingroup\$ Yes, i found it earlier but the attiny25's flash is too small for these libraries. I compiled only the OneWIre and the DallasTemperature without the software serial lib, and it is 2452 byte. The flash size is 2kByte. However, thanks for the idea. \$\endgroup\$
    – toma3757
    Feb 2, 2019 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.