Community Forum
    • Blog
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Negative temperature measures

    Scheduled Pinned Locked Moved TH02
    temperatureth02negativelibrary
    4 Posts 2 Posters 2.5k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      kgx123
      last edited by

      Hi Charles-Henri,

      I am using your excellent TH02 library on Moteino. I have one sensor outside my house, with minus degrees celsius. However the TH02 lib reports the absolute value, without the minus prefix. E.g. “6.5” instead of “-6.5″. Please advise on what I am doing wrong.

      Merci beacoup,
      Karim

      From the Arduino sketch:

      int16_t temp, rh, rh_comp;
       //uint8_t status;
       
       Serial.print(F("Starting Temperature conversion."));
       sensor.startTempConv();
       sensor.waitEndConversion();
       Serial.println(F(".done!"));
      
       // Get temperature calculated and rounded
       temp = sensor.getConversionValue();
       
       // Display unrounded value (raw)
       Serial.print(F("Temperature = "));
       // this call does not do any I2C reading, it use last reading
       Serial.print(sensor.getLastRawTemp()/100.0);
       Serial.print(F(" C  =>  "));
       // Display now rounded value returned by 1st call
       Serial.print(temp/10.0);
       Serial.println(F(" C"));
      
      1 Reply Last reply Reply Quote
      • CharlesC Offline
        Charles
        last edited by

        Karim,

        Would you try to modify the following line (261 to 269) to the library th02.cpp

         if(result >= 5000)
        {
          result -= 5000;
        }
        else
        {
          result -= 5000;
          result = -result;
        }
        

        by

        result -= 5000;
        

        Let me know if it works, I don’t understand why I’ve done like that 😉

        1 Reply Last reply Reply Quote
        • K Offline
          kgx123
          last edited by

          Changes done to th02.cpp. Thanks! Seems to be working fine ::

          NEGATIVE TEMP:
          Starting Temperature conversion..done!
          Temperature = -7.00 C => -7.00 C

          Starting Temperature conversion..done!
          Temperature = -5.82 C => -5.80 C

          Starting Temperature conversion..done!
          Temperature = -2.10 C => -2.10 C

          Starting Temperature conversion..done!
          Temperature = -0.79 C => -0.80 C

          POSITIVE TEMP:
          Starting Temperature conversion..done!
          Temperature = 1.43 C => 1.40 C

          Starting Temperature conversion..done!
          Temperature = 2.87 C => 2.90 C

          1 Reply Last reply Reply Quote
          • CharlesC Offline
            Charles
            last edited by

            Excellent,
            I will modify the lib on github
            Charles

            1 Reply Last reply Reply Quote

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post

            2

            Online

            5.8k

            Users

            552

            Topics

            5.2k

            Posts

            Top Topics

            • Accès à l'interface Serial et/ou Reset du Winky
              E
              EliasMM
              0
              7
              248

            Popular Tags

            teleinfo
            25 topics
            arduino
            19 topics
            remora
            16 topics
            esp8266
            10 topics
            arduipi
            10 topics
            raspberry
            8 topics
            wifinfo
            7 topics
            broadcast
            7 topics
            Copyright © 2022 Charles-Henri Hallard | Return to blog page | Powered by NodeBB