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. Controllers
  3. OpenHAB
  4. Sending I_CONFIG to set unit of measure on sensor nodes

Sending I_CONFIG to set unit of measure on sensor nodes

Scheduled Pinned Locked Moved OpenHAB
6 Posts 3 Posters 2.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tango2
    wrote on last edited by
    #1

    I tried asking this on the OpenHAB forums, but I haven't received any feedback. I'm having problems properly sending the I_CONFIG value to my sensors.

    Below is my "Arduino sends to Openhab" rule that I've added the I_CONFIG variable to:

    rule "Arduino sends to Openhab"
    when
    Item Arduino received update
    then
    var String lineBuffer = Arduino.state.toString.split("\n")
    for (String line : lineBuffer) {
    var String[] message = line.split(";")
    var Integer nodeId = new Integer(message.get(0))
    var Integer childId = new Integer(message.get(1))
    var Integer msgType = new Integer(message.get(2))
    var Integer ack = new Integer(message.get(3))
    var Integer subType = new Integer(message.get(4))
    var String msg = message.get(5)
    if(msgType == 1 ){
    if (subType == V_TEMP){ 
    postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
    println ("Temp item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " temp: " + msg )
    }
    if (subType == V_HUM){
    postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
    println ("Hum item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " hum: " + msg )
    }
    }
    if(msgType == 3){
    if(subType == I_BATTERY_LEVEL){
    postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
    println ("Battery level received: " + msg)
    }
    if(subType == I_CONFIG){
    println("Request config units") 
    sendCommand(Arduino, nodeId + ";" + childId + ";" + msgType + ";" + ack + ";" + subType + ";" + core_Units.state + "\n")
    println("Sent measurement units:" + core_Units.state )
    }
    if(subType == I_SKETCH_NAME){
    println("Sketch name: " + msg )
    sketchName=msg
    }
    if(subType == I_SKETCH_VERSION){
    println("Sketch version: " + msg )
    postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), sketchName+" " +msg )
    sketchName=""
    }
    }
    }
    
    end
    

    In it's current state, the sensor node gets repeated responses from the controller/gateway with the units (I or M), based on the value of the item Core_Units.state. I'm trying to figure out why this doesn't just sendCommand one time to the sensor node. The response received by the sensor node seems correct, I just get hundreds of them. Below is the output from my sensor node after requesting the I_CONFIG value from the controller:

    read: 0-0-105 s=255,c=3,t=6,pt=0,l=1,sg=0:I
    

    This appears correct to me. Any thoughts?

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

      Yes, it should be picked up here:

      https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/MySensor.cpp#L711-L716

      You could add some debug print in the node to verify that this is the case perhaps.

      The node should normally only ask once when the node starts up:
      https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/MySensor.cpp#L282

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tango2
        wrote on last edited by
        #3

        It seems as if the problem I'm seeing is more with the controller/gateway than with the node. The gateway is sending out the I_CONFIG units repeatedly (like hundreds of times). The node is only requesting the units once.

        That is why I'm not sure if it is a gateway problem or a controller (rules) problem. I can comment out the following section:

        if(subType == I_CONFIG){
        println("Request config units") 
        sendCommand(Arduino, nodeId + ";" + childId + ";" + msgType + ";" + ack + ";" + subType + ";" + core_Units.state + "\n")
        println("Sent measurement units:" + core_Units.state )
        }
        

        and the sensor node is no longer flooded with responses after it asks for config units. I'm just not sure why this is "flooding" the sensor node with responses.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TimO
          Hero Member
          wrote on last edited by
          #4

          I suppose the rules are triggered, whenever there is a message coming from the gateway or from a sendCommand () call. So this will result in an infinite loop.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tango2
            wrote on last edited by Tango2
            #5

            Eventually, the repeated requests seem to calm down and it works as expected. What I'm trying to figure out is why the repeated messages occur.

            If I'm reading the code correctly, the only time the 'if(subType == I_CONFIG)' should be invoked is when the request for config units is made from the sensor node. I've confirmed that the sensor node only requests the I_CONFIG units once, and the gateway only receives it once. I can't seem to make sense out of why the gateway replies so many times...

            1 Reply Last reply
            0
            • T Offline
              T Offline
              TimO
              Hero Member
              wrote on last edited by
              #6

              If you only comment out the line with "sendCommand()" how often does is the rule triggered? My guess: only once.
              You need to distinguish if you're getting a request from the node or sending an answer.

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


              31

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


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