Notifications
Clear all

ESP-32 and DHT22

46 Posts
5 Users
2 Likes
4,787 Views
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@farzad_k 

Sorry about that. I'm lazy, so I tend to collapse several lines of code into a single expression. That one line combines about 4 lines from the example I sent you before (all the ones that start "temp = ").

I would suggest that you create functions to generate your required data and keep the basic coding out of the main loop() section. There are two reasons for this: 1) if you ever need to change the formula (e.g. you change to a different part or module) then you don't have to root through all the code to find it and change it wherever it was and 2) it keeps unrelated code from the control section of your sketch.

I noticed that you seem to be using a different set of numbers for the TMP36 calculations, so I'm going to try to find a data sheet for it and check on the proper range it covers and adjust the formula (if required).

I've become quite interested in this and, if you want, I'd like to provide you with 3 functions, calcAmbient which will the average of the TMP36 sensors, calcDewPoint which will calculate the dew point temperature and calcPWMLevel which will return the suggested power level to send to the MOSFET.

I'm just offering at this point because I realize that you may prefer to do it all yourself, and that way you'll learn more than if I do it. I'm only offering because you seemed to be in a bit of a hurry and I may be able to help cut down the time needed. I'll try to keep the code from getting too abstruse 🙂

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Page 4 / 4