• Categories
    • Recent
    • Tags
    • Popular
    • Register
    • Login

    Sensor state

    Scheduled Pinned Locked Moved General Discussion
    10 Posts 2 Posters 4.0k Views 1 Watching
    Loading More Posts
    • 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.
    • B Offline
      benya
      last edited by

      I'm building MySensors node connected to the relay.
      It's presented as BINARY sensor type.
      Mycontroller properly shows node with a child sensor.
      But nowhere in UI I'm able to change sensor state.
      A few questions:

      • Does node have to report current sensor state?
      • when node gets new state from controller, is it better to save state in EEPROM or
      • is it better to request new state from controller every time node boots?
      • I understood controller keeps sensor state in the database. Node has ability to report sensor state. Which value has higher priority - state in the database or recently reported value from sensor?
      jkandasaJ 1 Reply Last reply Reply Quote 0
      • jkandasaJ Offline
        jkandasa @benya
        last edited by

        @benya To change sensor(relay) state you have sensor/sensor variable entry on MyController server. We can add Sensor/Sensor variable in multiple ways.

        • Does node have to report current sensor state?

        Yes, By reporting sensor/sensor variable state from node, when node turns ON, entry created on MyController

        • when node gets new state from controller, is it better to save state in EEPROM or
        • is it better to request new state from controller every time node boots?

        It is about your convenience, you can either store state on Node's EEPROM, or you can request from MyController when you want.

        • I understood controller keeps sensor state in the database. Node has ability to report sensor state. Which value has higher priority - state in the database or recently reported value from sensor?

        MyController stores all the values on it is database. When node reports a state, it stores on database as recent value.

        1 Reply Last reply Reply Quote 0
        • B Offline
          benya
          last edited by

          If node performs the following actions:

          • boot
          • request current value from controller
          • receive value and change relay state accordingly
          • report current value to the controller
          • smartSleep 1min

          Is it sufficient to change its state from controller?

          jkandasaJ 1 Reply Last reply Reply Quote 0
          • jkandasaJ Offline
            jkandasa @benya
            last edited by

            @benya Yes, it can perform.

            smartSleep 1min

            You have to enable Smart Sleep on node settings in MyController.

            1 Reply Last reply Reply Quote 0
            • B Offline
              benya
              last edited by

              How does node request its own sensor's value from controller?
              Should it call request(uint8_t childSensorId, uint8_t variableType, uint8_t destination)?
              destination should be 0?
              What should be used for childSensorId?
              Is it the same ID used to present this sensor (e.g. childSensorId passed to present() function)?

              jkandasaJ 1 Reply Last reply Reply Quote 0
              • jkandasaJ Offline
                jkandasa @benya
                last edited by

                @benya

                How does node request its own sensor's value from controller?
                Should it call request(uint8_t childSensorId, uint8_t variableType, uint8_t destination)?

                Specifying destination id is not required, when request data from the controller or you can specify it as the gateway address.

                request(uint8_t childSensorId, uint8_t variableType);
                or
                 request(const uint8_t childSensorId, const uint8_t variableType, 0);
                
                1 Reply Last reply Reply Quote 0
                • B Offline
                  benya
                  last edited by

                  What about appropriate value of childSensorId when sensor belongs to the same node that makes request?

                  jkandasaJ 1 Reply Last reply Reply Quote 0
                  • jkandasaJ Offline
                    jkandasa @benya
                    last edited by jkandasa

                    @benya

                    What about appropriate value of childSensorId when sensor belongs to the same node that makes request?

                    In a node, we have a different type of sensors.
                    In a sensor, we have a different type of variables(SensorVariables).

                    Here childId is sensorId and variableType defines which type of variable.

                    Example: I have binary (S_BINARY) sensor with the id 21 and Status and Watts (V_STATUS and V_WATTS) variables. I want to know the current state of my Status variable on MyController. I have to call the following code from my Arduino/MySensors node.

                    request(21, V_STATUS);
                    

                    I will receive the response on,

                    void receive(const MyMessage &message){
                      if (message.sensor == 21 && message.type == V_STATUS) {
                        //Do some actions with, message.getBool();
                      }
                    }
                    
                    1 Reply Last reply Reply Quote 0
                    • B Offline
                      benya
                      last edited by

                      If I have two nodes (#1 and #2) and each has sensor with ID '21' and each node calls request(21, V_STATUS), which sensor values they will get from controller?
                      Node #1 will get his node_1/sensor_21 value and node #2 will get his node_2/sensor_21 value?

                      jkandasaJ 1 Reply Last reply Reply Quote 0
                      • jkandasaJ Offline
                        jkandasa @benya
                        last edited by jkandasa

                        @benya

                        If I have two nodes (#1 and #2) and each has sensor with ID '21' and each node calls request(21, V_STATUS), which sensor values they will get from controller?
                        Node #1 will get his node_1/sensor_21 value and node #2 will get his node_2/sensor_21 value?

                        Yes, You can have any number of nodes with the same sensorId. When MyController receives a request from a node, it knows node Id too. node id will be added on behind the scene when you raise a request.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        1

                        Online

                        587

                        Users

                        529

                        Topics

                        3.4k

                        Posts
                        Copyright © 2015-2025 MyController.org | Contributors | Localization