• header.categories
    • header.recent
    • header.tags
    • header.popular
    • register
    • login

    Sensor state

    scheduled pinned locked moved General Discussion
    10 posts 2 posters 4.3k views 1 watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • B offline
      benya
      global: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 one-reply-to-this-post last-reply-time reply quote 0
      • jkandasaJ offline
        jkandasa @benya
        global: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.

        one-reply-to-this-post last-reply-time reply quote 0
        • B offline
          benya
          global: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 one-reply-to-this-post last-reply-time reply quote 0
          • jkandasaJ offline
            jkandasa @benya
            global:last-edited-by,

            @benya Yes, it can perform.

            smartSleep 1min

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

            one-reply-to-this-post last-reply-time reply quote 0
            • B offline
              benya
              global: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 one-reply-to-this-post last-reply-time reply quote 0
              • jkandasaJ offline
                jkandasa @benya
                global: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);
                
                one-reply-to-this-post last-reply-time reply quote 0
                • B offline
                  benya
                  global:last-edited-by,

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

                  jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
                  • jkandasaJ offline
                    jkandasa @benya
                    global: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();
                      }
                    }
                    
                    one-reply-to-this-post last-reply-time reply quote 0
                    • B offline
                      benya
                      global: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 one-reply-to-this-post last-reply-time reply quote 0
                      • jkandasaJ offline
                        jkandasa @benya
                        global: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.

                        one-reply-to-this-post last-reply-time reply quote 0
                        • first-post
                          last-post

                        0

                        online

                        644

                        users

                        532

                        topics

                        3.4k

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