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. Can't find the right documentation... Reading receive messages

Can't find the right documentation... Reading receive messages

Scheduled Pinned Locked Moved Development
4 Posts 2 Posters 1.1k 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.
  • A Offline
    A Offline
    Alain Mizreh
    wrote on last edited by
    #1

    Hello,
    First of all, I would like to say thank you for MySensors.
    It seems to be doing all the things I expected for a longtime, and I have been trying to do it all by myself before...

    So, I am new to MySensors, not to Arduino / ESP8266, etc...

    I have been able to make a Gateway & a Sensor talk together.
    I have been able to connect to my io.adafruit.com MQTT server, as well...

    I am using the "void receive(MyMessage &msg)" routine to read incoming messages from my Sensor (a DHT22 based one).

    But I cannot figure out how to get the data from it !
    The variable I use doesn't seem to be a String, and I am pretty sure I coud get something like : MyNode = MyMessage.NODE_ID... but I can't find the explanation of how to read incoming messages...

    Hint : I am a hardware engineer from 1985, and I developed my programming skills very late...

    Here is the bit of code I use :

    void receive(MyMessage &msg)
    {
    
      
      String MyMessage;
      int MsgLen = MyMessage.length();
      
      String Humid = MyMessage.substring(12, MsgLen);
      
      Serial.println(MsgLen);
      Serial.println (Humid);
      
    
    }```
    
    The result is that MsgLen (Length of MyMessage) = 0. So to me this is not a String... 
    
    Thanks for your help, 
    
    Regards,
    
    Alain
    mfalkviddM 1 Reply Last reply
    0
    • A Alain Mizreh

      Hello,
      First of all, I would like to say thank you for MySensors.
      It seems to be doing all the things I expected for a longtime, and I have been trying to do it all by myself before...

      So, I am new to MySensors, not to Arduino / ESP8266, etc...

      I have been able to make a Gateway & a Sensor talk together.
      I have been able to connect to my io.adafruit.com MQTT server, as well...

      I am using the "void receive(MyMessage &msg)" routine to read incoming messages from my Sensor (a DHT22 based one).

      But I cannot figure out how to get the data from it !
      The variable I use doesn't seem to be a String, and I am pretty sure I coud get something like : MyNode = MyMessage.NODE_ID... but I can't find the explanation of how to read incoming messages...

      Hint : I am a hardware engineer from 1985, and I developed my programming skills very late...

      Here is the bit of code I use :

      void receive(MyMessage &msg)
      {
      
        
        String MyMessage;
        int MsgLen = MyMessage.length();
        
        String Humid = MyMessage.substring(12, MsgLen);
        
        Serial.println(MsgLen);
        Serial.println (Humid);
        
      
      }```
      
      The result is that MsgLen (Length of MyMessage) = 0. So to me this is not a String... 
      
      Thanks for your help, 
      
      Regards,
      
      Alain
      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      @Alain-Mizreh welcome to the MySensors community!

      msg is an object, which contains lots of stuff. msg.getString(char* buffer) is probably what you are looking for.

      Information about the MyMessage object is available at https://www.mysensors.org/download/sensor_api_20#message-manipulation. You might need to scroll inside the "code" box though, the get functions might not fit on the screen.

      A 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        @Alain-Mizreh welcome to the MySensors community!

        msg is an object, which contains lots of stuff. msg.getString(char* buffer) is probably what you are looking for.

        Information about the MyMessage object is available at https://www.mysensors.org/download/sensor_api_20#message-manipulation. You might need to scroll inside the "code" box though, the get functions might not fit on the screen.

        A Offline
        A Offline
        Alain Mizreh
        wrote on last edited by
        #3

        @mfalkvidd , Thanks for your reply !
        Would there be some code example to illustrate ?
        I am bad at manipulating variables, and I don't get it...
        The link you gave me is very detailed, however, I don't understand what I should do with all the variables described... Create one local variable for every field ?

        Thanks a lot,

        Regards,

        Alain

        mfalkviddM 1 Reply Last reply
        0
        • A Alain Mizreh

          @mfalkvidd , Thanks for your reply !
          Would there be some code example to illustrate ?
          I am bad at manipulating variables, and I don't get it...
          The link you gave me is very detailed, however, I don't understand what I should do with all the variables described... Create one local variable for every field ?

          Thanks a lot,

          Regards,

          Alain

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

          @Alain-Mizreh only create a variable for the data you are using. If you use a string, get a string.

          1 Reply Last reply
          0

          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


          12

          Online

          12.1k

          Users

          11.2k

          Topics

          113.4k

          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