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. Announcements
  3. 1.4 Beta

1.4 Beta

Scheduled Pinned Locked Moved Announcements
1.4betahelp
129 Posts 18 Posters 87.1k 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.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #1

    The 1.4 version of the MySenors Arduino library is new open for beta testing.

    Arduino library and examples
    https://github.com/mysensors/Arduino/tree/development

    Vera plugin (1.4)
    https://github.com/mysensors/Vera/tree/development

    Here are some of the hi-lights.

    • Improved communication reliability (now uses hardware acks and resend functionality).
    • Simplified sketches (only one include needed).
    • Most common sleep scenarios build in.
    • Helper for permanently storing values in the Arduinos EEPROM.
    • Acknowledgments can now be requested from gateway and other sensors in network.
    • Smaller footprint.
    • The message structure has been adopted to work better on RPi platform.
    • Binary payloads supported and used for integers between sensors.
    • Configuration message (only metric setting in it today).
    • Allow static parent (no dynamic lookups)
    • Callbacks for incoming messages and time. No synchronous waiting methods any more -> no missed messages.

    All examples in the development branch above has been converted to use the new functionality of the library.

    The new API:

    /**
    * Constructor
    *
    * Creates a new instance of Sensor class.
    *
    * @param _cepin The pin attached to RF24 Chip Enable on the RF module (defualt 9)
    * @param _cspin The pin attached to RF24 Chip Select (default 10)
    */
    MySensor(uint8_t _cepin=9, uint8_t _cspin=10);
    
    /**
    * Begin operation of the MySensors library
    *
    * Call this in setup(), before calling any other sensor net library methods.
    * @param incomingMessageCallback Callback function for incoming messages from other nodes or controller and request responses. Default is NULL.
    * @param nodeId The unique id (1-254) for this sensor. Default is AUTO(255) which means sensor tries to fetch an id from controller.
    * @param repeaterMode Activate repeater mode. This node will forward messages to other nodes in the radio network. Make sure to call process() regularly. Default in false
    * @param parentNodeId Use this to force node to always communicate with a certain parent node. Default is AUTO which means node automatically tries to find a parent.
    * @param paLevel Radio PA Level for this sensor. Default RF24_PA_MAX
    * @param channel Radio channel. Default is channel 76
    * @param dataRate Radio transmission speed. Default RF24_1MBPS
    */
    
    void begin(void (* msgCallback)(const MyMessage &)=NULL, uint8_t nodeId=AUTO, boolean repeaterMode=false, uint8_t parentNodeId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE);
    
    /**
     * Return the nodes nodeId.
     */
    uint8_t getNodeId();
    
    /**
    * Each node must present all attached sensors before any values can be handled correctly by the controller.
    * It is usually good to present all attached sensors after power-up in setup().
    *
    * @param sensorId Select a unique sensor id for this sensor. Choose a number between 0-254.
    * @param sensorType The sensor type. See sensor typedef in MyMessage.h.
    * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
    */
    void present(uint8_t sensorId, uint8_t sensorType, bool ack=false);
    
    /**
     * Sends sketch meta information to the gateway. Not mandatory but a nice thing to do.
     * @param name String containing a short Sketch name or NULL  if not applicable
     * @param version String containing a short Sketch version or NULL if not applicable
     * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
     *
     */
    void sendSketchInfo(const char *name, const char *version, bool ack=false);
    
    /**
    * Sends a message to gateway or one of the other nodes in the radio network
    *
    * @param msg Message to send
    * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
    * @return true Returns true if message reached the first stop on its way to destination.
    */
    bool send(MyMessage &msg, bool ack=false);
    
    /**
     * Send this nodes battery level to gateway.
     * @param level Level between 0-100(%)
     * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
     *
     */
    void sendBatteryLevel(uint8_t level, bool ack=false);
    
    /**
    * Requests a value from gateway or some other sensor in the radio network.
    * Make sure to add callback-method in begin-method to handle request responses.
    *
    * @param childSensorId  The unique child id for the different sensors connected to this Arduino. 0-254.
    * @param variableType The variableType to fetch
    * @param destination The nodeId of other node in radio network. Default is gateway
    */
    void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination=GATEWAY_ADDRESS);
    
    /**
     * Requests time from controller. Answer will be delivered to callback.
     *
     * @param callback for time request. Incoming argument is seconds since 1970.
     */
    void requestTime(void (* timeCallback)(unsigned long));
    
    
    /**
     * Processes incoming messages to this node. If this is a relaying node it will
    * Returns true if there is a message addressed for this node just was received.
    * Use callback to handle incoming messages.
    */
    boolean process();
    
    /**
     * Returns the most recent node configuration received from controller
     */
    ControllerConfig getConfig();
    
    /**
     * Save a state (in local EEPROM). Good for actuators to "remember" state between
     * power cycles.
     *
     * You have 256 bytes to play with. Note that there is a limitation on the number
     * of writes the EEPROM can handle (~100 000 cycles).
     *
     * @param pos The position to store value in (0-255)
     * @param Value to store in position
     */
    void saveState(uint8_t pos, uint8_t value);
    
    /**
     * Load a state (from local EEPROM).
     *
     * @param pos The position to fetch value from  (0-255)
     * @return Value to store in position
     */
    uint8_t loadState(uint8_t pos);
    
    /**
    * Returns the last received message
    */
    MyMessage& getLastMessage(void);
    
    /**
     * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer.
     * @param ms Number of milliseconds to sleep.
     */
    void sleep(int ms);
    
    /**
     * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
     * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
     * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
     * @param interrupt Interrupt that should trigger the wakeup
     * @param mode RISING, FALLING, CHANGE
     * @param ms Number of milliseconds to sleep or 0 to sleep forever
     * @return true if wake up was triggered by pin change and false means timer woke it up.
     */
    bool sleep(int interrupt, int mode, int ms=0);
    
    /**
     * getInternalTemp
     *
     * Read temp from internal (ATMEGA328 only) temperature sensor. This reading is very
     * inaccurate so we round the result to full degrees celsius.
     * http://playground.arduino.cc/Main/InternalTemperatureSensor
     *
     * @return Temperature in full degrees Celsius.
     */
    int getInternalTemp(void);
    

    ###To convert an old 1.3 sketch follow this guide:

    Include section

    Remove the following includes
    #include <Sleep_n0m1.h>
    #include <EEPROM.h>
    #include <RF24.h>
    #include <Sensor.h>
    #include <Relay.h>

    Add
    #include <MySensor.h>

    Global variable scope

    Change the following lines

    Sensor gw;
    or
    Relay gw;
    

    To

    MySensor gw;
    

    Also message containers for outgoing messages. E.g. Light level message for child sensor id 1.

    MyMessage msg(1, V_LIGHT_LEVEL);
    

    ####Setup()
    In setup() replace sendPresentation with present.
    Also note that begin() now allows you to add an function-argument to get callbacks for incoming messages (actuators). begin also controls wether this node should act as an repeater node. See above for full argument list.

    ####Loop()

    The sending of values looks a bit different. The old sketches could look like this:

    gw.sendVariable(CHILD_ID_LIGHT, V_LIGHT_LEVEL, lux);
    

    In new code you send a value by using the MyMessage contaner defined in global scope. Fill it with the value to send like this (where lux is light level in this case).

     gw.send(msg.set(lux));
    

    Replace any sleeping with the new build in sleep functions. The old code might have a few lines like this:

    delay(500);
    gw.powerDown();
    sleep.pwrDownMode(); //set sleep mode
    sleep.sleepDelay(SLEEP_TIME * 1000);
    

    Replace those with:

    gw.sleep(<sleep time in milliseconds>);
    
    DammeD Z marceltrapmanM hekH liningerL 8 Replies Last reply
    0
    • jendrushJ Offline
      jendrushJ Offline
      jendrush
      wrote on last edited by
      #2

      @Hek Ok, so last time i was writing about my problem with latest version of this beta, and Relays not working. When i am sending message, example 11;1;1;2;1 with, or wothout newline char nothing happen. Even stranger is that serial gateway giving me message with 4 segments, istead of normal 5. Look at the screenshoot: http://screenshooter.net/1288732/vlliswb . This is Relay + button, but same thing is with Relay alone.

      1 Reply Last reply
      -1
      • BSoftB Offline
        BSoftB Offline
        BSoft
        wrote on last edited by BSoft
        #3

        While server was down, I've used a recent tab from this post. This file represent the mhl backup

        Due to server upload limits, removed one photo and zipped the mhl file. It is like it never happened. :)

        Arduino Library 1_4b1_ Call for beta testers_ MySensors Forum.zip

        MisterEM 1 Reply Last reply
        -1
        • MisterEM Offline
          MisterEM Offline
          MisterE
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • BSoftB BSoft

            While server was down, I've used a recent tab from this post. This file represent the mhl backup

            Due to server upload limits, removed one photo and zipped the mhl file. It is like it never happened. :)

            Arduino Library 1_4b1_ Call for beta testers_ MySensors Forum.zip

            MisterEM Offline
            MisterEM Offline
            MisterE
            wrote on last edited by
            #5

            @BSoft

            Crowd Backup (TM)

            1 Reply Last reply
            0
            • DammeD Offline
              DammeD Offline
              Damme
              Code Contributor
              wrote on last edited by
              #6

              Hello

              I'm using serialgateway and trying to interface with a linux machine.

              I setup serial with a simple stty -F /dev/ttyUSB0 cs8 115200 -onlcr -icrnl
              cat /dev/ttyUSB0 works fine;
              0;0;3;9;Arduino startup complete.
              0;0;3;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,cr=ok:
              255;255;3;3;

              but I am unable to send data from the gateway
              echo -n -e "255;255;3;4;1\n" > /dev/ttyUSB0

              Nothing happens, not even in perl I can get it to work.
              $port->write("255;255;3;4;1\n");

              what am I doing wrong?

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

                @Damme said:

                $port->write("255;255;3;4;1\n");

                Try
                $port->write("255;255;3;0;4;1\n");

                DammeD 1 Reply Last reply
                0
                • hekH hek

                  @Damme said:

                  $port->write("255;255;3;4;1\n");

                  Try
                  $port->write("255;255;3;0;4;1\n");

                  DammeD Offline
                  DammeD Offline
                  Damme
                  Code Contributor
                  wrote on last edited by
                  #8

                  @hek

                  Thanks, that worked. I thought I understood the message layout.. never seen that 0 before:)

                  hekH 1 Reply Last reply
                  0
                  • DammeD Damme

                    @hek

                    Thanks, that worked. I thought I understood the message layout.. never seen that 0 before:)

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

                    @Damme said:

                    Thanks, that worked. I thought I understood the message layout.. never seen that 0 before:)

                    It's a change in the serial protocol for 1.4.
                    1 = request ack back from destination node.
                    0 = no ack.

                    1 Reply Last reply
                    0
                    • jendrushJ Offline
                      jendrushJ Offline
                      jendrush
                      wrote on last edited by jendrush
                      #10

                      @hek said:

                      It's a change in the serial protocol for 1.4.

                      Could you describe it better keeping in mind my problem with Relay? How the message should look like to turn on Relay? Previously message like this worked ok - 11;1;1;2;1.

                      DammeD 1 Reply Last reply
                      0
                      • jendrushJ jendrush

                        @hek said:

                        It's a change in the serial protocol for 1.4.

                        Could you describe it better keeping in mind my problem with Relay? How the message should look like to turn on Relay? Previously message like this worked ok - 11;1;1;2;1.

                        DammeD Offline
                        DammeD Offline
                        Damme
                        Code Contributor
                        wrote on last edited by
                        #11

                        @jendrush I suppose it should be 11:1:1:0:2:1 then

                        @hek what about C_STREAM ? Didnt find much about it.

                        hekH jendrushJ 2 Replies Last reply
                        0
                        • DammeD Damme

                          @jendrush I suppose it should be 11:1:1:0:2:1 then

                          @hek what about C_STREAM ? Didnt find much about it.

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

                          @Damme

                          It will be used for firmware updates.

                          DammeD 1 Reply Last reply
                          1
                          • DammeD Damme

                            @jendrush I suppose it should be 11:1:1:0:2:1 then

                            @hek what about C_STREAM ? Didnt find much about it.

                            jendrushJ Offline
                            jendrushJ Offline
                            jendrush
                            wrote on last edited by
                            #13

                            @Damme said:

                            I suppose it should be 11:1:1:0:2:1 then

                            I fugured it out yesterday, but thanx!

                            1 Reply Last reply
                            0
                            • hekH hek

                              @Damme

                              It will be used for firmware updates.

                              DammeD Offline
                              DammeD Offline
                              Damme
                              Code Contributor
                              wrote on last edited by Damme
                              #14

                              @hek

                              I just tried to send myself a picture over the network. real ugly code but it worked.. thought if I put a small cam and someone rings on the doorbell or something.. :) (Right now I just read the data from SPI flash)

                              hekH 1 Reply Last reply
                              1
                              • DammeD Damme

                                @hek

                                I just tried to send myself a picture over the network. real ugly code but it worked.. thought if I put a small cam and someone rings on the doorbell or something.. :) (Right now I just read the data from SPI flash)

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

                                @Damme

                                great

                                1 Reply Last reply
                                0
                                • MisterEM Offline
                                  MisterEM Offline
                                  MisterE
                                  wrote on last edited by
                                  #16
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • DammeD Offline
                                    DammeD Offline
                                    Damme
                                    Code Contributor
                                    wrote on last edited by Damme
                                    #17

                                    I've tried the lib for a while now and found the following:

                                    Then using ack=1 the returned message is exacly the one I sent. No way of knowing if its a request or an ACK.

                                    example:
                                    Client sends
                                    3;255;3;6;0 (Give me configuration 0 (btw, why not leave config as a byte 0-255 instead of hardcoing it? I could have plenty of uses for configuration-values.)
                                    Gateway responds: 3;255;3;6;M and requests ack
                                    client sends
                                    3;255;3;6;M
                                    my software tried to lookup config id 'M' (Not a big deal for letter, but what if its a number?)
                                    maybe ACK should be some sort of incremental number in return in special message type. I dont really know what is best.
                                    It would be great if GW resends the messsage automatically a couple of times (configurable) if ACK = 1.

                                    I've also noticed during DEBUG enabled that the message gets overwritten by old one, i.e.

                                    send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=15,st=fail:1.4b1 (18848a2)
                                    send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=4,st=ok:test1 (18848a2)
                                    send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:2.0t1 (18848a2)
                                    (message 2: test1, message 3: 2.0)

                                    Edit; One more thing
                                    Do I really need one gw.process(); before each gw.send(..); in the loop? I seam to loose messages if I dont do like that.

                                    void loop()
                                    {
                                    delay(dht.getMinimumSamplingPeriod());

                                    gw.process();
                                    float temperature = dht.getTemperature();
                                    gw.send(msgTemp.set(temperature, 1));

                                    gw.process();
                                    float humidity = dht.getHumidity();
                                    gw.send(msgHum.set(humidity, 1));

                                    // gw.sleep(SLEEP_TIME); //Seems to break recieing message, loosing ~75%

                                    }

                                    YveauxY DammeD 2 Replies Last reply
                                    0
                                    • DammeD Damme

                                      I've tried the lib for a while now and found the following:

                                      Then using ack=1 the returned message is exacly the one I sent. No way of knowing if its a request or an ACK.

                                      example:
                                      Client sends
                                      3;255;3;6;0 (Give me configuration 0 (btw, why not leave config as a byte 0-255 instead of hardcoing it? I could have plenty of uses for configuration-values.)
                                      Gateway responds: 3;255;3;6;M and requests ack
                                      client sends
                                      3;255;3;6;M
                                      my software tried to lookup config id 'M' (Not a big deal for letter, but what if its a number?)
                                      maybe ACK should be some sort of incremental number in return in special message type. I dont really know what is best.
                                      It would be great if GW resends the messsage automatically a couple of times (configurable) if ACK = 1.

                                      I've also noticed during DEBUG enabled that the message gets overwritten by old one, i.e.

                                      send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=15,st=fail:1.4b1 (18848a2)
                                      send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=4,st=ok:test1 (18848a2)
                                      send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:2.0t1 (18848a2)
                                      (message 2: test1, message 3: 2.0)

                                      Edit; One more thing
                                      Do I really need one gw.process(); before each gw.send(..); in the loop? I seam to loose messages if I dont do like that.

                                      void loop()
                                      {
                                      delay(dht.getMinimumSamplingPeriod());

                                      gw.process();
                                      float temperature = dht.getTemperature();
                                      gw.send(msgTemp.set(temperature, 1));

                                      gw.process();
                                      float humidity = dht.getHumidity();
                                      gw.send(msgHum.set(humidity, 1));

                                      // gw.sleep(SLEEP_TIME); //Seems to break recieing message, loosing ~75%

                                      }

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

                                      @Damme Other wireless protocols usually have a counter which is increased with each message. Returning the counter as an ack would be sufficient to correlate the ack and the original message.
                                      Returning the whole message seems like overkill indeed...

                                      The send-methods could e.g. return the Id counter of the message sent, and an app waiting for an ack on that message should check for this value in any ack received (using some timeout)

                                      http://yveaux.blogspot.nl

                                      hekH 1 Reply Last reply
                                      0
                                      • DammeD Offline
                                        DammeD Offline
                                        Damme
                                        Code Contributor
                                        wrote on last edited by Damme
                                        #19

                                        Additional comment on config;
                                        I think it should be request config, response config messages.

                                        I also think its a bit odd that the actuator reports as
                                        gw.present(2, S_LIGHT);
                                        but requests as
                                        if (message.type==V_LIGHT) {

                                        V_LIGHT != S_LIGHT (2 vs 3)
                                        I think the def should follow as much as possible.

                                        hope any of my thoughts are somewhat useful

                                        YveauxY 1 Reply Last reply
                                        0
                                        • DammeD Damme

                                          Additional comment on config;
                                          I think it should be request config, response config messages.

                                          I also think its a bit odd that the actuator reports as
                                          gw.present(2, S_LIGHT);
                                          but requests as
                                          if (message.type==V_LIGHT) {

                                          V_LIGHT != S_LIGHT (2 vs 3)
                                          I think the def should follow as much as possible.

                                          hope any of my thoughts are somewhat useful

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

                                          @Damme there's a lot of Vera legacy in there... This forum had a discussion going on about decoupling from Vera, but I'm afraid that got lost in the crash...

                                          http://yveaux.blogspot.nl

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


                                          5

                                          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