[SOLVED (but can somebody explain why)]Not getting any incoming messages...



  • Hi all

    I am trying to make a controller for my blinds using a 2 channel relay. I am using MySensors 1.5 and arduino 1.6.5b as dev env.

    I am using the following sketch

    #include <MySensor.h>
    #include <SPI.h>
    
    #define UP_PIN  3 
    #define DOWN_PIN  4
    #define CHILD_ID 250 
    
    MySensor gw;
    void setup()  
    {   
      gw.begin(incomingMessage, AUTO, false);
      gw.sendSketchInfo("Blinds", "1.0");
      gw.present(CHILD_ID, S_COVER,"Blinds",true);
      pinMode(UP_PIN, OUTPUT);   
      pinMode(DOWN_PIN, OUTPUT);   
      digitalWrite(UP_PIN, 0);
      digitalWrite(DOWN_PIN, 0);
      Serial.println( "Node ready to receive messages..." );
    }
    
    void loop() 
    {
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      Serial.println(message.data);
      if (message.type==V_UP) {
         digitalWrite(UP_PIN,1);
         gw.sleep(15000);
         digitalWrite(UP_PIN,0);
         Serial.println("opening up covers");
       } 
       else if (message.type==V_DOWN) {
         digitalWrite(DOWN_PIN,1);
         gw.sleep(15000);
         digitalWrite(DOWN_PIN,0);
         Serial.println("closing up covers");
       } 
       else if (message.type==V_STOP) {
         digitalWrite(UP_PIN,0);
         digitalWrite(DOWN_PIN,0);
         Serial.println("stopping covers");
       }
    }
    
    

    In the gateway I get

    0;0;3;0;9;read: 250-250-0 s=255,c=0,t=17,pt=0,l=3,sg=0:1.5
    250;255;0;0;17;1.5
    0;0;3;0;9;read: 250-250-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    250;255;3;0;6;0
    0;0;3;0;9;read: 250-250-0 s=255,c=3,t=11,pt=0,l=6,sg=0:Blinds
    250;255;3;0;11;Blinds
    0;0;3;0;9;read: 250-250-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    250;255;3;0;12;1.0
    0;0;3;0;9;read: 250-250-0 s=250,c=0,t=5,pt=0,l=6,sg=0:Blinds
    0;0;3;0;9;send: 0-0-250-250 s=250,c=0,t=5,pt=0,l=6,sg=0,st=ok:Blinds
    
    250;250;0;0;5;Blinds
    

    I can see the blinds coming up in Domoticz and I can even send data to it (vtype 30,29 and 31) yet nothing is receiving the incoming message (The controller is still connected to my laptop so I can monitor them)

    Any clues why this goes wrong?

    Kind regards

    Steve


  • Admin

    How does the node log look like?



  • Hek I just updated the first post a bit (had some issues there I noticed)

    this is the node log

    send: 250-250-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
    send: 250-250-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    sensor started, id=250, parent=0, distance=1
    send: 250-250-0-0 s=255,c=3,t=11,pt=0,l=6,sg=0,st=ok:Blinds
    send: 250-250-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 250-250-0-0 s=250,c=0,t=5,pt=0,l=6,sg=0,st=ok:Blinds
    Node ready to receive messages...
    read: 0-0-250 s=250,c=0,t=5,pt=0,l=6,sg=0:Blinds
    Blinds

    UPDATE: I am a bit further. I can now send one command to the sensor, yet after that it fails. The relay will be enable, but another command fails.

    0;0;3;0;9;send: 0-0-250-250 s=10,c=1,t=30,pt=0,l=0,sg=0,st=ok:
    0;0;3;0;9;read: 1-3-0 s=0,c=1,t=0.0
    0;0;3;0;9;send: 0-0-250-250 s=10,c=1,t=29,pt=0,l=0,sg=0,st=fail:
    

    As you can see the V_CLOSE works, but the next command fails when I use gw.sleep. When I reset the sensor or use gw.wait they work again.

    I copied the latest sketch below

    #include <MySensor.h>
    #include <SPI.h>
    
    #define UP_PIN  3 
    #define DOWN_PIN  4
    #define CHILD_ID 250 
    
    MySensor gw;
    void setup()  
    {   
      gw.begin(incomingMessage, AUTO, false);
      gw.sendSketchInfo("Blinds", "1.0");
      gw.present(CHILD_ID, S_COVER,"Blinds",true);
      pinMode(UP_PIN, OUTPUT);   
      pinMode(DOWN_PIN, OUTPUT);   
      digitalWrite(UP_PIN, 0);
      digitalWrite(DOWN_PIN, 0);
      Serial.println( "Node ready to receive messages..." );
    }
    
    void loop() 
    {
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      Serial.println(message.data);
      if (message.type==V_UP) {
        Serial.println("opening up covers");
         digitalWrite(UP_PIN,1);
         gw.wait(15000);
         digitalWrite(UP_PIN,0);
       } 
       else if (message.type==V_DOWN) {
         Serial.println("closing up covers");
         digitalWrite(DOWN_PIN,1);
         gw.wait(15000);
         digitalWrite(DOWN_PIN,0);
       } 
       else if (message.type==V_STOP) {
         Serial.println("stopping covers");
         digitalWrite(UP_PIN,0);
         digitalWrite(DOWN_PIN,0);
       }
    }
    

  • Admin

    You are taking out too much power from the Arduino. Power relays separately.



  • Hey Hek,

    there is currently nothing connected to them. How come the wait works but the sleep doesn't? Does it mean it does no longer wake up?

    Kind regards



  • @Steve-Caster how many time do you have between the V_DOWN and V_UP. Is it lower than 15s ?



  • Hi, I am waiting for the relay to stop and next try to use V_UP or V_DOWN. When I use gw.wait, it works fine and I can interrupt the motion by using V_STOP.



  • @Steve-Caster so is everything good or do you have another question/issue ?



  • @fets I am good :) Thank for the support :)


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.