Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Printing floats with MS_DBG()

Home Forums Mayfly Data Logger Printing floats with MS_DBG()

Viewing 2 reply threads
  • Author
    Posts
    • #15118
      Matt Barney
      Participant

      How can I specify higher floating-point precision when using MS_DBG()? For example:

      prints:

       

    • #15119
      Sara Damiano
      Moderator

      The Arduino print function defaults to two decimal places for a float.  Normally, if you were using Serial.print(float) you could control the decimal places with Serial.print(float, decimalPlaces).  But because of the way the MS_DBG macro is written, that won’t work.  You’ll have to create a String from the number and then MS_DBG that:  MS_DBG(String(float, decimalPlaces));

    • #15120
      Matt Barney
      Participant

      Ah, perfect – thanks Sara!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.