Announcement

Collapse
No announcement yet.

Hs3 arduino plugin Api input long process time problem ? Big delay

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hs3 arduino plugin Api input long process time problem ? Big delay

    Hello .
    I m trying arduino plugin on hs3 (win 10)
    The arduino mega board get canbus messages and push 3 unsigned long to homeseer by the plugin API (sendToHS) each 60 seconds
    at first everything works perfectly and the devices are updated normally in Hs
    but after several hours there is a growing delay between data send by the arduino and updates in homeseer
    nov.-05 16:26:46 Board 1, Device Ref = 1921, API Input 3, Value = 151447, String = 151447
    at the moment. at 16:26 the plugin updates the homeseer devices with the data of 15:14
    there is more than an hour late and it increases with time
    The rtc time is send by the arduino 151447 = 15h14 47sec
    And the processing time by homeseer / arduino plugin = 16:26:46
    Can you help me please ?
    Thank you
    Best regards, Stephane
    Last edited by Aqua-Passion; November 5, 2017, 10:47 AM.

    #2
    I would need to see the API code to work out your problem. If you don't want to post it then email it to me by clicking on my name in the config page.

    Sent from my SM-G950F using Tapatalk
    Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
    X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
    Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
    Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
    Scripts =
    Various

    Comment


      #3
      Thank you
      This is the API code
      Code:
      /*************************************************************
       *Arduino to Homeseer 3 Plugin API written by Enigma Theatre.*
       * V1.0.0.140                                                *
       *                                                           *
       *************************************************************/
      int FromHS[50];                                              
      boolean IsConnected = false;                                 
      //************************************************************
      
      
      //**************Declare your variables here******************* 
      
      // CAN Receive
      //
      #include <mcp_can.h>
      #include <SPI.h>
      
      //for refresh HS send
      #define REFRESH_TIME 60000
      unsigned int currentRefreshTime = 0;
      unsigned long Refresh_StartMillis;
      
      volatile long unsigned int rxId;
      volatile unsigned char len = 0;
      volatile unsigned char rxBuf[8];
      volatile char msgString[128];                        // Array to store serial string
      volatile unsigned long waterCount;                        //Water count from CAN
      volatile unsigned long dayWaterCount;                        //day water count from CAN
      volatile unsigned long rtcHour;                        //Rtc Hour from CAN
      
      #define CAN0_INT 2                              // Set INT to pin 2
      MCP_CAN CAN0(10);                               // Set CS to pin 10
      
      
      //****************************************************************
      
      void HSSetup() {
        
        //************************
        //Add YOUR SETUP HERE;
        //************************
        
        // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
        CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ);  
        CAN0.setMode(MCP_NORMAL);                     // Set operation mode to normal so the MCP2515 sends acks to received data.
        pinMode(CAN0_INT, INPUT);                            // Configuring pin for /INT input
      
      }
      
      
      void HSloop() {
                     
          //************************
          //Add YOUR CODE HERE;
          //************************
          /* To Send Data to Homeseer use SendToHS(Device,Value)
           Eg.. SendToHS(1,200); where 1 is the API device in homeseer and 200 is the value to send
           To Recieve data from Homeseer look up the FromHS array that is updated when the device value changes.
           Eg.. FromHS[5] would be the data from API Output device 5
           All code that is located just below this block will execute regardless of connection status!
           You can include SendToHS() calls, however when there isn't an active connection, it will just return and continue.
           If you only want code to execute when HomeSeer is connected, put it inside the if statement below.
           */
      
          /*Execute regardless of connection status*/
      
          if(!digitalRead(CAN0_INT))                         // If CAN0_INT pin is low, read receive buffer
          {
            CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)
                
          
            if((rxId & 0x40000000) == 0x40000000){    // Determine if message is a remote request frame.
              //REMOTE REQUEST FRAME
            } else {
              if(rxId == 0x004){
                  //Hour from RTC CAN BUS
                  String thisHour = String(rxBuf[4])+String(rxBuf[5])+String(rxBuf[6]);
                  rtcHour = thisHour.toInt();
                 
                }else if(rxId == 0x002) {
                  //count and Day count CAN BUS
                  long bufcan[8];
                  bufcan[0] = (byte)rxBuf[0];
                  bufcan[1] = (byte)rxBuf[1];
                  bufcan[2] = (byte)rxBuf[2];
                  bufcan[3] = (byte)rxBuf[3];
                  bufcan[4] = (byte)rxBuf[4];
                  bufcan[5] = (byte)rxBuf[5];
                  bufcan[6] = (byte)rxBuf[6];
                  bufcan[7] = (byte)rxBuf[7];
                  waterCount = ((bufcan[3] << 24) | (bufcan[2] << 16) | (bufcan[1] << 8) | bufcan[0]);
                  dayWaterCount = ((bufcan[7] << 24) | (bufcan[6] << 16) | (bufcan[5] << 8) | bufcan[4]);
                }
            }
        }
      
      
       if (IsConnected == true) {
         /*Execute ONLY when HomeSeer is connected*/
         currentRefreshTime = millis() - Refresh_StartMillis;   
          if(currentRefreshTime > REFRESH_TIME){
            Refresh_StartMillis = millis();
            currentRefreshTime = 0;     
            SendToHS(1,(long)waterCount);
            SendToHS(2,(long)dayWaterCount);
            SendToHS(3,(long)rtcHour);
          }
        }
      }
      
      //************Do not change anything after Here*****************
      
      .... defaut api
      Last edited by Aqua-Passion; November 5, 2017, 06:54 PM.

      Comment


        #4
        code edited / cleaned in my previous post
        I removed unnecessary items
        the installation is :
        [Arduino UNO counter with rtc clock]---------CANBUS------[Arduino Mega with API]----SERIAL COM PORT---[HS3 + Arduino plugin on win 10]
        "Arduino counter" send the 3 canbus values each 30 seconds
        "Arduino Mega with API" send the values to HS plugin each 60 seconds
        for now it's good, plugin just restarted
        HS logs:
        nov.-05 19:31:00 Arduino Plugin Board 1, Device Ref = 1921, API Input 3, Value = 193159, String = 193159
        HS log hour (19:31) = hour received from the arduino (193159) => 19:31:59 just 59 seconds off but I'm not paying attention because the rtc clock is not set to the second
        I post the evolution in a few hours
        Last edited by Aqua-Passion; November 5, 2017, 01:51 PM.

        Comment


          #5
          after about 30 minutes
          HS logs:
          nov.-05 20:00:33 Arduino Plugin Board 1, Device Ref = 1921, API Input 3, Value = 195414, String = 195414
          HS log hour (20:00)
          hour received from the arduino (195414) => 19:54:14
          already 6 minutes late in the reception after a half hour
          it looks like the messages are put on hold between the arduino and homeseer
          counter values sent too, it looks like it's sent in order but late
          how much can we normally expect to process values updates per minute with the plugin?
          1 time 3 values per minute does not seem huge.
          could this cause queuing in homeseer?

          Comment


            #6
            Can you post a debug of this running for 5 min or so so I can trace what is happening.

            Greig.
            Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
            X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
            Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
            Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
            Scripts =
            Various

            Comment


              #7
              Edit , log removed problem solved , see post #12
              thanks for your help
              Last edited by Aqua-Passion; November 5, 2017, 06:52 PM.

              Comment


                #8
                I wander if the device time is not updating because the value is not changing. Have you unchecked the "Do not update device last change time
                if device value does not change:" tick box on the device config page?

                Greig.
                Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
                X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
                Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
                Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
                Scripts =
                Various

                Comment


                  #9
                  HS log:
                  nov.-05 21:24:07 Arduino Plugin Board 1, Device Ref = 1921, API Input 3, Value = 205913, String = 205913
                  at 21:24 => 20:59:13 : 35 minutes late after 2 hours running

                  Edit , log removed problem solved , see post #12
                  Last edited by Aqua-Passion; November 5, 2017, 06:51 PM.

                  Comment


                    #10
                    Originally posted by enigmatheatre View Post
                    I wander if the device time is not updating because the value is not changing. Have you unchecked the "Do not update device last change time
                    if device value does not change:" tick box on the device config page?

                    Greig.
                    no , I just uncheck them an restart the plugin for testing

                    Comment


                      #11
                      on the post above are the logs of the debug file of the plugin arduino
                      we can also see the problem of lagging dates
                      I wonder
                      this debug file is written by the plugin before treatment by homeseer or written by homeseer after treatment?
                      it is to know if the problem arises between the arduino and the plugin or between the plugin and homeseer

                      Comment


                        #12
                        maybe i have found the problem
                        i think the plugin i satured because API here send value at each loop
                        60 sec timer don't work maybe because in interrupt
                        added volatile to timer variable have solved this problem
                        Code:
                        //for refresh HS send
                        #define REFRESH_TIME 60000
                        volatile unsigned int currentRefreshTime = 0;
                        volatile unsigned long Refresh_StartMillis;
                        after this , I see each loop with SendToHS did not work very well
                        the values are well sent every minute but the plugin took only one or two out of the three
                        I solved for the moment this problem by adding a delay between each
                        Code:
                         if (IsConnected == true) {
                           /*Execute ONLY when HomeSeer is connected*/
                           currentRefreshTime = millis() - Refresh_StartMillis;   
                            if(currentRefreshTime > REFRESH_TIME){
                              Refresh_StartMillis = millis();
                              currentRefreshTime = 0;     
                              SendToHS(1,(long)waterCount);
                              delay(100);
                              SendToHS(2,(long)dayWaterCount);
                              delay(100);
                              SendToHS(3,(long)rtcHour);
                            }
                          }
                        restarting plugin everything is ok for the moment
                        Thank you very much for your help
                        and thank for this plugin ,if everything works perfectly then I would be happy to take the license after the try
                        Best regards , Stephane

                        Comment


                          #13
                          This could be the speed of the comport. I would recommend moving the board to ethernet in the future as this is faster and more reliable.

                          Greig.
                          Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
                          X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
                          Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
                          Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
                          Scripts =
                          Various

                          Comment


                            #14
                            Originally posted by enigmatheatre View Post
                            This could be the speed of the comport. I would recommend moving the board to ethernet in the future as this is faster and more reliable.

                            Greig.
                            Ok thank you very much
                            best regards, Stephane

                            Comment

                            Working...
                            X