ayufan-pine64 / dht22-pine64

Simple application to read DHT22 value on Pine A64
1 stars 3 forks source link

Invalid CRC or Not enough bits #2

Closed xrmb closed 6 years ago

xrmb commented 6 years ago

First of all the code works pretty well and I can easily work around the issue! But sometimes I get random errors like "Invalid CRC" or "Not enough bits". I get what is going on there in the code, I just dont know if it is an issue with my hardware, some timing issue or a sensor issue.

Is that normal?

Thanks in advance.

$dht22 -p 71 -d 1000

Humidity: 44.1 % Temperature: 29.2 C Humidity: 44.0 % Temperature: 29.2 C Humidity: 44.0 % Temperature: 29.1 C Humidity: 44.0 % Temperature: 29.1 C Invalid CRC Not enough bits: 0 Not enough bits: 0 Not enough bits: 0 Humidity: 44.0 % Temperature: 29.1 C Humidity: 43.9 % Temperature: 29.1 C Humidity: 44.0 % Temperature: 29.1 C Not enough bits: 39 Not enough bits: 0 Not enough bits: 0 Not enough bits: 0 Humidity: 44.0 % Temperature: 29.1 C

ayufan commented 6 years ago

It is run in userspace and sometimes kernel switches context and you then fail to read the data.

On Tue, Jul 25, 2017 at 2:28 AM, xrmb notifications@github.com wrote:

First of all the code works pretty well and I can easily work around the issue! But sometimes I get random errors like "Invalid CRC" or "Not enough bits". I get what is going on there in the code, I just dont know if it is an issue with my hardware, some timing issue or a sensor issue.

Is that normal?

Thanks in advance. $dht22 -p 71 -d 1000

Humidity: 44.1 % Temperature: 29.2 C Humidity: 44.0 % Temperature: 29.2 C Humidity: 44.0 % Temperature: 29.1 C Humidity: 44.0 % Temperature: 29.1 C Invalid CRC Not enough bits: 0 Not enough bits: 0 Not enough bits: 0 Humidity: 44.0 % Temperature: 29.1 C Humidity: 43.9 % Temperature: 29.1 C Humidity: 44.0 % Temperature: 29.1 C Not enough bits: 39 Not enough bits: 0 Not enough bits: 0 Not enough bits: 0 Humidity: 44.0 % Temperature: 29.1 C

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ayufan-pine64/dht22-pine64/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/ACTpQem1BhL4v4DzU_6o_2OzTqKifSD0ks5sRTavgaJpZM4Oh69d .

xrmb commented 6 years ago

Would running parts of the code in a "critical section" to avoid context switches solve it? Or would that block to long?