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
Ericb2745E

Ericb2745

@Ericb2745
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Trouble sending message to Relay from Openhab
    Ericb2745E Ericb2745

    @CJ-Cassarino Thanks for the reply. I will try your send syntax in my Arduino rules. Also, the reason you don't see the mqtt tag is that I am using a Serial Gateway not a MQTT gateway.

    OpenHAB

  • Trouble sending message to Relay from Openhab
    Ericb2745E Ericb2745

    Simply put I am trying to send a message from Openhab to a MySensors sensor via a Serial Gateway.

    My environment is Openhab 1.7 running on RPi 3. I have a stock Serial Gateway running on Nano using RF24. I have two sensors DHT and micro switch sending data to the gateway and values are appearing in Openhab fine. For about week now I have been trying to turn the communication around. In Openhab I have configured an Switch Item called Relay. When it changes from Off to On I have a rule to send a command to the Arduino gateway item. However the message never shows up on the sensor. Any advice would be appreciated.

    Here is some of the code, config, and logs:

    Relay Sensor:

    #include <EEPROM.h>
    #include <MySigningNone.h>
    #include <MyTransportNRF24.h>
    #include <MyTransportRFM69.h>
    #include <MyHwATMega328.h>
    #include <MySensor.h>
    #include <SPI.h>
    
    #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
    //MyTransportRFM69 radio;
    // Message signing driver (none default)
    //MySigningNone signer;
    // Select AtMega328 hardware profile
    MyHwATMega328 hw;
    // Construct MySensors library
    MySensor gw(radio, hw);
    
    void setup()  
    {   
      //Wipe eprom
      for (int i = 0 ; i < EEPROM.length() ; i++) {
        EEPROM.write(i, 0);
      }
      
      // Initialize library and add callback for incoming messages
      gw.begin(incomingMessage, 105, true);
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Relay", "1.0");
    
      // Fetch relay status
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        gw.present(sensor, S_LIGHT);
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    
    
    void loop() 
    {
      // Alway process incoming messages whenever possible
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      Serial.println("message received");
    
    }
    
    

    arduino items

    String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }
    
    Contact Garage_Door             "Garage Door [MAP(en.map):%s]"          (gGarage, Windows)
    Number Temperature_Basement     "Temperature [%.1f F]"  <temperature>   (Temperature, gBasement)
    Number Humidity_Basement        "Humidity [%.1f %%]"    <temperature>   (gBasement)
    
    Switch Relay          "Relay"  (gBasement)
    

    test.rules

    import org.openhab.core.library.types.*
    
    rule "Send Relay Arduino Command"
    when
            Item Relay changed from OFF to ON
    then
            logInfo("FILE","Entering Rule: Send Relay Arduino Command")
            sendCommand(Arduino, "105;2;1;0;2;1\n")
    
    end
    

    openhab.log during registration

    2016-04-24 11:51:57.728 [INFO ] [org.openhab.model.script.FILE ] - nodeId: 105 childId: 255 msgType: 3 subType: 6 msg: 0
    2016-04-24 11:51:57.841 [INFO ] [org.openhab.model.script.FILE ] - Entering rule Arduino sends to Openhab
    2016-04-24 11:51:58.229 [INFO ] [org.openhab.model.script.FILE ] - Entering rule Arduino sends to Openhab
    2016-04-24 11:51:59.161 [INFO ] [org.openhab.model.script.FILE ] - nodeId: 0 childId: 0 msgType: 3 subType: 9 msg: read: 105-105-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    2016-04-24 11:51:59.454 [INFO ] [org.openhab.model.script.FILE ] - nodeId: 0 childId: 0 msgType: 3 subType: 9 msg: send: 0-0-105-105 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0
    2016-04-24 11:52:00.462 [INFO ] [org.openhab.model.script.FILE ] - nodeId: 105 childId: 255 msgType: 3 subType: 12 msg: 1.0
    

    openhab.log after turning on switch

    2016-04-24 11:49:30 - Relay received command ON
    2016-04-24 11:49:31 - Arduino received command 105;2;1;0;2;1
    2016-04-24 11:49:31 - Arduino state updated to 0;0;3;0;9;send: 0-0-105-105 s=2,c=1,t=2,pt=0,l=1,sg=0,st=fail:1
    

    openhab events.log

    2016-04-24 11:49:31.056 [INFO ] [org.openhab.model.script.FILE ] - Entering Rule: Send Relay Arduino Command
    2016-04-24 11:49:31.522 [INFO ] [org.openhab.model.script.FILE ] - Entering rule Arduino sends to Openhab
    2016-04-24 11:49:31.943 [INFO ] [org.openhab.model.script.FILE ] - Entering rule Arduino sends to Openhab
    2016-04-24 11:49:32.651 [INFO ] [org.openhab.model.script.FILE ] - nodeId: 105 childId: 2 msgType: 1 subType: 2 msg: 1
    
    OpenHAB
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular