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. Convert sketch from 1.3 to 1.4

Convert sketch from 1.3 to 1.4

Scheduled Pinned Locked Moved Development
14 Posts 5 Posters 7.2k Views 3 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.
  • hekH hek

    @BulldogLowell

    You just have to compare the provided examples between 1.3<->1.4. They have all been converted.

    BulldogLowellB Offline
    BulldogLowellB Offline
    BulldogLowell
    Contest Winner
    wrote on last edited by
    #4

    @hek

    MyMessage msg(0,V_TEMP); 
    

    Is this needed for every child device??

    YveauxY 1 Reply Last reply
    0
    • BulldogLowellB BulldogLowell

      @hek

      MyMessage msg(0,V_TEMP); 
      

      Is this needed for every child device??

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #5

      @BulldogLowell yes, if you declare a message for each child and initialize it once.
      You can also create a single message in loop () and change its properties on the fly (don't have my PC near right now, so no code example.... :cry:

      http://yveaux.blogspot.nl

      BulldogLowellB 1 Reply Last reply
      0
      • YveauxY Yveaux

        @BulldogLowell yes, if you declare a message for each child and initialize it once.
        You can also create a single message in loop () and change its properties on the fly (don't have my PC near right now, so no code example.... :cry:

        BulldogLowellB Offline
        BulldogLowellB Offline
        BulldogLowell
        Contest Winner
        wrote on last edited by
        #6

        @Yveaux

        thanks, I guess I have tunnel vision here.

        I have 3 hours on a plane tonight, I'll fiddle with it then and see if I can't get a sketch to even compile!

        gw.loadState???

        where is all of this explained? Did I miss some document that has all of these?

        YveauxY 1 Reply Last reply
        0
        • hekH hek

          @BulldogLowell

          You just have to compare the provided examples between 1.3<->1.4. They have all been converted.

          clippermiamiC Offline
          clippermiamiC Offline
          clippermiami
          Hero Member
          wrote on last edited by
          #7

          @hek So, all the examples provided on MySensors.org are already configured for the 1.4 Library including the Serial Gateway? It will probably be easier to simply make minor tweaks to the examples to suit my specific configs then.

          1 Reply Last reply
          0
          • BulldogLowellB BulldogLowell

            @Yveaux

            thanks, I guess I have tunnel vision here.

            I have 3 hours on a plane tonight, I'll fiddle with it then and see if I can't get a sketch to even compile!

            gw.loadState???

            where is all of this explained? Did I miss some document that has all of these?

            YveauxY Offline
            YveauxY Offline
            Yveaux
            Mod
            wrote on last edited by
            #8

            @BulldogLowell The 1.4 library is still under development and documentation is only present in the code. If you're unable to read the code then maybe you should delay the switch to 1.4 until released and stable...

            http://yveaux.blogspot.nl

            clippermiamiC BulldogLowellB 2 Replies Last reply
            0
            • YveauxY Yveaux

              @BulldogLowell The 1.4 library is still under development and documentation is only present in the code. If you're unable to read the code then maybe you should delay the switch to 1.4 until released and stable...

              clippermiamiC Offline
              clippermiamiC Offline
              clippermiami
              Hero Member
              wrote on last edited by
              #9

              @Yveaux Good idea :)

              John

              1 Reply Last reply
              0
              • YveauxY Yveaux

                @BulldogLowell The 1.4 library is still under development and documentation is only present in the code. If you're unable to read the code then maybe you should delay the switch to 1.4 until released and stable...

                BulldogLowellB Offline
                BulldogLowellB Offline
                BulldogLowell
                Contest Winner
                wrote on last edited by
                #10

                @Yveaux said:

                If you're unable to read the code then maybe you should delay the switch to 1.4 until released and stable...

                sort of goes without saying, right?!!

                I can read the code, I just have to spend the time deciphering the calls.

                I have built some more complex sketches that were using a lot of the richness of the MySensors capability, I am just trying to piece it all together from the bits that are in each (very lean) example.

                YveauxY 1 Reply Last reply
                0
                • BulldogLowellB BulldogLowell

                  @Yveaux said:

                  If you're unable to read the code then maybe you should delay the switch to 1.4 until released and stable...

                  sort of goes without saying, right?!!

                  I can read the code, I just have to spend the time deciphering the calls.

                  I have built some more complex sketches that were using a lot of the richness of the MySensors capability, I am just trying to piece it all together from the bits that are in each (very lean) example.

                  YveauxY Offline
                  YveauxY Offline
                  Yveaux
                  Mod
                  wrote on last edited by
                  #11

                  @BulldogLowell said:

                  @Yveaux said:

                  sort of goes without saying, right?!!

                  Not necessarily... Some people just want it because it's new and probably better.
                  Then they get frustrated when they run into problems.

                  I'm not saying you're one of them and I also don't mean you cannot read code, I just want to stress that it might be better to wait unless you are prepared to run into troubles ;-)

                  http://yveaux.blogspot.nl

                  BulldogLowellB 1 Reply Last reply
                  0
                  • YveauxY Yveaux

                    @BulldogLowell said:

                    @Yveaux said:

                    sort of goes without saying, right?!!

                    Not necessarily... Some people just want it because it's new and probably better.
                    Then they get frustrated when they run into problems.

                    I'm not saying you're one of them and I also don't mean you cannot read code, I just want to stress that it might be better to wait unless you are prepared to run into troubles ;-)

                    BulldogLowellB Offline
                    BulldogLowellB Offline
                    BulldogLowell
                    Contest Winner
                    wrote on last edited by
                    #12

                    @Yveaux

                    yeah, perhaps I'll go back to creating new stuff and wait for the dust to settle on the API.

                    I may sneak n a bit of time on this, though. I cannot stand not knowing! :)

                    thanks!!

                    YveauxY 1 Reply Last reply
                    0
                    • BulldogLowellB BulldogLowell

                      @Yveaux

                      yeah, perhaps I'll go back to creating new stuff and wait for the dust to settle on the API.

                      I may sneak n a bit of time on this, though. I cannot stand not knowing! :)

                      thanks!!

                      YveauxY Offline
                      YveauxY Offline
                      Yveaux
                      Mod
                      wrote on last edited by Yveaux
                      #13

                      @BulldogLowell Just some stuff for in the plane tonight, should you decide to dive into 1.4 a little deeper.
                      It shows how to create and send messages with the 1.4 library.

                      The example below shows 3 possible scenarios, each with their own pros & cons. Combinations are also possible.
                      It will depend on the application and your preference which one to choose.

                      I prefer option 1.

                      #include <MySensor.h>
                      
                      #define NODE_ID              (64)
                      #define CHILD_ID_TEMP         (0)
                      #define CHILD_ID_HUMIDITY     (1)
                      #define CHILD_ID_LIGHT        (2)
                      
                      MySensor gw;
                      
                      void setup()
                      {
                        gw.begin( NULL, NODE_ID, false /*relay*/ );
                        gw.sendSketchInfo("My 1.4 Sensor", "1.0");
                        gw.present(CHILD_ID_TEMP, S_TEMP);
                        gw.present(CHILD_ID_HUMIDITY, S_HUM);
                        gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
                      }
                      
                      void loop()
                      {
                        // ... fetch data from sensors ...
                        double humi = SHT2x.GetHumidity();
                        double temp = SHT2x.GetTemperature();
                        int lightLevel = analogRead(LDR_PIN)/10.23; 
                      
                        // Option 1 -- compact, message on stack:
                        // Create a new MyMessage instance for every message to send,
                        // and set the value by chaining (using the reference to the
                        // MyMessage instance returned by the constructor)
                        gw.send( MyMessage(CHILD_ID_TEMP, V_TEMP).set(temp, 1) );
                        gw.send( MyMessage(CHILD_ID_HUMIDITY, V_HUM).set(humi, 1) );
                        gw.send( MyMessage(CHILD_ID_LIGHT, V_LIGHT_LEVEL).set(lightLevel) );
                      
                        // Option 2 -- longer, message in RAM:
                        // Create the MyMessage instance once, and re-use it for every sensor
                        static MyMessage msg;
                        msg.setSensor(CHILD_ID_TEMP);
                        msg.setType(V_TEMP);
                        msg.set(temp, 1);
                        gw.send(msg);
                      
                        msg.setSensor(CHILD_ID_HUMIDITY);
                        msg.setType(V_HUM);
                        msg.set(humi, 1);
                        gw.send(msg);
                        // etc.
                      
                        // Option 3 -- static msg for each sensor. More RAM, less CPU:
                        // Create a MyMessage instance for each sensor once.
                        static MyMessage msgTemp;
                        static MyMessage msgHum;
                        static MyMessage msgLight;
                        static bool initDone = false;
                        if (!initDone)   // Better to do the init once in setup(), it is only here for clarity.
                        {
                          msgTemp.setSensor(CHILD_ID_TEMP);
                          msgTemp.setType(V_TEMP);
                          msgTemp.setSensor(CHILD_ID_HUMIDITY);
                          msgTemp.setType(V_HUM);
                          msgTemp.setSensor(CHILD_ID_LIGHT);
                          msgTemp.setType(V_LIGHT_LEVEL);
                          initDone = true;
                        }
                        msgTemp.set(temp, 1);
                        gw.send(msgTemp);
                        msgHum.set(humi, 1);
                        gw.send(msgHum);
                        msgLight.set(light);
                        gw.send(msgLight);
                      
                        // ... e.g. sleep the CPU & radio
                      }
                      

                      http://yveaux.blogspot.nl

                      BulldogLowellB 1 Reply Last reply
                      1
                      • YveauxY Yveaux

                        @BulldogLowell Just some stuff for in the plane tonight, should you decide to dive into 1.4 a little deeper.
                        It shows how to create and send messages with the 1.4 library.

                        The example below shows 3 possible scenarios, each with their own pros & cons. Combinations are also possible.
                        It will depend on the application and your preference which one to choose.

                        I prefer option 1.

                        #include <MySensor.h>
                        
                        #define NODE_ID              (64)
                        #define CHILD_ID_TEMP         (0)
                        #define CHILD_ID_HUMIDITY     (1)
                        #define CHILD_ID_LIGHT        (2)
                        
                        MySensor gw;
                        
                        void setup()
                        {
                          gw.begin( NULL, NODE_ID, false /*relay*/ );
                          gw.sendSketchInfo("My 1.4 Sensor", "1.0");
                          gw.present(CHILD_ID_TEMP, S_TEMP);
                          gw.present(CHILD_ID_HUMIDITY, S_HUM);
                          gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
                        }
                        
                        void loop()
                        {
                          // ... fetch data from sensors ...
                          double humi = SHT2x.GetHumidity();
                          double temp = SHT2x.GetTemperature();
                          int lightLevel = analogRead(LDR_PIN)/10.23; 
                        
                          // Option 1 -- compact, message on stack:
                          // Create a new MyMessage instance for every message to send,
                          // and set the value by chaining (using the reference to the
                          // MyMessage instance returned by the constructor)
                          gw.send( MyMessage(CHILD_ID_TEMP, V_TEMP).set(temp, 1) );
                          gw.send( MyMessage(CHILD_ID_HUMIDITY, V_HUM).set(humi, 1) );
                          gw.send( MyMessage(CHILD_ID_LIGHT, V_LIGHT_LEVEL).set(lightLevel) );
                        
                          // Option 2 -- longer, message in RAM:
                          // Create the MyMessage instance once, and re-use it for every sensor
                          static MyMessage msg;
                          msg.setSensor(CHILD_ID_TEMP);
                          msg.setType(V_TEMP);
                          msg.set(temp, 1);
                          gw.send(msg);
                        
                          msg.setSensor(CHILD_ID_HUMIDITY);
                          msg.setType(V_HUM);
                          msg.set(humi, 1);
                          gw.send(msg);
                          // etc.
                        
                          // Option 3 -- static msg for each sensor. More RAM, less CPU:
                          // Create a MyMessage instance for each sensor once.
                          static MyMessage msgTemp;
                          static MyMessage msgHum;
                          static MyMessage msgLight;
                          static bool initDone = false;
                          if (!initDone)   // Better to do the init once in setup(), it is only here for clarity.
                          {
                            msgTemp.setSensor(CHILD_ID_TEMP);
                            msgTemp.setType(V_TEMP);
                            msgTemp.setSensor(CHILD_ID_HUMIDITY);
                            msgTemp.setType(V_HUM);
                            msgTemp.setSensor(CHILD_ID_LIGHT);
                            msgTemp.setType(V_LIGHT_LEVEL);
                            initDone = true;
                          }
                          msgTemp.set(temp, 1);
                          gw.send(msgTemp);
                          msgHum.set(humi, 1);
                          gw.send(msgHum);
                          msgLight.set(light);
                          gw.send(msgLight);
                        
                          // ... e.g. sleep the CPU & radio
                        }
                        
                        BulldogLowellB Offline
                        BulldogLowellB Offline
                        BulldogLowell
                        Contest Winner
                        wrote on last edited by
                        #14

                        @Yveaux

                        WOW! thanks!

                        I appreciate that and will look it over. Hopefully I'll have something to share with you tomorrow (or a problem that I need help).

                        thanks again.

                        Jim

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


                        12

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.0k

                        Posts


                        Copyright 2019 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