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. Development
  3. SerialGateway can't send to nodes via rules or Serial Monitor

SerialGateway can't send to nodes via rules or Serial Monitor

Scheduled Pinned Locked Moved Development
18 Posts 3 Posters 3.9k Views 2 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.
  • J Offline
    J Offline
    jgporteous
    wrote on last edited by
    #1

    Hi everyone,
    I have a strange on for you...

    I've setup a Serial Gateway using NRF24l0+ modules.

    When I request ACK for a node/sensor, I can see it's sent.
    0;0;3;0;9;send: 0-0-101-101 s=4,c=0,t=2,pt=0,l=11,sg=0,st=ok:Water Re

    But when I have a rule for example:
    arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n")

    It fails. So I decided to past my command in a serial monitor connected to the gateways' arduino node.
    When I past 101;4;1;0;2;1 it also fails: 0;0;3;0;9;send: 0-0-101-101 s=4,c=1,t=2,pt=0,l=1,sg=0,st=fail:1

    I've traced the code to the function: RF24::write where it fails.

    I've tried enabling FAILURE_HANDLING in the RF24_config file but that doesn't help.

    All other operations are working as expected:

    1. Sensor values sent to gateway
    2. ACK response sent back to node

    Any ideas?

    J

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jgporteous
      wrote on last edited by
      #2

      I tried adding the below code to the gateway in setup() to see if it would send...

      Serial.println("Sending Value for Relay... ON");
      gw.send(msg.setSensor(4).set(1));
      delay(1000);
      Serial.println("Sending Value for Relay... OFF");
      gw.send(msg.setSensor(4).set(1));
      delay(1000);

      and I get this response:

      Sending Value for Relay... ON
      0;0;3;0;9;send: 0-0-0-0 s=4,c=1,t=2,pt=2,l=2,sg=0,st=fail:1
      Sending Value for Relay... OFF
      0;0;3;0;9;send: 0-0-0-0 s=4,c=1,t=2,pt=2,l=2,sg=0,st=fail:1

      Still looking for any ideas on this problem...

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

        Are you sending things from the gateway itself? If so, not supported in 1.5.

        If this is what you want you can use the following branch
        https://github.com/mysensors/Arduino/tree/gateway-refactoring

        The sketch syntax differs a bit, and you have to look in the examples until this has been released.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jgporteous
          wrote on last edited by
          #4

          Thanks Hek, I will have a look at that.

          What is the logic behind not being able to send from the gateway?
          I'm trying to send a value to a node, to turn on a relay.

          The rule fails, and when I try manually send via a serial monitor (or any listed above) it also fails.

          J

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jgporteous
            wrote on last edited by
            #5

            Hi Hek,

            If you look at this: https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/SerialGateway/SerialGateway.ino

            Line 117 to 123 takes a message and sends it. This is what I'm trying to do, so my code is the same already. :)
            I'm just not sure why it's not working.

            J

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

              Ah..

              Sure you don't mean to do a msg.setDestination(4)?

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jgporteous
                wrote on last edited by
                #7

                let me look that up and try :)

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jgporteous
                  wrote on last edited by
                  #8

                  @hek said:

                  msg.setDestination

                  Here is a silly question, do I need on msg variable per sensor on my arduino node - Currently I only have one, and do a msg.preset for each?

                  These are the rules I have (only applicable to this problem):

                  //switch function
                  val org.eclipse.xtext.xbase.lib.Functions$Function4 switchOperation = [
                      org.openhab.core.library.items.SwitchItem relayItem, 
                      org.openhab.core.library.items.StringItem arduinoItem, 
                      String arduinoDevMap,
                      Integer subType|
                      
                      logInfo("Function: switchOperation ","Starting for " + relayItem.name)
                      
                      var Integer state = 0
                      if (relayItem.state != null)
                      {   if (relayItem.state == ON) {
                          state = 1
                      }
                      else {
                          state = 0
                      }
                      
                      logInfo("Function: switchOperation ",arduinoDevMap + "1;1;" + subType + ";" + state )
                      
                      }
                   
                      arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n")
                  ]
                  
                  // Mappings
                  var HashMap<String, String> sensorToItemsMap = newLinkedHashMap(
                      "101;0;"            -> "Balcony_Temperature_Soil"
                      ,"Balcony_Temperature_Soil"       -> "101;0;"
                      ,"101;1;"            -> "Balcony_Temperature_Air"
                      ,"Balcony_Temperature_Air"       -> "101;1;"
                      ,"101;2;"            -> "Balcony_Humidity_Air"
                      ,"Balcony_Humidity_Air"       -> "101;2;"
                      ,"101;3;"            -> "Balcony_Light_Lux"
                      ,"Balcony_Light_Lux"       -> "101;3;"
                      ,"101;4;"            -> "Balcony_Water_Relay"
                      ,"Balcony_Water_Relay"      -> "101;4;"
                  )
                  
                    
                  
                  rule "Balcony_Water_Relay Switch Rule"
                      when
                          Item Balcony_Water_Relay changed
                      then
                      logInfo("Water Relay","Changing state of Water Relay")
                          switchOperation.apply(Balcony_Water_Relay, Arduino, sensorToItemsMap.get("Balcony_Water_Relay"), V_LIGHT)
                          	
                                 
                  end 
                  
                  1 Reply Last reply
                  0
                  • hekH Offline
                    hekH Offline
                    hek
                    Admin
                    wrote on last edited by
                    #9

                    Sorry, I'm not the one to ask for openhab help.

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      jgporteous
                      wrote on last edited by
                      #10

                      Ok, so if I take a step back and exclude OpenHab.

                      Surly I should be able to send data from gateway to a node?
                      I can send from node to gateway, and ACK is returned successfully.

                      So, If I use a serial interface and send a string, like I did above, should that work with API 1.5?

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

                        The api in 1.5 isn't built for attaching sensors on the gateway itself (when it comes to presenting and sending data to the controller). But if you hack around a bit you can do like the Serial gateway example and send out messages from the gateway to nodes in the radio network.

                        In the branch I'm working on now the gateway acts like any other sensor.

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          jgporteous
                          wrote on last edited by
                          #12

                          Hi Hek,

                          I don't want to add a sensor to the gateway, I want to send a command to a node with the sensor.

                          J

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            jgporteous
                            wrote on last edited by
                            #13

                            Hi Everyone,

                            I tried adding the following code to my gateway, to see if it will send the value to the sensor to set it, but it fails with:
                            0;0;3;0;9;send: 0-0-101-101 s=2,c=1,t=2,pt=2,l=2,sg=0,st=fail:1

                            Added to loop():

                              if (!sentSensorValue)
                              {
                            	  delay(2500);
                            	  MyMessage message;
                            	  message.setDestination(101);
                            	  message.setSensor(2);
                            	  message.setType(2);
                            	  message.set(1);
                            
                            	  gw.send(message);
                            	  sentSensorValue = true;
                              }
                            
                            1 Reply Last reply
                            0
                            • rvendrameR Offline
                              rvendrameR Offline
                              rvendrame
                              Hero Member
                              wrote on last edited by
                              #14

                              How are you powering your GW ( arduino and radio)? st=fail:1 usually indicates a problem with power (radio is more sensitive to power noise / fluctuations ).

                              Home Assistant / Vera Plus UI7
                              ESP8266 GW + mySensors 2.3.2
                              Alexa / Google Home

                              1 Reply Last reply
                              0
                              • J Offline
                                J Offline
                                jgporteous
                                wrote on last edited by
                                #15

                                @rvendrame said:

                                ( arduino and radio)

                                Hi,

                                I'm powering the gateway from raspberry pi 2 and has a 10uF Cap.
                                The node is powered from Arduino Nano and has a 22uF Cap.

                                I have tried giving each radio module a separate power supply but that didn't help.

                                What is interesting though, is that the module sends sensor values for 4 sensors and with ACK, the gateway (Arduino) replies successfully. The failure only comes when I try send from parse information from serial input.

                                I think I'm going to try put bigger capacitors on each and see what happens... just not sure how big I can go :)

                                J

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  jgporteous
                                  wrote on last edited by
                                  #16

                                  I upgraded the Cap on the gateway to a 47uF and no change...

                                  This is the serial monitor of the Node, as you can see, it's successfully transmitting data:

                                  
                                  send: 101-101-0-0 s=0,c=0,t=6,pt=0,l=0,sg=0,st=ok:
                                  send: 101-101-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=ok:
                                  send: 101-101-0-0 s=2,c=0,t=7,pt=0,l=0,sg=0,st=ok:
                                  send: 101-101-0-0 s=3,c=0,t=16,pt=0,l=0,sg=0,st=ok:
                                  send: 101-101-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,st=ok:
                                  send: 101-101-0-0 s=4,c=1,t=0,pt=2,l=2,sg=0,st=ok:0
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.73
                                  send: 101-101-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:23.00
                                  send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:39
                                  send: 101-101-0-0 s=3,c=1,t=0,pt=7,l=5,sg=0,st=ok:75
                                  send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:42
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.82
                                  send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:41
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.91
                                  send: 101-101-0-0 s=3,c=1,t=0,pt=7,l=5,sg=0,st=ok:74
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.82
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.91
                                  send: 101-101-0-0 s=3,c=1,t=0,pt=7,l=5,sg=0,st=ok:75
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.82
                                  send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:42
                                  send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:41
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.73
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.64
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.73
                                  send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.64
                                  

                                  This is the serial output of the gateway, where I let it read for a while then send command via serial (101;4;1;0;3;0):

                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.91
                                  101;0;1;0;0;24.91
                                  0;0;3;0;9;read: 101-101-0 s=3,c=1,t=0,pt=7,l=5,sg=0:74
                                  101;3;1;0;0;74
                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.82
                                  101;0;1;0;0;24.82
                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.91
                                  101;0;1;0;0;24.91
                                  0;0;3;0;9;read: 101-101-0 s=3,c=1,t=0,pt=7,l=5,sg=0:75
                                  101;3;1;0;0;75
                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.82
                                  101;0;1;0;0;24.82
                                  0;0;3;0;9;read: 101-101-0 s=2,c=1,t=0,pt=7,l=5,sg=0:42
                                  101;2;1;0;0;42
                                  0;0;3;0;9;read: 101-101-0 s=2,c=1,t=0,pt=7,l=5,sg=0:41
                                  101;2;1;0;0;41
                                  Sending command from serial input...
                                  Destination: 101
                                  Sensor: 4
                                  sensorType: 0
                                  Type: 3
                                  Ack: 0
                                  Payload: 0
                                  0;0;3;0;9;send: 0-0-101-101 s=4,c=1,t=3,pt=4,l=4,sg=0,st=fail:0
                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.73
                                  101;0;1;0;0;24.73
                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.64
                                  101;0;1;0;0;24.64
                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.73
                                  101;0;1;0;0;24.73
                                  0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.64
                                  101;0;1;0;0;24.64
                                  
                                  
                                  1 Reply Last reply
                                  0
                                  • J Offline
                                    J Offline
                                    jgporteous
                                    wrote on last edited by jgporteous
                                    #17

                                    I did another test, I sent all presentation of sensors to request ACK and this below is the output.
                                    Although there is only two fails, I think I'm going to have to setup dedicated power for each and try again... unless there is another way?

                                    Gateway:

                                    0;0;3;0;9;read: 101-101-0 s=255,c=3,t=11,pt=0,l=15,sg=0:Balcony Senso
                                    0;0;3;0;9;send: 0-0-101-101 s=255,c=3,t=11,pt=0,l=15,sg=0,st=fail:Bal
                                    101;255;3;0;11;Balcony Sensors
                                    0;0;3;0;9;read: 101-101-0 s=0,c=0,t=6,pt=0,l=9,sg=0:Soil Temp
                                    0;0;3;0;9;send: 0-0-101-101 s=0,c=0,t=6,pt=0,l=9,sg=0,st=ok:Soil Temp
                                    101;0;0;0;6;Soil Temp
                                    0;0;3;0;9;read: 101-101-0 s=1,c=0,t=6,pt=0,l=8,sg=0:Air Temp
                                    0;0;3;0;9;send: 0-0-101-101 s=1,c=0,t=6,pt=0,l=8,sg=0,st=fail:Air Tem
                                    101;1;0;0;6;Air Temp
                                    0;0;3;0;9;read: 101-101-0 s=2,c=0,t=7,pt=0,l=12,sg=0:Air Humitidy
                                    0;0;3;0;9;send: 0-0-101-101 s=2,c=0,t=7,pt=0,l=12,sg=0,st=fail:Air Hu
                                    101;2;0;0;7;Air Humitidy
                                    0;0;3;0;9;read: 101-101-0 s=4,c=0,t=3,pt=0,l=11,sg=0:Water Relay
                                    0;0;3;0;9;send: 0-0-101-101 s=4,c=0,t=3,pt=0,l=11,sg=0,st=ok:Water Re
                                    101;4;0;0;3;Water Relay
                                    0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.64
                                    101;0;1;0;0;24.64
                                    0;0;3;0;9;read: 101-101-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.00
                                    101;1;1;0;0;23.00
                                    0;0;3;0;9;read: 101-101-0 s=2,c=1,t=0,pt=7,l=5,sg=0:41
                                    101;2;1;0;0;41
                                    0;0;3;0;9;read: 101-101-0 s=3,c=1,t=0,pt=7,l=5,sg=0:76
                                    101;3;1;0;0;76
                                    0;0;3;0;9;read: 101-101-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.56
                                    101;0;1;0;0;24.56
                                    0;0;3;0;9;read: 101-101-0 s=2,c=1,t=0,pt=7,l=5,sg=0:42
                                    101;2;1;0;0;42
                                    

                                    Node:

                                    send: 101-101-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
                                    send: 101-101-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                                    sensor started, id=101, parent=0, distance=1
                                    send: 101-101-0-0 s=255,c=3,t=11,pt=0,l=15,sg=0,st=ok:Balcony Sensors
                                    send: 101-101-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:1.1
                                    send: 101-101-0-0 s=0,c=0,t=6,pt=0,l=9,sg=0,st=ok:Soil Temp
                                    send: 101-101-0-0 s=1,c=0,t=6,pt=0,l=8,sg=0,st=ok:Air Temp
                                    send: 101-101-0-0 s=2,c=0,t=7,pt=0,l=12,sg=0,st=ok:Air Humitidy
                                    send: 101-101-0-0 s=3,c=0,t=16,pt=0,l=11,sg=0,st=fail:Light Level
                                    send: 101-101-0-0 s=4,c=0,t=3,pt=0,l=11,sg=0,st=ok:Water Relay
                                    send: 101-101-0-0 s=4,c=1,t=0,pt=2,l=2,sg=0,st=fail:0
                                    read: 0-0-101 s=0,c=0,t=6,pt=0,l=9,sg=0:Soil Temp
                                    Incoming message: Soil Temp   Sensor: 0
                                    Value:
                                    Soil Temp
                                    send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.64
                                    send: 101-101-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:23.00
                                    send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:41
                                    send: 101-101-0-0 s=3,c=1,t=0,pt=7,l=5,sg=0,st=ok:76
                                    read: 0-0-101 s=4,c=0,t=3,pt=0,l=11,sg=0:Water Relay
                                    Incoming message: Water Relay   Sensor: 4
                                    Value:
                                    Water Relay
                                    send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.56
                                    send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:42
                                    send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.64
                                    send: 101-101-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:24.56
                                    send: 101-101-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=ok:41```
                                    1 Reply Last reply
                                    0
                                    • J Offline
                                      J Offline
                                      jgporteous
                                      wrote on last edited by
                                      #18

                                      @jgporteous said:

                                      101;4;1;0;3;0

                                      Added ACK to one of my senors, node sending values correctly, but ACK failing.

                                      I've bumped up the CAP on the gateway to 330uF and no change :(

                                      I also dropped bandwidth to 250Kbps and power to low, no change either.

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


                                      18

                                      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