A class-based DHT sensor method, with 60 second Temperature and Humidity averaging, delivered via web page calls.First Attempt
My first attempt at this was this: NodeMCU Web Server with DHT11 data. It worked fine and the data was used to produce the first part of the graphic.
And thus you can see my issue, or if not, see top left caption of the image. The sensor, (specs), has a resolution of 1 degree C, repeat-ability of 1 degree C and an accuracy of 1 degree C, upon subsequent readings. Not bad for such a cheap sensor, however, but not good enough, as the very jagged lines are a serious offense to my eyes.Adjustments
It was time to rethink this. Taking some of the stuff, that I've written for another project, I 'classified' the temperature reader, and also created a mechanism for returning the mean of the last 60 (1 per second) readings, for a smoother return value, and thus, graphic after the 15th. Better, smoother lines, but the block-ish rises and dips?! They offend, and must go, and specifically, are caused by a sensor limitation. The 1 degree C resolution STILL makes itself very CLEAR, in the rapid rises and falls at the 1 degree level.
Time for a sensor upgrade, to a DHT22 (specs). It has a resolution of 0.1 degree C, repeat-ability of 0.2 degree C, and an accuracy of 0.5 degree C. With these specs, and the averaging, it should be indistinguishable from the baseline AM2315 sensor(Outside on the graphic), used in my weatherstation, which has no averaging, at the moment (specs). It has a 0.1 degree C resolution, 0.2 degree C repeat-abilty, and 0.1 degree C accuracy.
MUCH better than the DHT11, and MUCH cheaper than the AM2315! If you don't need the device to exist outside, then the DHT22 is a very suitable upgrade from the DHT11!
Since temperatures and humidity are not generally largely variable in the short term (minute), using a mean data approach allows 'data smoothing', to help overcome minor fluctuations that can show up due to sensor limitations.
The reason for a separate project is not the change in the sensor, which is trivial, but the change in approach, from a singular request based approach, to a mean based approach, using a class to fulfill that need.