5 Replies Latest reply on Sep 19, 2019 10:28 PM by RakshithM_16

    PSOC 4 BLE WITH DHT22

    AnMo_4196841

      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

        • 1. Re: PSOC 4 BLE WITH DHT22
          RakshithM_16

          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

          1 of 1 people found this helpful
          • 2. Re: PSOC 4 BLE WITH DHT22
            AnMo_4196841

            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?

            • 3. Re: PSOC 4 BLE WITH DHT22
              RakshithM_16

              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

               

               

              Regards,

              Rakshith M B

              1 of 1 people found this helpful
              • 4. Re: PSOC 4 BLE WITH DHT22
                AnMo_4196841

                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.

                • 5. Re: PSOC 4 BLE WITH DHT22
                  RakshithM_16

                  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