atmega328p DHT22 problem

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

Moderator: Benj

Post Reply
kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

atmega328p DHT22 problem

Post by kabouras_33 »

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)

User avatar
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

Post by Benj »

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.

kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: atmega328p DHT22 problem

Post by kabouras_33 »

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?
Attachments
home_garage.fcfx
(38.21 KiB) Downloaded 148 times

User avatar
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

Post by Benj »

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.

kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: atmega328p DHT22 problem

Post by kabouras_33 »

I do not have any schematics yet (breadboard :D :D )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

viktor_au
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

Post by viktor_au »

Try this version
Attachments
home_garage1.fcfx
(41.1 KiB) Downloaded 166 times

kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: atmega328p DHT22 problem

Post by kabouras_33 »

Thanks Viktor,
But sadly no......all code works .....the esp01,the MQTT,the button ...except the dht22.....

kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: atmega328p DHT22 problem

Post by kabouras_33 »

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...

viktor_au
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

Post by viktor_au »

Hello kabouras

Please pay attention to switch.
Attachments
empty_switch-1.jpg
empty_switch-1.jpg (61.33 KiB) Viewed 5065 times

kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: atmega328p DHT22 problem

Post by kabouras_33 »

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 :wink:

kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: atmega328p DHT22 problem

Post by kabouras_33 »

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 :mrgreen: :mrgreen:

viktor_au
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

Post by viktor_au »

Understood kabouras

What is the reason you don't use Arduino boards?
Easy to program...

kabouras_33
Posts: 128
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 8 times
Been thanked: 8 times
Contact:

Re: atmega328p DHT22 problem

Post by kabouras_33 »

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 :wink: (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 :evil: .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

viktor_au
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

Post by viktor_au »

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.

Post Reply