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. Sending an integer >32767

Sending an integer >32767

Scheduled Pinned Locked Moved Development
7 Posts 4 Posters 1.6k Views 4 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.
  • AndurilA Offline
    AndurilA Offline
    Anduril
    wrote on last edited by Anduril
    #1

    Hey there,

    I'm trying to send a value between 10.000 and 99.999, but as soon as it gets bigger than 32.767 (size of int16) I receive totally senseless numbers. Is there a way to send this big number e.g. with an int32? I use V_VAR1 as message type.

    Regards,
    Anduril

    F AWIA 2 Replies Last reply
    0
    • AndurilA Anduril

      Hey there,

      I'm trying to send a value between 10.000 and 99.999, but as soon as it gets bigger than 32.767 (size of int16) I receive totally senseless numbers. Is there a way to send this big number e.g. with an int32? I use V_VAR1 as message type.

      Regards,
      Anduril

      F Offline
      F Offline
      flopp
      wrote on last edited by flopp
      #2

      @Anduril
      I have checked my sketches. But I don't know so much about code.

      double VAR1
      long VAR1

      Try if they work

      1 Reply Last reply
      0
      • AndurilA Anduril

        Hey there,

        I'm trying to send a value between 10.000 and 99.999, but as soon as it gets bigger than 32.767 (size of int16) I receive totally senseless numbers. Is there a way to send this big number e.g. with an int32? I use V_VAR1 as message type.

        Regards,
        Anduril

        AWIA Offline
        AWIA Offline
        AWI
        Hero Member
        wrote on last edited by
        #3

        @Anduril Are you sending it from your sketch or the controller? If you are sending from the sketch make sure the "setter"

           // Setters for payload
            MyMessage& set(void* payload, uint8_t length);
            MyMessage& set(const char* value);
            MyMessage& set(uint8_t value);
            MyMessage& set(float value, uint8_t decimals);
            MyMessage& set(unsigned long value);
            MyMessage& set(long value);
            MyMessage& set(unsigned int value);
            MyMessage& set(int value);
        
        

        can recognize the variable as a type > int16. (long or unsigned long) i.e
        unsigned long variableToBeSend = 1234567 UL ;

        I assume the value is now 'overflowing' to a negative number.

        1 Reply Last reply
        0
        • AndurilA Offline
          AndurilA Offline
          Anduril
          wrote on last edited by
          #4

          I tried to send from controller. When sending 32768 the node 'received' 4294934528 (written to the serial monitor)...

          1 Reply Last reply
          0
          • AndurilA Offline
            AndurilA Offline
            Anduril
            wrote on last edited by
            #5

            well I did some further testing... sending e.g. 65000 from the node to the controller works, sending back 65001 does not. That seems more related to the controller (MyController) than MySensors. Maybe @jkandasa can help shine some light on this.

            1 Reply Last reply
            1
            • AndurilA Offline
              AndurilA Offline
              Anduril
              wrote on last edited by
              #6

              I found the problem... or to be honest @jkandasa found it. He told me in the MyController forum to check my receiving code and not use getInt() but getLong(). Thanks again to him.

              mfalkviddM 1 Reply Last reply
              1
              • AndurilA Anduril

                I found the problem... or to be honest @jkandasa found it. He told me in the MyController forum to check my receiving code and not use getInt() but getLong(). Thanks again to him.

                mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by
                #7

                @Anduril great that you found the problem. Thanks for sharing the solution, it might help someone else in the future.

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


                19

                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