Page 1 of 1
ATTINY85 + dht22
Posted: Fri Mar 13, 2020 11:32 pm
by claudemir
Hello
I'm trying to use ATTINY85 to read a dht22 and convert it into a 0 to 5v output, but I can't make it work, as it has few resources, I have practically tested them all, but without success.
It remains to be asked whether ATTINY85 and dht22 are compatible?
In simulating everything is perfect, but not in hardware.
Re: ATTINY85 + dht22
Posted: Sat Mar 14, 2020 2:33 pm
by Benj
Hello,
4Mhz is probably too slow to accurately read the sensor. Can you clock the device faster?
Re: ATTINY85 + dht22
Posted: Sat Mar 14, 2020 6:19 pm
by claudemir
hello Benj
Thanks for the answer.
Tested with various clock settings, also used various clock parameters and it still didn't work.
Re: ATTINY85 + dht22
Posted: Mon Mar 16, 2020 2:31 pm
by Benj
Hello,
What speed is your device clocked at? You can do the 1 second flasher test to get things set up correctly.
https://www.matrixtsl.com/wiki/index.ph ... ED_flasher
If the above is not correct then the DHT22 will not work as it requires accurate timings.
Once the speed is configured correctly, if the MCU is running fast enough the comms to the DHT22 should work fine. If the DHT22 is still not working then you may need to increase the speed of your crystal or internal oscillator setting depending on what is clocking your circuit.
Re: ATTINY85 + dht22
Posted: Tue Mar 17, 2020 1:57 am
by claudemir
Hello Benj
was that I really did it, I put a blinker for one second, to blink with an interval of one second I had to set it to 1MHz, if I put 8MHz it blinks outside the one second interval, if I set it to 16MHz the interval is even bigger.
The sensor return is always 0.00 for temperature and 0.00 for humidity, but when you call the sensor function ok, 'samplesensor' seems to me that the sensor is ok, as it enters the routine to read the sensor
Re: ATTINY85 + dht22
Posted: Tue Mar 17, 2020 10:23 am
by Benj
Hello,
Ok if the timings are correct for 1Mhz then that is the speed your microcontroller is running at. This is not fast enough for DHT22 communications.
Can you tell if you are using an external crystal or an internal oscillator to drive your microcontroller.
If you are using an external crystal then you will need to use a higher speed crystal say 16 or 20 MHz.
If you are using the internal oscillator then the configuration fuse bits can be changed to increase the speed of the microcontroller.
Re: ATTINY85 + dht22
Posted: Wed Mar 18, 2020 12:42 am
by claudemir
Hello
You can tell if you are using an external crystal or an internal oscillator to power your microcontroller.
Answer: I used 4MHz external crystal and 1MHz to 16MHz internal oscillator, the best result was 1MHz.
If you are using an external crystal, you will need to use a higher speed crystal, say 16 or 20 MHz.
Answer: I tested it with the smallest I have, 4MHz, even so it remains very slow the 1 second flashes, with 16MHz it did not work.
If you are using the internal oscillator, the setting fuse bits can be changed to increase the speed of the microcontroller.
Answer: With a 1MHz internal oscillator I changed all the spindles but not one result was achieved.
Re: ATTINY85 + dht22
Posted: Wed Mar 18, 2020 11:42 am
by Benj
Hello,
Ok let's focus on the internal oscillator and getting the device running as fast as possible. It looks like 8MHz should be possible with a clock divider of 1.
Set the clock speed to 8000000 in the project options and then adjust the configuration fuse settings accordingly.
Can you send an example of how you are setting the configuration fuse settings and the values you are using I will double check they are correct for you.
Re: ATTINY85 + dht22
Posted: Thu Mar 19, 2020 12:50 am
by claudemir
Hello
Follow the two programs I use, one is flashing for 1 second and the other is with dht22, both are configured with 8 MHz.
I ended up burning my single attiny85, but until 03/20 more attiny85 will be arriving to test, I hope we created a solution to this problem, thank you for your support.
Re: ATTINY85 + dht22
Posted: Tue Mar 24, 2020 5:30 pm
by claudemir
Hello Benj
Any suggestions for this problem?
Re: ATTINY85 + dht22
Posted: Wed Mar 25, 2020 11:39 pm
by Benj
Hello,
What programmer are you using to program the ATTINY device? Are you programming the fuse bits from within Flowcode or can you enter them via your programming software.
With PIC devices the configuration fuse settings are parts of the generated hex file but on AVR based devices they are not and have to be sent separately.
Re: ATTINY85 + dht22
Posted: Thu Mar 26, 2020 2:35 am
by claudemir
Hello Benj
I use the eXtreme burner recorder and to configure the fuses I count with the help of the AVR FUSES calculator, current fuses I used, and the fuses I send separately.
http://eleccelerator.com/fusecalc/fusec ... p=attiny85
Re: ATTINY85 + dht22
Posted: Thu Mar 26, 2020 9:15 am
by Benj
Aha now we are getting somewhere.
You are using the 8MHz internal clock which is good but you also have the divide clock by 8 checkbox ticked which will bring you down to 1MHz. Untick this and you should be good to go at 8MHz.
Re: ATTINY85 + dht22
Posted: Sun Mar 29, 2020 11:43 pm
by claudemir
Hello Benj
I am very grateful for your help, when I disabled the CKDIV8 fuse, it returned to work as expected, but before that I still found a fault of mine (not forgiven by myself), I had programmed samplesensor equal to 1 for success, and not equal to 0, as specified "Returns 0 for success, 1 for no communication".
Once again, without your kind help, I would not have reached the end of my project.