Programming the ATTiny observations

I was investigating the amazing DHT** library by Rob Tillart (genius)

The DHT11 only gives you an integer for both humidity and temperature, no decimal places so this line in Rob's code:

Serial.print(DHT.humidity, 1);

I cunningly changed to Serial.print((Int)DHT.humidity, 1);

to cast it to an int (it returns a double) because I didn't want the unused decimal place.

Running on the Uno this works fine but when transferred over to the ATTiny85 it causes it to crash and restart.

Don't do this: Serial.print((Int)DHT.humidity, 1);

do this instead: Serial.print(DHT.humidity, 0);

another bug bites the dust!

IanMcRV: The DHT11 only gives you an integer for both humidity and temperature, no decimal places so this line in Rob's code:

No, it provides an 8 bit fractional and 8 bit integer temperature value. Total 16 bit value. http://akizukidenshi.com/download/ds/aosong/DHT11.pdf

oh :astonished:

this bit in the manual is interesting:

10、Warnings and personal injury This product is not applied to the safety or emergency stop devices, as well as the failure of the product may result in injury to any other application, unless a particular purpose or use authorized. Installation, handling, use or maintenance of the product refer to product data sheets and application notes. Failure to comply with this recommendation may result in death and serious personal injury. The Company will bear all damages resulting personal injury or death, and waive any claims that the resulting subsidiary company managers and employees and agents, distributors, etc. that may arise, including: a variety of costs, compensation costs, attorneys' fees, and so on.

I don't 'know' if they hired the right lawyer but i'm guessing that part of that blurb should have read: 'The company will NOT bear 'ANY' damages resulting 'IN' personal injury ..... etc. etc.

just guessing though

or maybe its a challenge?

If you can kill yourself with a DHT11 we'll cover all the costs!

It would seem as though you are not telling porky pies

Data format:
The 8bit humidity integer data + 8bit the Humidity decimal data +8 bit temperature integer data +
8bit fractional temperature data +8 bit parity bit.

Rob! Where’s the fractional data in your library?

(he has a lot to answer for, and I called him a genius)

:grinning: