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. Sending Variables to a arduino switch

Sending Variables to a arduino switch

Scheduled Pinned Locked Moved Vera
28 Posts 8 Posters 11.9k Views 6 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.
  • mfalkviddM Offline
    mfalkviddM Offline
    mfalkvidd
    Mod
    wrote on last edited by
    #5

    What is the output on the serial port when you run it?
    What type of led are you using?

    Most leds cannot be controlled by voltage level (analogWrite), they need to be controlled by pwm.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      patrick schaerer
      wrote on last edited by patrick schaerer
      #6

      The LED is not the problem. AnalogWrite works perfect.
      Serial out is:
      Requesting VAR1
      LED Level 255

      connecting at 9600
       ,pt=0,l=23,sg=0,st=ok:LED brightness via VAR1
       send: 5-5-13-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:0.2 
      send: 5-5-13-0 s=0,c=0,t=3,pt=0,l=0,sg=0,st=ok: 
      Requesting VAR1 send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: Requesting VAR1send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: 
      LED Level: 255 
      read: 13-13-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 
      Requesting VAR1send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: 
      LED Level: 255 
      Requesting VAR1send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: 
      LED Level: 255 
      Requesting VAR1send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: 
      LED Level: 255 
      read: 13-13-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 
      Requesting VAR1send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: 
      LED Level: 255 
      Requesting VAR1send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: 
      LED Level: 255 
      Requesting VAR1send: 5-5-13-0 s=0,c=2,t=24,pt=0,l=0,sg=0,st=ok: 
      LED Level: 255
      

      IncomingMessage routine is never executed

      1 Reply Last reply
      0
      • sundberg84S Offline
        sundberg84S Offline
        sundberg84
        Hardware Contributor
        wrote on last edited by
        #7

        Im having this issue as well with domoticz... sometimes i get a reply but its like that ack doesnt work somewhere. Im trying to figure this out but no luck so far. Was just about to post in Domoticz forum yesterday but didnt...

        Im trying to recieve a VAR1 for my rain sensor... sometimes it takes 10 tries and sometimes it never returns. I have the sensor just beside the gateway with no luck so my feeling is that there is an error in the code somewhere (Domoticz or Mysensors, dont know).

        So far I have not debugge my gateway (no logs) but in MYSController i get the request in but never see any reply out with the VAR1 value.

        Controller: Proxmox VM - Home Assistant
        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

        1 Reply Last reply
        0
        • BartEB Offline
          BartEB Offline
          BartE
          Contest Winner
          wrote on last edited by BartE
          #8

          @patrick-schaerer the problem in your code snipped is the delay(1000).

          This is a blocking call which blocks also your radio module from communicating. You have to use gw.wait(1000); i.s.o. delay. Now your plugin will receive data.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            patrick schaerer
            wrote on last edited by
            #9

            @BartE said:

            @patrick-schaerer the problem in your code snipped is the delay(1000).

            This is a blocking call which blocks also your radio module from communicating. You have to use gw.wait(1000); i.s.o. delay. Now your plugin will receive data.

            ok Ill try that

            1 Reply Last reply
            0
            • sundberg84S Offline
              sundberg84S Offline
              sundberg84
              Hardware Contributor
              wrote on last edited by
              #10

              I don't have any delay in my code. Still same problem with var1 and domoticz.

              Controller: Proxmox VM - Home Assistant
              MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
              MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
              RFLink GW - Arduino Mega + RFLink Shield, 433mhz

              1 Reply Last reply
              0
              • P Offline
                P Offline
                patrick schaerer
                wrote on last edited by
                #11

                delay is not the problem ... i changed the code to gw.wait(1000)
                Serial output is the same

                1 Reply Last reply
                0
                • sundberg84S Offline
                  sundberg84S Offline
                  sundberg84
                  Hardware Contributor
                  wrote on last edited by sundberg84
                  #12

                  I wrote a code that only fetch time and the V_VAR1 - works every time.
                  MySensors 2.0b, Ethernet GW, Domoticz latest version:

                  #NOTE THAT CODE IS FOR MySensors > 1.6.0b version
                  #define MY_DEBUG 
                  
                  // Enable and select radio type attached
                  #define MY_RADIO_NRF24
                  //#define MY_RADIO_RFM69
                  
                  #define MY_NODE_ID 7
                  
                  #include <SPI.h>
                  #include <MySensor.h>  
                  #include <Time.h>  
                  
                  boolean timeReceived = false;
                  unsigned long lastUpdate=0, lastRequest=0;
                  #define CHILD_ID 1   
                  
                  boolean pcReceived = false; 
                  unsigned long lastSend =0; 
                  
                  void setup()  
                  {  
                  }
                  
                  void presentation()  {
                    // Send the sketch version information to the gateway and Controller
                    sendSketchInfo("Test to get V_VAR1", "1.0");
                  }
                  
                  void loop()     
                  {     
                    unsigned long now = millis();
                  
                    // If no time has been received yet, request it every 5 second from controller
                    // When time has been received, request update every hour
                    if ((!timeReceived && (now-lastRequest) > (5UL*1000UL))
                      || (timeReceived && (now-lastRequest) > (60UL*1000UL*60UL))) {
                      requestTime();  
                      lastRequest = now;
                    }
                  
                      //Request V_VAR1 every 5 sec if not recieved.
                      if (!pcReceived && (now - lastSend > 5000)) {      
                        request(CHILD_ID, V_VAR1);
                        lastSend=now;
                        return;
                      }
                      if (!pcReceived) {
                        return;
                      }
                  }
                  
                  void receive(const MyMessage &message) {
                    if (message.type==V_VAR1) {
                    Serial.print("Received last pulse count from gw:");
                    Serial.println(message.getULong());
                    pcReceived = true;
                    }
                  }
                  
                  // This is called when a new time value was received
                  void receiveTime(unsigned long time) {
                    // Ok, set incoming time 
                    setTime(time);
                    Serial.print("Got time, hour: ");
                    Serial.println(hour());
                    timeReceived = true;
                  }
                  

                  Its not different from my Rain sensor code... where i have the same problem as above... so there must be something else blocking recieve function in that code or radiotraffic... Its nothing wrong with Domoticz and/or Gateway what i can see... its something wrong with the code in the sensor itself. To be continued...

                  Controller: Proxmox VM - Home Assistant
                  MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                  MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                  RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                  1 Reply Last reply
                  0
                  • sundberg84S Offline
                    sundberg84S Offline
                    sundberg84
                    Hardware Contributor
                    wrote on last edited by
                    #13

                    What is similar in our sketches that does not work is that we use pin 3. I have seen some post with relays that it worked if you move to pin 4. Don't know why but I will try this tonight. Worth a shot...

                    Controller: Proxmox VM - Home Assistant
                    MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                    MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                    RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                    1 Reply Last reply
                    0
                    • BartEB Offline
                      BartEB Offline
                      BartE
                      Contest Winner
                      wrote on last edited by BartE
                      #14

                      @patrick-schaerer and @sundberg84

                      I've compiled your code and uploaded in my Arduino to debug your issue. What i noticed is that the sketch worked on my side, two remarks on the code snipped:

                      • why switching back to 9600 baud and not just setting your terminal to 115200 baud.
                      • line 83 contains an error i think the + should be removed so it becomes this line:
                      LED_Level = gwLEDLevel;
                      

                      But this will not solve you original problem. What i also noticed is when you requesting data from a none exiting node you do not get any data but the following error in your Vera controller log file:

                      Open a terminal like putty -> new connection to your Vera's IP address login with username root and the WIFI password and give this command

                      tail -f /var/log/cmh/LuaUPnP.log
                      

                      The error line you might see is this one (the second line is yellow marked)

                      50      01/17/16 15:07:28.915   luup_log:64: Arduino: Log: read: 50-50-0 s=255,c=3,t=12,pt=0,l=3,sg=0:0.2 <0x6011>
                      02      01/17/16 15:07:28.918   luup_log:64: Arduino: Incoming internal command '50;255;3;0;12;0.2' discarded for child: nil <0x6011>
                      

                      So it might help to:

                      • start MySensors inclusion mode
                      • give a reset on your Arduino
                      • wait to see MySensors does find new nodes
                      • press stop inclusion
                      • wait until Vera is ready again
                      • press reload
                      • wait until Vera is ready again
                      • reset your Arduino again and make sure the MySensor node shows the corrent version information
                      1 Reply Last reply
                      0
                      • sundberg84S Offline
                        sundberg84S Offline
                        sundberg84
                        Hardware Contributor
                        wrote on last edited by
                        #15

                        Tried my hypothesis above but same error. What made some different now was to add a second cap of 10uF to the radio... still nog good, but at least after some tries I now receive the V_VAR1.

                        Controller: Proxmox VM - Home Assistant
                        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                        1 Reply Last reply
                        0
                        • clio75C Offline
                          clio75C Offline
                          clio75
                          wrote on last edited by
                          #16

                          @sundberg84
                          Can your code be used on 1.5.1 ??
                          I need to get Temp Values from Vera. to my PID controller

                          1 Reply Last reply
                          0
                          • sundberg84S Offline
                            sundberg84S Offline
                            sundberg84
                            Hardware Contributor
                            wrote on last edited by sundberg84
                            #17

                            No - code is > 1.6b
                            @clio75 I couldnt find out what my problem was... got tired of it and uploaded same sketch so complete new set of hardware... and now its working so my occlusion was bad hardware.

                            Controller: Proxmox VM - Home Assistant
                            MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                            MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                            RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                            1 Reply Last reply
                            0
                            • clio75C Offline
                              clio75C Offline
                              clio75
                              wrote on last edited by
                              #18

                              @sundberg84
                              Thanx for your reply,

                              Do you know where I can find one example for getting variables from Vera ?
                              I have tried searching, but can't seem to find any :(
                              Thanx

                              1 Reply Last reply
                              0
                              • sundberg84S Offline
                                sundberg84S Offline
                                sundberg84
                                Hardware Contributor
                                wrote on last edited by sundberg84
                                #19

                                In the library you can use timeawaresensor to recieve time
                                https://github.com/mysensors/Arduino/tree/development/libraries/MySensors/examples/TimeAwareSensor

                                The raingauge, WaterMeterPulseSensor and Power meter to recieve V_VAR1

                                Controller: Proxmox VM - Home Assistant
                                MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                                MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                                RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  patrick schaerer
                                  wrote on last edited by
                                  #20

                                  @BartE: Thank you for your corrections to the code. I changed that.

                                  Now the sketch works. All I did is to add a new repeaternode between the gateway and the receiving node. It was definetly a hardware problem (or the problem was solved in 1.5.3 update).

                                  The LED_Node_var sketch works!

                                  1 Reply Last reply
                                  0
                                  • NuubiN Offline
                                    NuubiN Offline
                                    Nuubi
                                    wrote on last edited by
                                    #21

                                    Eh, how do you define or set a value for, let's say, V_VAR1 in Vera?

                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      patrick schaerer
                                      wrote on last edited by
                                      #22

                                      in the advanced tab all the way down at the bottom there are should be Variable1. Put a value in the field and save.
                                      the next time your device requests the variable, the new value will be sent.

                                      NuubiN 1 Reply Last reply
                                      0
                                      • P patrick schaerer

                                        in the advanced tab all the way down at the bottom there are should be Variable1. Put a value in the field and save.
                                        the next time your device requests the variable, the new value will be sent.

                                        NuubiN Offline
                                        NuubiN Offline
                                        Nuubi
                                        wrote on last edited by
                                        #23

                                        @patrick-schaerer said:

                                        in the advanced tab all the way down at the bottom there are should be Variable1. Put a value in the field and save.
                                        the next time your device requests the variable, the new value will be sent.

                                        Thanks, though so, too.
                                        So the next question is, is it possible to add variables to sensor types that don't have those to begin with? In my case I'd like to add few variables to window covers (S_COVER in http://www.mysensors.org/download/serial_api_15). Can't test now, but would this gw.present(CHILD_ID_OF_BLINDS, V_VAR1) work in adding this property to the blinds?

                                        1 Reply Last reply
                                        0
                                        • P Offline
                                          P Offline
                                          patrick schaerer
                                          wrote on last edited by
                                          #24

                                          It should work. The variable1 appears in vera after the sensor had requested var1. (But Im not completely shure about that ... )

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


                                          12

                                          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