ATTINY85 + dht22

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

ATTINY85 + dht22

Postby claudemir » Fri Mar 13, 2020 11:32 pm

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.
Attachments
Escaleonamento DHT.fcfx
(11.86 KiB) Downloaded 14 times

User avatar
Benj
Matrix Staff
Posts: 14790
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4752 times
Been thanked: 4358 times
Contact:

Re: ATTINY85 + dht22

Postby Benj » Sat Mar 14, 2020 2:33 pm

Hello,

4Mhz is probably too slow to accurately read the sensor. Can you clock the device faster?

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: ATTINY85 + dht22

Postby claudemir » Sat Mar 14, 2020 6:19 pm

hello Benj
Thanks for the answer.
Tested with various clock settings, also used various clock parameters and it still didn't work.

User avatar
Benj
Matrix Staff
Posts: 14790
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4752 times
Been thanked: 4358 times
Contact:

Re: ATTINY85 + dht22

Postby Benj » Mon Mar 16, 2020 2:31 pm

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.

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: ATTINY85 + dht22

Postby claudemir » Tue Mar 17, 2020 1:57 am

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

User avatar
Benj
Matrix Staff
Posts: 14790
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4752 times
Been thanked: 4358 times
Contact:

Re: ATTINY85 + dht22

Postby Benj » Tue Mar 17, 2020 10:23 am

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.

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: ATTINY85 + dht22

Postby claudemir » Wed Mar 18, 2020 12:42 am

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.
Last edited by claudemir on Wed Mar 18, 2020 12:52 am, edited 2 times in total.

User avatar
Benj
Matrix Staff
Posts: 14790
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4752 times
Been thanked: 4358 times
Contact:

Re: ATTINY85 + dht22

Postby Benj » Wed Mar 18, 2020 11:42 am

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.

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: ATTINY85 + dht22

Postby claudemir » Thu Mar 19, 2020 12:50 am

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.
Attachments
teste.fcfx
(7.69 KiB) Downloaded 8 times
Escaleonamento DHT.fcfx
(11.86 KiB) Downloaded 7 times

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: ATTINY85 + dht22

Postby claudemir » Tue Mar 24, 2020 5:30 pm

Hello Benj
Any suggestions for this problem?

User avatar
Benj
Matrix Staff
Posts: 14790
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4752 times
Been thanked: 4358 times
Contact:

Re: ATTINY85 + dht22

Postby Benj » Wed Mar 25, 2020 11:39 pm

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.

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: ATTINY85 + dht22

Postby claudemir » Thu Mar 26, 2020 2:35 am

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
Attachments
eXtreme Burner.jpg
eXtreme Burner.jpg (118.24 KiB) Viewed 683 times
Fuses.jpg
Fuses.jpg (85.67 KiB) Viewed 683 times

User avatar
Benj
Matrix Staff
Posts: 14790
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4752 times
Been thanked: 4358 times
Contact:

Re: ATTINY85 + dht22

Postby Benj » Thu Mar 26, 2020 9:15 am

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.
These users thanked the author Benj for the post:
claudemir (Sun Mar 29, 2020 11:45 pm)
Rating: 5%
 

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: ATTINY85 + dht22

Postby claudemir » Sun Mar 29, 2020 11:43 pm

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.
Attachments
Escaleonamento DHT.fcfx
(12.24 KiB) Downloaded 3 times
These users thanked the author claudemir for the post:
Benj (Mon Mar 30, 2020 9:13 pm)
Rating: 5%