Stay on version 1.5 or move to 2.1.1 on my vera plus and vera 3?



  • Hello everyone,

    I run version 1.5 on both my vera's and Ethernet gateways and someone hinted to go to version 2.x since the newer codes don't work with 1.5

    I also read on this forum there are issues with version 2.x and library.
    Is it usefull to stay on version 1.5 or I better upgrade?

    I run not that many nodes , an important one, servo actuator which is working good. And a door sensor with temperature sensor which is working not so good , it doesn't report alway , so an extra piece of code is inserted so it reports at least every 30 seconds. Maybe with the new library and codes this is solved , and it reports a change immediately?

    This is the code for the servo actuator I use , will it still work with version 2.11?

    // Example showing how to create an atuator for a servo.
    // Connect red to +5V, Black or brown to GND and the last cable to Digital pin 3.
    // The servo consumes much power and should probably have its own powersource.'
    // The arduino might spontanally restart if too much power is used (happend
    // to me when servo tried to pass the extreme positions = full load).
    // Contribution by: Derek Macias
    
    
    #include <MySensor.h>
    #include <SPI.h>
    #include <Servo.h> 
    
    #define SERVO_DIGITAL_OUT_PIN 3
    #define SERVO_MIN 0 // Fine tune your servos min. 0-180
    #define SERVO_MAX 180 // Fine tune your servos max. 0-180
    #define DETACH_DELAY 4000 // Tune this to let your movement finish before detaching the servo
    #define CHILD_ID 10   // Id of the sensor child
    
    MySensor gw;
    MyMessage msg(CHILD_ID, V_DIMMER);
    Servo myservo;  // create servo object to control a servo 
                    // a maximum of eight servo objects can be created Sensor gw(9,10);
    unsigned long timeOfLastChange = 0;
    bool attachedServo = false;
                
    void setup() 
    { 
      // Attach method for incoming messages
      gw.begin(incomingMessage);
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Servo", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID, S_COVER);
    
      // Request last servo state at startup
      gw.request(CHILD_ID, V_DIMMER);
    } 
    
    void loop() 
    { 
      gw.process();
      if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) {
         myservo.detach();
         attachedServo = false;
      }
    } 
    
    void incomingMessage(const MyMessage &message) {
      myservo.attach(SERVO_DIGITAL_OUT_PIN);   
      attachedServo = true;
      if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
         int val = message.getInt();
        val = map(val, 0, 100, 0, 180); // scale 0%-100% between 0 and 180)
            myservo.write(val);       // sets the servo position 0-180
         // Write some debug info
         Serial.print("Servo changed. new state: ");
         Serial.println(val);
       } else if (message.type==V_UP) {
         Serial.println("Servo UP command");
         myservo.write(SERVO_MIN);
         gw.send(msg.set(100));
       } else if (message.type==V_DOWN) {
         Serial.println("Servo DOWN command");
         myservo.write(SERVO_MAX); 
         gw.send(msg.set(0));
       } else if (message.type==V_STOP) {
         Serial.println("Servo STOP command");
         myservo.detach();
         attachedServo = false;
    
       }
       timeOfLastChange = millis();
    }```

  • Mod

    @Corvl Hi, I did not have many sensors until now but I am ready to add stuff ( I finally have some time again 🙂 ).
    Because of that I decided to re-evaluate my sensors and to upgrade in the process.

    You probably guessed it but this is what I would do.

    If you are not planning to add (many) sensors and everything works well I would stay with 1.5.

    If either or both of the above conditions == false I would move to 2.2.1 (current version).



  • I would like to add some more stuff as well, and hopefully , with the newer version that doorsensor is working better.

    But is 2.11 working on vera?
    And the above sketch , of the servo actuator , is that one still compatible?

    Thanks,
    Cor


  • Mod

    @Corvl I can't comment on the vera question.

    For 2.1.1 you have to make some changes but they are not too difficult 😉


  • Hero Member

    @Corvl I am also not sure of any problems with Vera.

    Had a quick look at your sketch and it should be ok in version 2.

    V_DIMMER has been Deprecated and although it will still work at the moment you should now use V_PERCENTAGE instead

    Did a quick re-write for V2 so you can see what is different. I think I got all the changes
    I think you will find v2 easier to use once you get the hang of it

    // Example showing how to create an atuator for a servo.
    // Connect red to +5V, Black or brown to GND and the last cable to Digital pin 3.
    // The servo consumes much power and should probably have its own powersource.'
    // The arduino might spontanally restart if too much power is used (happend
    // to me when servo tried to pass the extreme positions = full load).
    // Contribution by: Derek Macias
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Enable repeater functionality for this node
    //#define MY_REPEATER_FEATURE
    
    #include <MySensors.h>
    //#include <MySensor.h>
    #include <SPI.h>
    #include <Servo.h> 
    
    #define SERVO_DIGITAL_OUT_PIN 3
    #define SERVO_MIN 0 // Fine tune your servos min. 0-180
    #define SERVO_MAX 180 // Fine tune your servos max. 0-180
    #define DETACH_DELAY 4000 // Tune this to let your movement finish before detaching the servo
    #define CHILD_ID 10   // Id of the sensor child
    
    //MySensor gw;   
    //MyMessage msg(CHILD_ID, V_DIMMER);  //V_DIMMER has been deprecated use V_PERCENTAGE instead
    MyMessage msg(CHILD_ID, V_PERCENTAGE);
    Servo myservo;  // create servo object to control a servo 
                    // a maximum of eight servo objects can be created Sensor gw(9,10);
    unsigned long timeOfLastChange = 0;
    bool attachedServo = false;
                
    void setup() 
    { 
      // Attach method for incoming messages
     // gw.begin(incomingMessage);
    
      // Send the sketch version information to the gateway and Controller
      //gw.sendSketchInfo("Servo", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      //gw.present(CHILD_ID, S_COVER);
    
      // Request last servo state at startup
      //gw.request(CHILD_ID, V_DIMMER);
      request(CHILD_ID, V_PERCENTAGE);
    } 
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Servo", "1.0");
    
      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID, S_COVER);
    }
    
    
    void loop() 
    { 
     // gw.process();
      if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) {
         myservo.detach();
         attachedServo = false;
      }
    } 
    
    //void incomingMessage(const MyMessage &message) {
    void receive(const MyMessage &message){
      
      myservo.attach(SERVO_DIGITAL_OUT_PIN);   
      attachedServo = true;
      //if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
      if (message.type==V_PERCENTAGE) {
         int val = message.getInt();
        val = map(val, 0, 100, 0, 180); // scale 0%-100% between 0 and 180)
            myservo.write(val);       // sets the servo position 0-180
         // Write some debug info
         Serial.print("Servo changed. new state: ");
         Serial.println(val);
       } else if (message.type==V_UP) {
         Serial.println("Servo UP command");
         myservo.write(SERVO_MIN);
        // gw.send(msg.set(100));
           send(msg.set(100));
       } else if (message.type==V_DOWN) {
         Serial.println("Servo DOWN command");
         myservo.write(SERVO_MAX); 
      //   gw.send(msg.set(0));
           send(msg.set(0));  
       } else if (message.type==V_STOP) {
         Serial.println("Servo STOP command");
         myservo.detach();
         attachedServo = false;
    
       }
       timeOfLastChange = millis();
    }
    
    


  • Thanks a lot , that is a big re-assurance , since that servo is hooked up on my heating system...... and it is still winter.

    Still , there are 2 or 3 threads here on this forum saying they cab's get version 2.x to work with vera on Ui7.

    I have a spare vera lite on Ui7 I will try this version 2.x on the vera lite first. But it will be for next week.

    Thanks a lot so far!,
    Cor


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 1
  • 5
  • 1

60
Online

11.4k
Users

11.1k
Topics

112.7k
Posts