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
  1. Home
  2. Controllers
  3. Vera
  4. Vera Plus and MySensors Local Serial Gateway

Vera Plus and MySensors Local Serial Gateway

Scheduled Pinned Locked Moved Vera
12 Posts 2 Posters 3.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • briskspiritB Offline
    briskspiritB Offline
    briskspirit
    wrote on last edited by
    #2

    Tried both Vera-dev and Vera-UI7 github channels.. no luck.. maybe the problem is in this lines:

    02	10/27/16 16:59:39.756	luup_log:133: Arduino: Incoming internal command '0;255;3;0;11;Arduino_USB' discarded for child: nil <0x717a6520>
    02	10/27/16 16:59:39.757	luup_log:133: Arduino: Incoming internal command '0;255;3;0;12;1.0' discarded for child: nil <0x717a6520>
    

    But cant handle and understand this errors...

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #3

      I haven't tried the Vera plugin with locally attached sensors. Took another look at the code but I can't see any reason why it shouldn't work.

      Might be good to introduce some more log-entries in the plugin lua code to see where it fails.

      Here:
      https://github.com/mysensors/Vera/blob/development/L_Arduino.lua#L328
      and here:
      https://github.com/mysensors/Vera/blob/development/L_Arduino.lua#L397

      briskspiritB 1 Reply Last reply
      0
      • briskspiritB Offline
        briskspiritB Offline
        briskspirit
        wrote on last edited by
        #4

        @hek said:

        https://github.com/mysensors/Vera/blob/development/L_Arduino.lua#L397

        Mmm, will try.. but I am new to LUA)) So will try to understand it.
        I am clicking start include and then reset my gateway, right?
        As you see the problem is in gateway inclusion and discarded commands

        1 Reply Last reply
        0
        • hekH hek

          I haven't tried the Vera plugin with locally attached sensors. Took another look at the code but I can't see any reason why it shouldn't work.

          Might be good to introduce some more log-entries in the plugin lua code to see where it fails.

          Here:
          https://github.com/mysensors/Vera/blob/development/L_Arduino.lua#L328
          and here:
          https://github.com/mysensors/Vera/blob/development/L_Arduino.lua#L397

          briskspiritB Offline
          briskspiritB Offline
          briskspirit
          wrote on last edited by
          #5

          @hek

          And which branch I should use? development or UI7 ?

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #6

            Think they are the same at the moment.

            briskspiritB 1 Reply Last reply
            0
            • hekH hek

              Think they are the same at the moment.

              briskspiritB Offline
              briskspiritB Offline
              briskspirit
              wrote on last edited by
              #7

              @hek

              Still can't see in code why it get discarded.. Saw that there is discard for 1.0 versions in payload - changed to 2.0 in my sketch - no luck.

              Here is my sketch, look plz maybe somewhere is an error, but took here on forum from some member who has it working on Vera:

              
              // Enable debug prints to serial monitor
              //#define MY_DEBUG 
              
              
              // Enable and select radio type attached
              //Comento la siguiente linea para que no necesite radio
              //#define MY_RADIO_NRF24
              //#define MY_RADIO_RFM69
              
              // Set LOW transmit power level as default, if you have an amplified NRF-module and
              // power your radio separately with a good regulator you can turn up PA level. 
              //#define MY_RF24_PA_LEVEL RF24_PA_LOW
              
              // Enable serial gateway
              #define MY_GATEWAY_SERIAL
              
              // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
              //#define MY_BAUD_RATE 9600
              
              
              // Enable inclusion mode
              #define MY_INCLUSION_MODE_FEATURE
              // Enable Inclusion mode button on gateway
              #define MY_INCLUSION_BUTTON_FEATURE
              
              // Inverses behavior of inclusion button (if using external pullup)
              //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
              
              // Set inclusion mode duration (in seconds)
              #define MY_INCLUSION_MODE_DURATION 60 
              // Digital pin used for inclusion mode button
              #define MY_INCLUSION_MODE_BUTTON_PIN  3 
              
              // Uncomment to override default HW configurations
              //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
              //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
              //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
              
              #include <SPI.h>
              #include <MySensors.h>  
              
              //Para el sensor de temperatura
              #ifdef TEMP
               #include <DallasTemperature.h>
               #include <OneWire.h>
               #define ONE_WIRE_BUS 2
               OneWire oneWire(ONE_WIRE_BUS);
               DallasTemperature sensors(&oneWire);
               MyMessage msg(0,V_TEMP);
              #endif
              
              //Structura de reles
              typedef struct  {
               int  pin;
               char desc[20];
               bool ON;
               bool OFF;
              } sRELE;
              
              sRELE Rele [] = { {13 , "LED", HIGH, LOW},
                               {31 , "RELE ASPERSOR PORCHE", LOW, HIGH},
                               {33 , "RELE TURBINAS", LOW, HIGH},
                               {35 , "RELE GOTEROS BAJOS", LOW, HIGH}
                             };
              
              #define NUMBER_OF_RELAYS 4 // Total number of attached relays
              
              void setup() { 
               // Setup locally attached sensors
              #ifdef TEMP
               //Para el sensor de temperatura
               sensors.begin();
              #endif
               //Para los reles
                // Serial.println("start call Setup");
               for (int sensor=0 ; sensor<NUMBER_OF_RELAYS;sensor++) {
                 // Poner el rele en output mode
                 pinMode(Rele[sensor].pin, OUTPUT);   
                 // Poner el rele en el ultimo estado conocido (usando eeprom storage) 
                 digitalWrite(Rele[sensor].pin, loadState(sensor)?Rele[sensor].ON:Rele[sensor].OFF);
               }
                // Serial.println("End call Setup");
                
              }
              
              void presentation() {
               // Presentar los sensores y actuadores locales 
               //Serial.println("start call presentation");
               // Mandar la info del sketch
              
               sendSketchInfo("myGateway", "2.0");
               //Presentar los reles
               for (int rele=0; rele<NUMBER_OF_RELAYS;rele++) {
                 // Registrar todos los reles al gw
                 present(rele, S_LIGHT,Rele[rele].desc);
               }
               //Serial.println("End call presentation");
              #ifdef TEMP
               //Presento el sensor de temperatura
               present(9,S_TEMP,"SENSOR_TEMP");
              #endif
              }
              bool STATUS;
              void loop() { 
               // Send locally attached sensor data here 
              #ifdef TEMP
              // Serial.print("Solicitando temperaturas...");
               sensors.requestTemperatures(); // Send the command to get temperatures
               float temperatura = sensors.getTempCByIndex(0);
               send(msg.setSensor(9).set(temperatura,1));
              // Serial.println("DONE");
               sleep(2000);
              #endif
              }
              
              
              void receive(const MyMessage &message) {
               // Solo esperamos mensajes V_LIGTH de momento, pero lo chequeamos por si acaso.
               if (message.type==V_LIGHT) {
                  // Cambiar estado del rele
                  digitalWrite(Rele[message.sensor].pin, message.getBool()?Rele[message.sensor].ON:Rele[message.sensor].OFF);
                  // Almacenar estado en la eeprom
                  saveState(message.sensor, message.getBool());
                  // Escribir informacion de debug
                 // Serial.print("Cambio entrante para sensor:");
                 // Serial.print(message.sensor);
                 // Serial.print(", Nuevo status: ");
                  //Serial.println(message.getBool());
                } 
              }
              
              
              1 Reply Last reply
              0
              • briskspiritB Offline
                briskspiritB Offline
                briskspirit
                wrote on last edited by
                #8

                As I understand the code, when I reset gateway and it was in inclusion mode - I get here:

                elseif (messageType==msgType.PRESENTATION) then
                log("Presentation: ".. s)
                presentation(incomingData, device, childId, altId)

                But I don't see any code in presentation function that belongs to creation of new device in Vera...
                I see creation at processInternalMessage, but it would not run as I get Presentation: 0;255;0;0;17;2.0.1-beta , but for inclusion it should be Presentation: 0;255;3;0;17;2.0.1-beta ? (message_type 3, not 0 as 0 do nothing with dev inclusion)

                1 Reply Last reply
                0
                • hekH Offline
                  hekH Offline
                  hek
                  Admin
                  wrote on last edited by
                  #9

                  Can't find any obvious error in the sketch.

                  The creation process starts after inclusion mode ends.. see my link above.

                  briskspiritB 1 Reply Last reply
                  0
                  • hekH hek

                    Can't find any obvious error in the sketch.

                    The creation process starts after inclusion mode ends.. see my link above.

                    briskspiritB Offline
                    briskspiritB Offline
                    briskspirit
                    wrote on last edited by
                    #10

                    @hek said:

                    Can't find any obvious error in the sketch.

                    The creation process starts after inclusion mode ends.. see my link above.

                    Nope, I am sorry, but you are wrong... In case of local sensor it would not start(and I tested that with debug log in each function).
                    Made some test function called processInclusion and now I got new devices listed) But because I am not a coder and don't know LUA - need to polish it a bit.
                    The problem is that I need to push reset button on arduino, after that gateway send presentation BUT without internal type of message! So there is two ways:
                    1 - make function for just inclusion process and put in right after presentation fujnction(pice of code from processInternal** function)
                    2 - Make gateway to send some internal command right after presentation(not tested)

                    First way tested, but I need to reset gateway same quantity of times as I have external sensors. So each new sensor is added after each reset.

                    1 Reply Last reply
                    0
                    • briskspiritB Offline
                      briskspiritB Offline
                      briskspirit
                      wrote on last edited by briskspirit
                      #11

                      (Edited post)

                      Thought all night about my problem and it's solution... Just was one thought that dev's of mysensors plugin can't make mistake in old tested plugin) Reviewed plugin code once again and understood it's logic. So first we get called Presentation function which stores new devices in array and than we should get command from gateway about finished inclusion process and plugin start to add devices to Vera. So the problem is: when we don't use radio and only local sensors we don't get message about inclusion finish! )

                      Solution is to send this message manually from gateway right after presentation processes. Should look like 0;255;3;0;5;0

                      So I have added this lines to my Arduino sketch in presentation function:

                      Serial.print("0;255;3;0;5;0");
                        Serial.print("\n");
                      

                      This solution will work without coding to existing Vera plugin :)

                      (Sorry, didn't found any other way to send this message like with MyMessage container)

                      briskspiritB 1 Reply Last reply
                      1
                      • briskspiritB briskspirit

                        (Edited post)

                        Thought all night about my problem and it's solution... Just was one thought that dev's of mysensors plugin can't make mistake in old tested plugin) Reviewed plugin code once again and understood it's logic. So first we get called Presentation function which stores new devices in array and than we should get command from gateway about finished inclusion process and plugin start to add devices to Vera. So the problem is: when we don't use radio and only local sensors we don't get message about inclusion finish! )

                        Solution is to send this message manually from gateway right after presentation processes. Should look like 0;255;3;0;5;0

                        So I have added this lines to my Arduino sketch in presentation function:

                        Serial.print("0;255;3;0;5;0");
                          Serial.print("\n");
                        

                        This solution will work without coding to existing Vera plugin :)

                        (Sorry, didn't found any other way to send this message like with MyMessage container)

                        briskspiritB Offline
                        briskspiritB Offline
                        briskspirit
                        wrote on last edited by
                        #12

                        @hek , maybe you could help to do that more right? And I think that this should be added to GitHub as a bug for 2.0.1-dev lib version (don't have an account on git)

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        23

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.1k

                        Posts


                        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

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