ATTINY85 + dht22
Moderator: Benj
ATTINY85 + dht22
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.
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 221 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ATTINY85 + dht22
Hello,
4Mhz is probably too slow to accurately read the sensor. Can you clock the device faster?
4Mhz is probably too slow to accurately read the sensor. Can you clock the device faster?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ATTINY85 + dht22
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ATTINY85 + dht22
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ATTINY85 + dht22
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ATTINY85 + dht22
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.
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.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ATTINY85 + dht22
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ATTINY85 + dht22
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.
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 213 times
-
- Escaleonamento DHT.fcfx
- (11.86 KiB) Downloaded 227 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ATTINY85 + dht22
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ATTINY85 + dht22
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
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 (118.24 KiB) Viewed 7312 times
-
- Fuses.jpg (85.67 KiB) Viewed 7312 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: ATTINY85 + dht22
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ATTINY85 + dht22
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.
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 175 times