Yep. Been there, done that, many times. From simple serial links to distributed, fault tolerant, control systems. In the "real world" of digital systems they are all analog!In the 'real world' of digital communication (over the airwaves, or copper wire or fibre etc.) errors and corrupted data are a fact of life.
Ah, there is a point. Looks like I'm thinking about the DHT11 sensor in the wrong light.One rarely experiences the luxury of guaranteed perfect data, every time, outside of the realm of a self-contained computer,...
I would generally expect a SPI or I2C device, or a peripheral chip like a RAM connected to a processor to communicate flawlessly so much that one does not worry about the failure rate.
Apparently the DHT11 is not to be treated as such.
The odd thing about this case is that the unreliability seems to be caused by the receiving end of the system, even if the DHT11 is working well and the communication link is noise free. All down to the non-deterministic timing of application code in the OS.
Where then should one do all this error checking and retrying?
Potentially if it's done at a low level, in C under BASIC say, then the read function may never return. Or at least the time taken to get a correct result is unbounded!
That is scary in itself.