Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Radi-M
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Radi-M

    @Radi-M

    0
    Reputation
    3
    Posts
    14
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Radi-M Follow

    Best posts made by Radi-M

    This user hasn't posted anything yet.

    Latest posts made by Radi-M

    • RE: !MCO:PRO:RC=1

      Hi,

      The strange behavior is no longer present and I can't replicate the problem. I suspect there was a general communication problem with the gateway.
      Anyway, please see the following debug prints.

       
       __  __       ____
      |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
      | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
      | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
      |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
              |___/                      2.3.2
      
      16 MCO:BGN:INIT NODE,CP=RNNNA-Q-,FQ=16,REL=255,VER=2.3.2
      26 TSM:INIT
      28 TSF:WUR:MS=0
      34 TSM:INIT:TSP OK
      36 TSF:SID:OK,ID=1
      38 TSM:FPAR
      41 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      247 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      252 TSF:MSG:FPAR OK,ID=0,D=1
      2050 TSM:FPAR:OK
      2051 TSM:ID
      2052 TSM:ID:OK
      2054 TSM:UPL
      2057 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      2068 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      2073 TSF:MSG:PONG RECV,HP=1
      2075 TSM:UPL:OK
      2077 TSM:READY:ID=1,PAR=0,DIS=1
      2081 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2100 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2110 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
      2118 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      2179 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2186 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=18,sg=0,ft=0,st=OK:Stairs Wall Lights
      2198 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.2
      2209 TSF:MSG:SEND,1-1-0-0,s=0,c=0,t=4,pt=0,l=10,sg=0,ft=0,st=OK:Top_Lights
      2318 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=4,pt=0,l=13,sg=0,ft=0,st=OK:Bottom_Lights
      2427 TSF:MSG:SEND,1-1-0-0,s=2,c=0,t=3,pt=0,l=17,sg=0,ft=0,st=OK:Top_Lights_Switch
      2537 TSF:MSG:SEND,1-1-0-0,s=3,c=0,t=3,pt=0,l=20,sg=0,ft=0,st=OK:Bottom_Lights_Switch
      2648 TSF:MSG:SEND,1-1-0-0,s=4,c=0,t=23,pt=0,l=23,sg=0,ft=0,st=OK:Top_Lights_Switch_Level
      2758 TSF:MSG:SEND,1-1-0-0,s=5,c=0,t=23,pt=0,l=25,sg=0,ft=0,st=OK:Bottom_Lights_Switch_Leve
      2866 MCO:REG:REQ
      2871 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      2877 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2882 MCO:PIM:NODE REG=1
      2884 MCO:BGN:STP
      Setup Started.
      2888 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
      2995 TSF:MSG:SEND,1-1-0-0,s=3,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
      Top Switch level: 100
      3103 TSF:MSG:SEND,1-1-0-0,s=4,c=1,t=24,pt=1,l=1,sg=0,ft=0,st=OK:100
      Bottom Switch level: 100
      3211 TSF:MSG:SEND,1-1-0-0,s=5,c=1,t=24,pt=1,l=1,sg=0,ft=0,st=OK:100
      3318 TSF:MSG:SEND,1-1-0-0,s=0,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      3364 TSF:MSG:READ,0-0-1,s=0,c=1,t=3,pt=0,l=1,sg=0:0
      V_Dimmer received: 0
      Fade to Level: 0:0-->0
      3425 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      3469 TSF:MSG:READ,0-0-1,s=1,c=1,t=3,pt=0,l=1,sg=0:0
      V_Dimmer received: 1
      Fade to Level: 1:0-->0
      Setup Colplete.
      3531 MCO:BGN:INIT OK,TSP=1
      Switch 1 pressed.
      11350 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1
      Fade to Level: 0:0-->100
      Sensor Update received: 0
      12360 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1
      12466 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=3,pt=1,l=1,sg=0,ft=0,st=OK:100
      Switch 1 pressed.
      14713 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
      Fade to Level: 0:100-->0
      Sensor Update received: 0
      15726 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
      15832 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=3,pt=1,l=1,sg=0,ft=0,st=OK:0
      
      

      Thanks

      posted in Troubleshooting
      Radi-M
      Radi-M
    • RE: !MCO:PRO:RC=1

      Hi mfalkvidd,

      Thank you for the prompt response.

      The code is the following:

      //#define MY_DEBUG   
      
      #define MY_RADIO_NRF24
      #define MY_RX_MESSAGE_BUFFER_FEATURE
      #define MY_RF24_IRQ_PIN 2
      #include <MySensors.h>
      #include <Bounce2.h>
      #include <elapsedMillis.h>
      
      #define SN "Stairs Wall Lights"
      #define SV "1.2"
      
      #define TopLED_ID 0
      #define BottomLED_ID 1
      #define TopSwitch_ID 2
      #define BottomSwitch_ID 3
      #define TopSwitchLev_ID 4
      #define BotSwitchLev_ID 5
      
      #define TopLED_PIN 3   
      #define BottomLED_PIN 5
      #define TopSwitch_PIN A3  // External switch 1
      #define BottomSwitch_PIN A4  // External switch 2
      #define FADE_DELAY 10  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
      #define Light_On 100
      #define Light_Off 0
      #define HEARTBEAT_TIME 605000 // 10 minutes
      #define HEARTBEAT_NO_RETURN 3
      
      uint8_t CurrentLevel[2];  // Current dim level...
      bool LastState[2];
      byte updateSensor;
      
      MyMessage TopDimmerMsg(TopLED_ID, V_DIMMER);
      MyMessage TopLightMsg(TopLED_ID, V_LIGHT);
      MyMessage BotDimmerMsg(BottomLED_ID, V_DIMMER);
      MyMessage BotLightMsg(BottomLED_ID, V_LIGHT);
      MyMessage TopSwitchMsg(TopSwitch_ID, V_STATUS);
      MyMessage BotSwitchMsg(BottomSwitch_ID, V_STATUS);
      MyMessage TopSwitchLevMsg(TopSwitchLev_ID, V_VAR1);
      MyMessage BotSwitchLevMsg(BotSwitchLev_ID, V_VAR1);
      
      elapsedMillis heartBeatTimer; 
      byte heartBeatReturn;
      Bounce debouncer1 = Bounce(); 
      Bounce debouncer2 = Bounce();
      
      void(* resetFunc) (void) = 0; //declare reset function @ address 0
      
      void setup()
      {
      #ifdef MY_DEBUG
        Serial.begin(115200);
        Serial.println("Setup Started.");
      #endif  
        pinMode(TopSwitch_PIN, INPUT_PULLUP);
        pinMode(BottomSwitch_PIN, INPUT_PULLUP);
        LastState[TopLED_ID] = digitalRead(TopSwitch_PIN);
        LastState[BottomLED_ID] =  digitalRead(BottomSwitch_PIN);
        // switch off lights
        analogWrite(TopLED_PIN, 0); CurrentLevel[TopLED_ID] = 0; 
        analogWrite(BottomLED_PIN, 0); CurrentLevel[BottomLED_ID] = 0;
      
        send(TopSwitchMsg.set(LastState[TopLED_ID])); wait(100);
        send(BotSwitchMsg.set(LastState[BottomLED_ID])); wait(100);
        byte b = loadState(TopSwitchLev_ID);
      #ifdef MY_DEBUG
        Serial.print("Top Switch level: ");
        Serial.println(b);
      #endif  
        if (b == Light_Off) {b = Light_On; saveState(TopSwitchLev_ID, Light_On);}
        send(TopSwitchLevMsg.set(b)); wait(100);
        b = loadState(BotSwitchLev_ID);
      #ifdef MY_DEBUG
        Serial.print("Bottom Switch level: ");
        Serial.println(b);
      #endif  
        if (b == Light_Off) {b = Light_On; saveState(BotSwitchLev_ID, b);}
        send(BotSwitchLevMsg.set(b)); wait(100);
      
        debouncer1.attach(TopSwitch_PIN);
        debouncer1.interval(5);
        debouncer2.attach(BottomSwitch_PIN);
        debouncer2.interval(5);
        heartBeatTimer = 0;
        heartBeatReturn = 0;
        updateSensor = 255;
        request(TopLED_ID, V_DIMMER); wait(100);
        request(BottomLED_ID, V_DIMMER); wait(100);
      #ifdef MY_DEBUG
        Serial.println("Setup Colplete.");
      #endif  
      }
      
      void presentation()
      {
        sendSketchInfo(SN, SV);
        present(TopLED_ID, S_DIMMER, "Top_Lights"); wait(100);
        present(BottomLED_ID, S_DIMMER, "Bottom_Lights"); wait(100);
        present(TopSwitch_ID, S_BINARY, "Top_Lights_Switch");  wait(100);
        present(BottomSwitch_ID, S_BINARY, "Bottom_Lights_Switch");  wait(100);
        present(TopSwitchLev_ID, S_CUSTOM, "Top_Lights_Switch_Level");  wait(100);
        present(BotSwitchLev_ID, S_CUSTOM, "Bottom_Lights_Switch_Level");  wait(100);
      }
      
      void loop()
      {
        debouncer1.update();
        bool CurrentState = debouncer1.read();
        if (CurrentState != LastState[TopLED_ID]) {
          #ifdef MY_DEBUG
            Serial.println("Switch 1 pressed.");
          #endif  
          send(TopSwitchMsg.set(CurrentState));
          LastState[TopLED_ID] = CurrentState;
          if (CurrentLevel[TopLED_ID] > Light_Off) {
            fadeToLevel(Light_Off, TopLED_ID);
          }
          else {
            byte b = loadState(TopSwitchLev_ID);  
            fadeToLevel(b, TopLED_ID);
          }
        }
        debouncer2.update();
        CurrentState = debouncer2.read();
        if (CurrentState != LastState[BottomLED_ID]) {
          #ifdef MY_DEBUG
            Serial.println("Switch 2 pressed.");
          #endif  
          send(BotSwitchMsg.set(CurrentState));
          LastState[BottomLED_ID] = CurrentState; 
          if (CurrentLevel[BottomLED_ID] > 0) {
            fadeToLevel(Light_Off, BottomLED_ID);
          }
          else {
            byte b = loadState(BotSwitchLev_ID);  
            fadeToLevel(b, BottomLED_ID);
          }
        }
        if (heartBeatTimer > HEARTBEAT_TIME) {
          heartBeatTimer = 0;
          if (!sendHeartbeat()) {
              #ifdef MY_DEBUG
                Serial.println("Hearbeat echo NOT received.");
              #endif  
            heartBeatReturn++;
            if (heartBeatReturn == HEARTBEAT_NO_RETURN) resetFunc();
          } else {
              #ifdef MY_DEBUG
                Serial.println("Hearbeat echo received.");
              #endif  
              heartBeatReturn = 0;
              request(TopLED_ID, V_DIMMER); wait(200);
              request(BottomLED_ID, V_DIMMER); wait(200);
          }
        }
        if (updateSensor != 255) {
          #ifdef MY_DEBUG
            Serial.print("Sensor Update received: ");
            Serial.println(updateSensor);
          #endif  
          if (updateSensor == TopLED_ID) {
            send(TopLightMsg.set(CurrentLevel[updateSensor] > 0));wait(100);
            send(TopDimmerMsg.set(CurrentLevel[updateSensor])); 
          }
          else if (updateSensor == BottomLED_ID){
            send(BotLightMsg.set(CurrentLevel[updateSensor] > 0));wait(100);
            send(BotDimmerMsg.set(CurrentLevel[updateSensor]));       
          }
          updateSensor = 255;
        }
      }
      
      void receive(const MyMessage &message)
      {
      	if (message.type == V_LIGHT) {
          bool requestedLevel = message.getBool();
          #ifdef MY_DEBUG
            Serial.print("V_Light received: ");
            Serial.println(message.sensor);
          #endif  
          int lvl;
          if (requestedLevel == LOW) lvl = Light_Off; else lvl = Light_On;
      		fadeToLevel(lvl, message.sensor);
      	 }
        else if (message.type == V_DIMMER) {
          #ifdef MY_DEBUG
            Serial.print("V_Dimmer received: ");
            Serial.println(message.sensor);
          #endif  
          int requestedLevel = message.getInt();
          fadeToLevel(requestedLevel, message.sensor);
        }
        else if (message.type == V_VAR1) {
          #ifdef MY_DEBUG
            Serial.print("V_VAR1 received: ");
            Serial.println(message.sensor);
          #endif  
          byte b = message.getByte();
          if (b > Light_On) b = Light_On;
          if (message.sensor == TopSwitchLev_ID) {
            saveState(TopSwitchLev_ID, b);
          }
          else if (message.sensor == BotSwitchLev_ID) {
            saveState(BotSwitchLev_ID, b);
          }
        }
      }
      
      void fadeToLevel(int toLevel, byte SensorID)
      {
        #ifdef MY_DEBUG
          Serial.print("Fade to Level: ");
          Serial.print(SensorID);
          Serial.print(":");
          Serial.print(CurrentLevel[SensorID]);
          Serial.print("-->");
          Serial.println(toLevel);
        #endif  
        byte SensorPIN; 
        if (SensorID == TopLED_ID) SensorPIN = TopLED_PIN; 
        else if (SensorID == BottomLED_ID) SensorPIN = BottomLED_PIN;
        int delta = (toLevel - CurrentLevel[SensorID]) < 0 ? -1 : 1;
        if (CurrentLevel[SensorID] != toLevel) {
          updateSensor = SensorID;
          while (CurrentLevel[SensorID] != toLevel) {
            CurrentLevel[SensorID] += delta;
            analogWrite(SensorPIN, (int)(CurrentLevel[SensorID] / 100. * 255));
      //      delay(FADE_DELAY);
            wait(FADE_DELAY);
          }
        }
      }
      

      There is no send() inside receive().

      Any ideas?

      posted in Troubleshooting
      Radi-M
      Radi-M
    • RE: !MCO:PRO:RC=1

      Hi all,

      I've got the same message when call wait(xx);

      while (CurrentLevel[SensorID] != toLevel) {
      	CurrentLevel[SensorID] += delta;
      	analogWrite(SensorPIN, (int)(CurrentLevel[SensorID] / 100. * 255));
      //    delay(FADE_DELAY);
      	wait(FADE_DELAY);
      
      23902 TSF:MSG:READ,0-0-1,s=0,c=1,t=3,pt=0,l=1,sg=0:5
      23907 !MCO:PRO:RC=1
      23909 !MCO:PRO:RC=1
      23911 !MCO:PRO:RC=1
      23913 !MCO:PRO:RC=1
      23915 !MCO:PRO:RC=1
      23916 !MCO:PRO:RC=1
      23918 !MCO:PRO:RC=1
      23920 !MCO:PRO:RC=1
      23922 !MCO:PRO:RC=1
      23924 !MCO:PRO:RC=1
      23926 !MCO:PRO:RC=1
      23928 !MCO:PRO:RC=1
      23930 !MCO:PRO:RC=1
      23931 !MCO:PRO:RC=1
      23933 !MCO:PRO:RC=1
      23936 !MCO:PRO:RC=1
      23938 !MCO:PRO:RC=1
      23940 !MCO:PRO:RC=1
      23942 !MCO:PRO:RC=1
      23944 !MCO:PRO:RC=1
      23946 !MCO:PRO:RC=1
      23948 !MCO:PRO:RC=1
      23949 !MCO:PRO:RC=1
      23951 !MCO:PRO:RC=1
      23953 !MCO:PRO:RC=1
      23955 !MCO:PRO:RC=1
      23957 !MCO:PRO:RC=1
      
      

      When I replace wait with delay the message doesn't appear.

      Why is that?

      Regards,
      Radi

      posted in Troubleshooting
      Radi-M
      Radi-M