DHT22 module can't read the data (nan)

i wanna ask some expert in here, i was using 3.3v as the vcc for dht22 module (3 pin), it worked normally but one time it can't read any data (nan), i changed my gpio, checked the wire, but it still can't read the data.

so, i tried to connect the vcc with 5v and it instantly works again (i just re-open the serial monitor without change any code, only change the wire connection), so i thought "well, i must use 5v instead of 3.3v, but, when i re-upload the code (literally same code), it become nan again (with 5 v) after works several time.

then i tried the previous work (use 3.3v --> it works), then change it again to 5v --> it also works), so i guess the vcc isn't the issue for the can't read the data like was I thought before. can anybody please explain what's the possible reason it became nan? i want to know cause it's gonna be hard if already attach dht22 in pcb and out of nowhere it display nan right..

Bad wiring, loose contacts, oxidation?

well maybe, it really confuses me cause sometimes it read the data, works normally, and suddenly became nan, or maybe it's the sensor itself?

has anyone used dht22 and how good and long lasting is it?

That sounds like a loose connection to me. Can you post a clear picture of your setup?