Skip to content
  • Blog
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Community Forum

  1. Home
  2. Categories
  3. TH02
  4. Negative temperature measures

Negative temperature measures

Scheduled Pinned Locked Moved TH02
temperatureth02negativelibrary
4 Posts 2 Posters 2.8k Views 2 Watching
  • 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
    K Offline
    kgx123
    wrote on last edited by
    #1

    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
    • CharlesC Offline
      CharlesC Offline
      Charles
      wrote on last edited by
      #2

      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
      • K Offline
        K Offline
        kgx123
        wrote on last edited by
        #3

        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
        • CharlesC Offline
          CharlesC Offline
          Charles
          wrote on last edited by
          #4

          Excellent,
          I will modify the lib on github
          Charles

          1 Reply Last reply

          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
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          3

          Online

          5.8k

          Users

          565

          Topics

          5.3k

          Posts

          Top Topics

          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
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Blog
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups