PSOC 4 BLE WITH DHT22

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
AnMo_4196841
Level 3
Level 3
First like received First like given

Can someone tell me why it does not detect the data in this project well?

I get the valor 1 for humidity and temperature.

Thanks in advance

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi AnMo_4196841

The logic of your code to obtain temperature and humidity seems to be working fine. I am able to get the temperature and humidity values from the sensor by running your project (Please refer to the screenshot of data stored in outstring). The issue might be with the sensor that you are using. Please verify that the sensor that you have used is working. Also, verify the checksum that is received from your sensor (last byte received) matches with the checksum that is calculated. Checksum is calculated by adding the first 4 bytes received from the sensor.

Please update after ensuring that the sensor and checksum are verified.

Note that the code ignores the checksum and the fraction values of both temperature and humidity.

tempsnip.png

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

View solution in original post

5 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi AnMo_4196841

The logic of your code to obtain temperature and humidity seems to be working fine. I am able to get the temperature and humidity values from the sensor by running your project (Please refer to the screenshot of data stored in outstring). The issue might be with the sensor that you are using. Please verify that the sensor that you have used is working. Also, verify the checksum that is received from your sensor (last byte received) matches with the checksum that is calculated. Checksum is calculated by adding the first 4 bytes received from the sensor.

Please update after ensuring that the sensor and checksum are verified.

Note that the code ignores the checksum and the fraction values of both temperature and humidity.

tempsnip.png

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

Thanks RakshithM_16

One thing more, I don´t know how I can verify the checksum that is received from your sensor (last byte received) matches with the checksum that is calculated. How can I obtain the bytes?

0 Likes

Hi AnMo_4196841

The sensor sends 5 bytes in total.

Byte 1 - Humidity (whole number part)

Byte 2 - Humidity (fractional part)

Byte 3 - Temperature (whole number part)

Byte 4 - Temperature (fractional part)

Byte 5 - Checksum

These bytes are stored in bits[ ] in your project.

To calculate checksum add the following code lines after you exit critical section in your code as shown -

/***********************************************

  Initialize checksum variable as shown

     uint8 checksum = 0;

***********************************************/

checksum = bits[0] + bits[1] + bits[2] + bits[3]; 

if ( (checksum == bits[4]) && (bits[4] != 0) )

     return 0;  //Checksum verified

else

     return 99;  // return error

pastedImage_1.png

Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

Hi RakshithM_16

The program continues without working well. I verify the checksum that is received from my sensor matches with the checksum that is calculated.

I have verify the sensor work correctly.

What can happen?

What happen whit this? -->Note that the code ignores the checksum and the fraction values of both temperature and humidity.

0 Likes

Hi AnMo_4196841

Please send a screenshot of the values of bits[] array that is sent by the sensor. You can get these values by using PSoC Creator in Debug mode and by setting a break-point at this line -

temperature = bits[2];

in the DHTread() function.

Can you let me know how you verified that your sensor is working correctly?

What I meant by "Note that the code ignores the checksum and the fraction values of both temperature and humidity" is that in your code that you have sent, you do not verify checksum or consider the fractional values of both temperature and humidity values. You have used the following lines -

humidity    = bits[0];

temperature = bits[2];

These are just the whole number values and bits[1] and bits[3] gives you the fractional values of humidity and temperature respectively which is not considered.

Can you also try the following?

1. Comment out DHTread() function call in the for loop in main function.

2. Assign random test values to humidity and temperature variables.

3. See if the LCD panel is printing the values that you have assigned.

By doing this we can figure out if the issue is with the sensor part or the LCD code.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes