atmega328p DHT22 problem
Moderator: Benj
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
atmega328p DHT22 problem
Hello guys
So i had some atmega328p around (empty not Arduino) and I gave a try to a dht22 sensor.Well to my surprise no readings....
Another problem also that maybe related
I try to use an external oscillator 16Mhz with low_fuse 0xff,high_fuse 0xde,and extended 0x05 but nothing....no led blinks it only works when I set project options to 1Mhz
Some pointers basically to make the dht22 work??(the sensor is good works in arduino uno)
So i had some atmega328p around (empty not Arduino) and I gave a try to a dht22 sensor.Well to my surprise no readings....
Another problem also that maybe related
I try to use an external oscillator 16Mhz with low_fuse 0xff,high_fuse 0xde,and extended 0x05 but nothing....no led blinks it only works when I set project options to 1Mhz
Some pointers basically to make the dht22 work??(the sensor is good works in arduino uno)
- 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: atmega328p DHT22 problem
Hello,
The DHT22 requires accurate timings and a clock > 1MHz.
This is a useful trick for getting your project running as expected.
https://www.matrixtsl.com/wiki/index.ph ... ED_flasher
I would guess it's to do with your configuration settings.
The DHT22 requires accurate timings and a clock > 1MHz.
This is a useful trick for getting your project running as expected.
https://www.matrixtsl.com/wiki/index.ph ... ED_flasher
I would guess it's to do with your configuration settings.
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
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
Re: atmega328p DHT22 problem
I am sure it has to do with conf settings too but......only at 1Mhz i can make the flasher...i literally tried every choice in the configurations to set the 16Mhz crystal but it just doesn't work....notice in pic18f....is working great.
Do you have a quick example for flasher for atmega328p?
Do you have a quick example for flasher for atmega328p?
- Attachments
-
- home_garage.fcfx
- (38.21 KiB) Downloaded 148 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: atmega328p DHT22 problem
Are you driving the Atmega with a 16MHz crystal? Are your load capacitors correct? Can you post your circuit so we can check.
You settings look ok to me for 16MHz operation.
You settings look ok to me for 16MHz operation.
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
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
Re: atmega328p DHT22 problem
I do not have any schematics yet (breadboard )but its fairly simple
pin1 & 7 -> 5v
pin8 & 22 -> grd
pin 9 & 10 -> crystal osc 16Mhz with 2 22pf caps to grd
dht22
pin 1 -> 5v
pin 2 -> atmega pin4
pin 4 -> grd
Thats it.....
and I am programming it using and arduino uno as isp with avr dude:
avrdude -c arduino -p m328p -P COM27 -b 19200 -U flash:w:home_garage.hex
pin1 & 7 -> 5v
pin8 & 22 -> grd
pin 9 & 10 -> crystal osc 16Mhz with 2 22pf caps to grd
dht22
pin 1 -> 5v
pin 2 -> atmega pin4
pin 4 -> grd
Thats it.....
and I am programming it using and arduino uno as isp with avr dude:
avrdude -c arduino -p m328p -P COM27 -b 19200 -U flash:w:home_garage.hex
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 43 times
- Been thanked: 60 times
- Contact:
Re: atmega328p DHT22 problem
Try this version
- Attachments
-
- home_garage1.fcfx
- (41.1 KiB) Downloaded 166 times
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
Re: atmega328p DHT22 problem
Thanks Viktor,
But sadly no......all code works .....the esp01,the MQTT,the button ...except the dht22.....
But sadly no......all code works .....the esp01,the MQTT,the button ...except the dht22.....
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
Re: atmega328p DHT22 problem
Ok I found the problem...looks like flow code doesn't set the fuses when you burn the hex file, you have to burn the fuses before and then burn your hex file...
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 43 times
- Been thanked: 60 times
- Contact:
Re: atmega328p DHT22 problem
Hello kabouras
Please pay attention to switch.
Please pay attention to switch.
- Attachments
-
- empty_switch-1.jpg (61.33 KiB) Viewed 5065 times
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
Re: atmega328p DHT22 problem
Thanks Victor!!
Yes you are right i removed it but the problem was that flowcode doesnt burn the configs like it does with pics..thats why it was always working only with 1Mhz no matter what i chose...
I had to burn rhe fuses first with a different set of instructions first for lfuse then hfuse and after that i burn the hex and boom all working perfectly at 16Mhz external crystal including the dht22....i think this is a bug but the workaround, worked
Yes you are right i removed it but the problem was that flowcode doesnt burn the configs like it does with pics..thats why it was always working only with 1Mhz no matter what i chose...
I had to burn rhe fuses first with a different set of instructions first for lfuse then hfuse and after that i burn the hex and boom all working perfectly at 16Mhz external crystal including the dht22....i think this is a bug but the workaround, worked
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
Re: atmega328p DHT22 problem
By the way the dht22_sample variable is to return 1 for no data and 2 for crc error i believe so i dont see any reason why the switch does not work...but i did not need it so did not try...i will test it tomorrow though
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 43 times
- Been thanked: 60 times
- Contact:
Re: atmega328p DHT22 problem
Understood kabouras
What is the reason you don't use Arduino boards?
Easy to program...
What is the reason you don't use Arduino boards?
Easy to program...
-
- Posts: 128
- Joined: Thu Jul 27, 2017 5:23 am
- Has thanked: 8 times
- Been thanked: 8 times
- Contact:
Re: atmega328p DHT22 problem
Well, the reason is that I develop and manufacture product orders from clients(custom designs)and products for ships automation...engine control, temperatures etc... now this system costs some money (not small) the problem with Arduino, raspberry etc is that the people know them and they know how much they cost...plus the fault image is that they are some kind of toys for kids .Anyway if I try to introduce a product that sells for 10000 euro lets say with an Arduino....well you are doomed...so I develop my own PCBs, my own enclosures etc...
www.aomi-tech.grwww.aomi-tech.gr
www.aomi-tech.grwww.aomi-tech.gr
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 43 times
- Been thanked: 60 times
- Contact:
Re: atmega328p DHT22 problem
Business development is not DIY.
I used to work with PIC and used some programs to make PCBs, etc.
But for some small house related projects Arduino is good enough.
Not for you, I understood.
You have raised a good points.
Thank you.
I used to work with PIC and used some programs to make PCBs, etc.
But for some small house related projects Arduino is good enough.
Not for you, I understood.
You have raised a good points.
Thank you.