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.
  • M mitekg

    @hek
    Could u plz help me
    getting in eth GW. Vera and Libs updated.

    **0;0;3;9;Arduino startup complete.
    0;0;3;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
    0;0;3;9;version mismatch0;0;3;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
    0;0;3;9;version mismatch0;0;3;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
    0;0;3;9;version mismatch0;0;3;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
    **

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

    @mitekg

    All the zeroes indicates that something is wrong in radio communication. Check wires.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mitekg
      wrote on last edited by
      #52
      • The new MySensors Bootloader supporting Over-the-air sketch updates ("client"-side).
        • A simple NodeJs Controller to test the OTA stuff ("server"-side).
          Is any instructions, how to use this?
          thx.
      1 Reply Last reply
      0
      • hekH hek

        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 Offline
        DammeD Offline
        Damme
        Code Contributor
        wrote on last edited by
        #53

        @hek
        I think BASE_RADIO_ID should be declared in MyCofig.h

        hekH 1 Reply Last reply
        0
        • hekH hek

          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>);
          
          Z Offline
          Z Offline
          Zeph
          Hero Member
          wrote on last edited by Zeph
          #54

          @hek @ToSa

          Could we get a description of how the OTA programming works?

          (Terminology: the program flash is divided into a bootloader section and an application section; compile sketches go in the application section)

          One approach is to have a separate flash or eeprom chip which one somehow fills (this could even happen at the application level). When booting, check this flash or eeprom and if valid - load into internal program flash, clear the vallidity of the external flash or eeprom (so you won't loop loading it again) and reboot. When you reboot there will be no valid image to copy from external memory, so you jump to the start of internal application flash. This takes external flash as large or larger than application flash (eg: >= 32 KiB for the 328p)

          I think you are taking a different route, where the bootloader is somehow given control, after which it receives nRF packets to RAM, periodically writing another page from RAM to the application section of internal flash. When done, reboot.

          If booting and there is no valid image in external memory and the CRC of the internal application flash section is valid, jump to it as usual.

          I'm not sure if you can also still use serial programming.

          This could be all wrong. It implies keeping (at least part of) the nRF library in bootload program flash, to receive packets. I'm putting it out as a hypotheis to help elicit the real description.

          How big is the OTA bootloader?

          hekH 1 Reply Last reply
          0
          • DammeD Damme

            @hek
            I think BASE_RADIO_ID should be declared in MyCofig.h

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

            @Damme said:

            I think BASE_RADIO_ID should be declared in MyCofig.h

            Yes, that's a better place for it.

            1 Reply Last reply
            0
            • Z Zeph

              @hek @ToSa

              Could we get a description of how the OTA programming works?

              (Terminology: the program flash is divided into a bootloader section and an application section; compile sketches go in the application section)

              One approach is to have a separate flash or eeprom chip which one somehow fills (this could even happen at the application level). When booting, check this flash or eeprom and if valid - load into internal program flash, clear the vallidity of the external flash or eeprom (so you won't loop loading it again) and reboot. When you reboot there will be no valid image to copy from external memory, so you jump to the start of internal application flash. This takes external flash as large or larger than application flash (eg: >= 32 KiB for the 328p)

              I think you are taking a different route, where the bootloader is somehow given control, after which it receives nRF packets to RAM, periodically writing another page from RAM to the application section of internal flash. When done, reboot.

              If booting and there is no valid image in external memory and the CRC of the internal application flash section is valid, jump to it as usual.

              I'm not sure if you can also still use serial programming.

              This could be all wrong. It implies keeping (at least part of) the nRF library in bootload program flash, to receive packets. I'm putting it out as a hypotheis to help elicit the real description.

              How big is the OTA bootloader?

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

              @Zeph, @mitekg

              Right now the OTA works without any need for external flash. @ToSa will have to answer the details when he's back (like size, building, serial programming).

              Yes it uses a VERY stripped down rf24 library.
              https://github.com/mysensors/Arduino/blob/development/Bootloader/MyOtaBootloaderRF24.h

              Not much of the MySensors library is needed.
              https://github.com/mysensors/Arduino/blob/development/Bootloader/MyOtaBootloader.c

              1 Reply Last reply
              0
              • joe.kJ Offline
                joe.kJ Offline
                joe.k
                wrote on last edited by
                #57

                I am in process of upgrading to 1.4b1 - have most things working. I noticed that my status consistently fails during setup() when presenting sensors AND also never receive a return message from controller after a time request. It's always the same two failures.

                Everything works after adding a 100ms delay between calls. Not sure if there's a timing problem somewhere.

                Hek - as always thanks for ALL your contributions. :-)

                Joe K.

                SERIAL CONSOLE OUTPUT:
                sensor started, id 4
                send: 4-4-0-0 s=255,c=0,t=17,pt=0,l=15,st=ok:1.4b1 (18848a2)
                send: 4-4-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                send: 4-4-0-0 s=255,c=3,t=11,pt=0,l=11,st=ok:LCD Display
                send: 4-4-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
                send: 4-4-0-0 s=0,c=0,t=7,pt=0,l=15,st=ok:1.4b1 (18848a2)
                send: 4-4-0-0 s=1,c=0,t=6,pt=0,l=15,st=fail:1.4b1 (18848a2)
                send: 4-4-0-0 s=2,c=0,t=8,pt=0,l=15,st=ok:1.4b1 (18848a2)
                send: 4-4-0-0 s=255,c=3,t=1,pt=0,l=15,st=fail:1.4b1 (18848a2)

                CODE in setup():
                // Send the Sketch Version Information to the Gateway
                gw.sendSketchInfo("LCD Display", "1.0");

                // Register all sensors to gw (they will be created as child devices)
                gw.present(CHILD_ID_DHT_HUM, S_HUM, true);
                delay(100); // needed otherwise status may come back as failed

                gw.present(CHILD_ID_DHT_TEMP, S_TEMP, true);
                delay(100); // needed otherwise status may come back as failed

                gw.present(CHILD_ID_BMP085_BARO, S_BARO, true);
                delay(100); // needed otherwise status may come back as failed & time request doesn't work

                // request time
                gw.requestTime(receiveTime);

                1 Reply Last reply
                0
                • hekH hek

                  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 Offline
                  DammeD Offline
                  Damme
                  Code Contributor
                  wrote on last edited by
                  #58

                  @hek Does the gateway use any eeprom?

                  hekH 1 Reply Last reply
                  0
                  • DammeD Damme

                    @hek Does the gateway use any eeprom?

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

                    @Damme

                    Yes, it uses eeprom for storing routing information.

                    DammeD 1 Reply Last reply
                    0
                    • hekH hek

                      @Damme

                      Yes, it uses eeprom for storing routing information.

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

                      @hek ok, how many bytes does it use?

                      hekH 1 Reply Last reply
                      0
                      • DammeD Damme

                        @hek ok, how many bytes does it use?

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

                        @Damme

                        If you want to store you own data in EEPROM you can use the provided saveState(), loadState(). It makes sure you won't overwrite anything important. If 256 bytes isn't enough you can start writing at position EEPROM_LOCAL_CONFIG_ADDRESS defined in MySensors.h.

                        1 Reply Last reply
                        1
                        • hekH hek

                          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 Offline
                          DammeD Offline
                          Damme
                          Code Contributor
                          wrote on last edited by Damme
                          #62

                          @hek I just cant figure this out:
                          0;0;3;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
                          0;0;3;9;send: 0-0-255-255 s=255,c=3,t=4,pt=0,l=2,st=fail:42
                          the last one isn't sent.What have I missed?
                          I have also tried 42 as int (no "")

                          	msg.destination = 255; 		//NodeID
                          	msg.sender = GATEWAY_ADDRESS;
                          	msg.sensor = 255;	  				//SensorID
                          	msg.type = I_ID_RESPONSE;			//MsgType
                          	mSetCommand(msg,C_INTERNAL); 		//Subtype
                          	mSetRequestAck(msg,true);			//Request ack
                          	mSetAck(msg,false);
                          	msg.set("42");					//Payload
                          	sendRoute(msg);
                          
                          hekH 1 Reply Last reply
                          0
                          • hekH hek

                            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>);
                            
                            marceltrapmanM Offline
                            marceltrapmanM Offline
                            marceltrapman
                            Mod
                            wrote on last edited by
                            #63

                            @hek Do you know if the ota is something initiated by the controller or do we update the gateway with a new version and will the gateway be responsible?

                            Fulltime Servoy Developer
                            Parttime Moderator MySensors board

                            I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
                            I have a FABtotum to print cases.

                            hekH 1 Reply Last reply
                            0
                            • marceltrapmanM marceltrapman

                              @hek Do you know if the ota is something initiated by the controller or do we update the gateway with a new version and will the gateway be responsible?

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

                              @marceltrapman

                              The controller will be responsible for initiating and serving the new sketch version. There is basically no changes in gateway except being able to handle binary data.

                              marceltrapmanM 1 Reply Last reply
                              0
                              • DammeD Damme

                                @hek I just cant figure this out:
                                0;0;3;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
                                0;0;3;9;send: 0-0-255-255 s=255,c=3,t=4,pt=0,l=2,st=fail:42
                                the last one isn't sent.What have I missed?
                                I have also tried 42 as int (no "")

                                	msg.destination = 255; 		//NodeID
                                	msg.sender = GATEWAY_ADDRESS;
                                	msg.sensor = 255;	  				//SensorID
                                	msg.type = I_ID_RESPONSE;			//MsgType
                                	mSetCommand(msg,C_INTERNAL); 		//Subtype
                                	mSetRequestAck(msg,true);			//Request ack
                                	mSetAck(msg,false);
                                	msg.set("42");					//Payload
                                	sendRoute(msg);
                                
                                hekH Offline
                                hekH Offline
                                hek
                                Admin
                                wrote on last edited by
                                #65

                                @Damme

                                mSetRequestAck(msg,true);

                                You should probably not request ack back on a id-response. But I doubt that is the cause for transmission error. What is happening in the sensor node?

                                DammeD 2 Replies Last reply
                                0
                                • hekH hek

                                  @Damme

                                  mSetRequestAck(msg,true);

                                  You should probably not request ack back on a id-response. But I doubt that is the cause for transmission error. What is happening in the sensor node?

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

                                  @hek Tried with no ack also. And the node doesn't recieve anything. I'm out of components to build myself a sniffer right now.. Might have to kill something.. :boom: I can recieve From the node though.. but the node does not read from gateway..

                                  hekH 1 Reply Last reply
                                  0
                                  • DammeD Damme

                                    @hek Tried with no ack also. And the node doesn't recieve anything. I'm out of components to build myself a sniffer right now.. Might have to kill something.. :boom: I can recieve From the node though.. but the node does not read from gateway..

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

                                    @Damme

                                    You only live 190 km from me. Come and get some :smile:

                                    What kind of antenna on your gateway? Have you tried lowering transmit power of gateway?

                                    1 Reply Last reply
                                    1
                                    • hekH hek

                                      @Damme

                                      mSetRequestAck(msg,true);

                                      You should probably not request ack back on a id-response. But I doubt that is the cause for transmission error. What is happening in the sensor node?

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

                                      @hek I fixed the problem , it was the RF24_PA_LEVEL_GW .. needed to be low.

                                      You are correct with the ack on id-response, it gets all fucked up. Stuck in loop requesting ID 10+times/second. And doesnt register the id.. Too bad. would be really good for me to know if the sensor actually got the id_response or not... (and if it's sent as node 255 or node newid doesnt really matter..)

                                      edit:
                                      I changed my aproach to checking if sendRoute(msg) is true. But I still have a problem that the node actually recieves the packagt but just ignored is. sometimes I need to reset the node for it to get accept the new ID.. example;

                                      0;0;3;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
                                      0;0;3;9;send: 0-0-255-255 s=255,c=3,t=4,pt=1,l=1,st=ok:20
                                      0;0;3;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
                                      0;0;3;9;send: 0-0-255-255 s=255,c=3,t=4,pt=1,l=1,st=ok:21
                                      0;0;3;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
                                      0;0;3;9;send: 0-0-255-255 s=255,c=3,t=4,pt=1,l=1,st=ok:22
                                      0;0;3;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0:
                                      0;0;3;9;send: 0-0-255-255 s=255,c=3,t=4,pt=1,l=1,st=ok:23
                                      

                                      I'll try to look at the debug output on the node tomorrow..

                                      btw: \n missing line 278 mysensor.cpp debug(PSTR("version mismatch"));

                                      1 Reply Last reply
                                      0
                                      • hekH hek

                                        @marceltrapman

                                        The controller will be responsible for initiating and serving the new sketch version. There is basically no changes in gateway except being able to handle binary data.

                                        marceltrapmanM Offline
                                        marceltrapmanM Offline
                                        marceltrapman
                                        Mod
                                        wrote on last edited by
                                        #69

                                        @hek said:

                                        The controller will be responsible for initiating and serving the new sketch version. There is basically no changes in gateway except being able to handle binary data.

                                        How do I get this started Henrik?

                                        Fulltime Servoy Developer
                                        Parttime Moderator MySensors board

                                        I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
                                        I have a FABtotum to print cases.

                                        hekH 1 Reply Last reply
                                        0
                                        • marceltrapmanM marceltrapman

                                          @hek said:

                                          The controller will be responsible for initiating and serving the new sketch version. There is basically no changes in gateway except being able to handle binary data.

                                          How do I get this started Henrik?

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

                                          @marceltrapman

                                          Until @ToSa is back, I suggest you have a look at how the NodeJSController serves hex-files.
                                          https://github.com/mysensors/Arduino/blob/development/NodeJsController/NodeJsController.js

                                          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