Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
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
  1. Home
  2. Development
  3. Help sending payload with more decimal places

Help sending payload with more decimal places

Scheduled Pinned Locked Moved Development
5 Posts 3 Posters 2.3k Views 1 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.
  • T Offline
    T Offline
    therik
    wrote on last edited by
    #1

    Hey guys,

    Just wondering if someone would be so kind as to help me figure out how to use setters to send a payload with more decimal places than the standard custom variable.

    I saw that perhaps I could construct the msg "on the fly", but I don't know the proper syntax to get that accomplished. Even easier, I would simply like to send a custom variable with two decimal places (or however many one should like). Right now the default is a single decimal place as I gather from the data that is being sent currently.

    In the plainest terms, I would like to send the battery voltage in a format X.XX using a custom variable, but using the standard custom variable constructor the payload is X.X.

    Thanks for your help.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      ericvdb
      wrote on last edited by
      #2

      multiply your float with 100 or 1000 before sending and divide again on the receiving end.

      1 Reply Last reply
      0
      • hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by
        #3

        the second argument to the MyMessage.set-method is the number of decimals.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          therik
          wrote on last edited by
          #4

          @hek okay, I guess I was being stupid....

          With this msg constructor...

          MyMessage msgVolt(CHILD_ID_VOLT, V_VAR1);
          

          With this type def...

           float batteryV  = sensorValue * 0.003363075;
          

          I had the following thinking that I had turned on auto ack...

            gw.send(msgVolt.set(batteryV, 1));
          

          but that sets the decimal places to "1". So, if I want to set the decimal places to "2" and enable auto ack it would look like this...?

            gw.send(msgVolt.set(batteryV, 2),1);
          

          Thanks again.

          hekH 1 Reply Last reply
          0
          • T therik

            @hek okay, I guess I was being stupid....

            With this msg constructor...

            MyMessage msgVolt(CHILD_ID_VOLT, V_VAR1);
            

            With this type def...

             float batteryV  = sensorValue * 0.003363075;
            

            I had the following thinking that I had turned on auto ack...

              gw.send(msgVolt.set(batteryV, 1));
            

            but that sets the decimal places to "1". So, if I want to set the decimal places to "2" and enable auto ack it would look like this...?

              gw.send(msgVolt.set(batteryV, 2),1);
            

            Thanks again.

            hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #5

            @therik said:

            gw.send(msgVolt.set(batteryV, 2),1);

            Yes, this is correct.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            17

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular