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. Development
  3. Connect sensors directly to the Gateway (again)

Connect sensors directly to the Gateway (again)

Scheduled Pinned Locked Moved Development
gatewaysensordevelopment
22 Posts 9 Posters 14.5k Views 9 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.
  • D Offline
    D Offline
    DirkB19
    wrote on last edited by
    #12

    @Mihai258, I can't seem to compile your MySensor2_GatewayMQTT_Sensors_Mega.ino
    It gives me these errors error : 'send' was not declared in this scope (and the same error for 'present' and 'ServerUpdate') I must be overlooking something obvious ?

    So my goal is to make build a Mega 2560 based MQTT client gateway WITHOUT radio and WITH local sensors (mostly contact-inputs) & actuators (relays). All this offcourse in development branch libs.
    My starting point would be Mihai258's example and then simply remove the MY_RADIO_NRF24 -#define's.
    Will this work ?

    Thanks,
    DirkB19

    M 1 Reply Last reply
    0
    • D DirkB19

      @Mihai258, I can't seem to compile your MySensor2_GatewayMQTT_Sensors_Mega.ino
      It gives me these errors error : 'send' was not declared in this scope (and the same error for 'present' and 'ServerUpdate') I must be overlooking something obvious ?

      So my goal is to make build a Mega 2560 based MQTT client gateway WITHOUT radio and WITH local sensors (mostly contact-inputs) & actuators (relays). All this offcourse in development branch libs.
      My starting point would be Mihai258's example and then simply remove the MY_RADIO_NRF24 -#define's.
      Will this work ?

      Thanks,
      DirkB19

      M Offline
      M Offline
      Mihai
      wrote on last edited by
      #13

      @DirkB19 , I just compile again this file and it works fine for me using Arduino IDE 1.6.5 on Linux, MySensors 2.0.0 beta, set Arduino/Genuino Mega or Mega 2560:

      Sketch uses 40,046 bytes (15%) of program storage space. Maximum is 253,952 bytes.
      Global variables use 1,404 bytes (17%) of dynamic memory, leaving 6,788 bytes for local variables. Maximum is 8,192 bytes.
      

      I saw this library is continuously changed, while still beta and still the same version number from long tome ago! You may remove some important definition or included libs, or the actual MySensor development version need something different into the code. I may ZIP and send to you my working version of MySensors, but should this be the right approach?

      D 1 Reply Last reply
      0
      • M Mihai

        @DirkB19 , I just compile again this file and it works fine for me using Arduino IDE 1.6.5 on Linux, MySensors 2.0.0 beta, set Arduino/Genuino Mega or Mega 2560:

        Sketch uses 40,046 bytes (15%) of program storage space. Maximum is 253,952 bytes.
        Global variables use 1,404 bytes (17%) of dynamic memory, leaving 6,788 bytes for local variables. Maximum is 8,192 bytes.
        

        I saw this library is continuously changed, while still beta and still the same version number from long tome ago! You may remove some important definition or included libs, or the actual MySensor development version need something different into the code. I may ZIP and send to you my working version of MySensors, but should this be the right approach?

        D Offline
        D Offline
        DirkB19
        wrote on last edited by
        #14

        @Mihai
        I just updated the libs from the development branch. Still the same errors.
        I'm on Windows 10 with Arduino 1.6.6
        Not sure but if you could send me a ZIP I'll give it a try.
        Grtz

        mfalkviddM 1 Reply Last reply
        0
        • D DirkB19

          @Mihai
          I just updated the libs from the development branch. Still the same errors.
          I'm on Windows 10 with Arduino 1.6.6
          Not sure but if you could send me a ZIP I'll give it a try.
          Grtz

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #15

          @DirkB19 when you update the libraries, do you delete the entire MySensors folder first? Adding the new version on top of the old doesn't work, the old version must be obliterated first :)

          D 1 Reply Last reply
          0
          • mfalkviddM mfalkvidd

            @DirkB19 when you update the libraries, do you delete the entire MySensors folder first? Adding the new version on top of the old doesn't work, the old version must be obliterated first :)

            D Offline
            D Offline
            DirkB19
            wrote on last edited by
            #16

            @mfalkvidd
            aha ! That trick worked ! Thanks a lot !
            I guess 'newbie' is the word for me :)

            But coming back to my second question about this MQTT Client Gateway without radio and with local sensors and actuators ... will it work ?
            If I have the time I will find out by trial-and-error tonight.

            Bye

            1 Reply Last reply
            1
            • D Offline
              D Offline
              DirkB19
              wrote on last edited by
              #17

              Ok, so I tried MQTT Client Gateway without radio and with local sensors and actuators and it works !!

              The MQTT topic shows the node-id as 0, which makes sense as it is a gateway.

              One thing I noticed, is that the Gateway occasionally seems to loose connection with the MQTT broker and then it shows "Attempting to connnect to MQTT broker ..." in the serial log.

              I suspect that my heavy void loop() occupies the CPU too much ?
              (I'm debouncing 16 contact inputs without the debounce library, without waits, without interrupts)

              Also sending a relais change status from OpenHab takes a few seconds before it actually gets changed on the Mega.
              OpenHab publishes right away (I see it on the MQTT monitor), but then it seems to take time before the
              void receive(const MyMessage &message) picks it up and changes the relais.

              I will do some more testing to see where the problem lies.
              Grtz,
              DirkB

              M 1 Reply Last reply
              1
              • D DirkB19

                Ok, so I tried MQTT Client Gateway without radio and with local sensors and actuators and it works !!

                The MQTT topic shows the node-id as 0, which makes sense as it is a gateway.

                One thing I noticed, is that the Gateway occasionally seems to loose connection with the MQTT broker and then it shows "Attempting to connnect to MQTT broker ..." in the serial log.

                I suspect that my heavy void loop() occupies the CPU too much ?
                (I'm debouncing 16 contact inputs without the debounce library, without waits, without interrupts)

                Also sending a relais change status from OpenHab takes a few seconds before it actually gets changed on the Mega.
                OpenHab publishes right away (I see it on the MQTT monitor), but then it seems to take time before the
                void receive(const MyMessage &message) picks it up and changes the relais.

                I will do some more testing to see where the problem lies.
                Grtz,
                DirkB

                M Offline
                M Offline
                Mihai
                wrote on last edited by
                #18

                @DirkB19 It may take some time to follow the debounce procedure for each of the 16 inputs. For me, I have no big problems with delay, the commands act almost instantly. I do not use debounce, since no physical input there, while my node use 4 relays, several sensors, IR receiver (this take some time, but no big delay).

                1 Reply Last reply
                0
                • TmasterT Offline
                  TmasterT Offline
                  Tmaster
                  wrote on last edited by
                  #19

                  hi. now that 2.0 it 's released .I'm upgrading my few sensors. But i was reading about diferences i couldn't find any example of a gateway + node integrated.
                  my doubt is how to send sensor mensage? send() is used to send message to the air ,but if the node is the same as the gw what command do i use?the same?

                  i'm a arduino fan .Even sometimes don't undestanding how to use it :P

                  chrilleC 1 Reply Last reply
                  0
                  • TmasterT Tmaster

                    hi. now that 2.0 it 's released .I'm upgrading my few sensors. But i was reading about diferences i couldn't find any example of a gateway + node integrated.
                    my doubt is how to send sensor mensage? send() is used to send message to the air ,but if the node is the same as the gw what command do i use?the same?

                    chrilleC Offline
                    chrilleC Offline
                    chrille
                    wrote on last edited by
                    #20

                    @Tmaster said:

                    hi. now that 2.0 it 's released .I'm upgrading my few sensors. But i was reading about diferences i couldn't find any example of a gateway + node integrated.
                    my doubt is how to send sensor mensage? send() is used to send message to the air ,but if the node is the same as the gw what command do i use?the same?

                    If you read at the top of this thread, there's a post from @Mihai - there's a very good example there - look at this:

                    https://github.com/Mihai258/MySensors2-HomeAssistant-MQTT/blob/master/Gateway/MySensor2_GatewayMQTT_Sensors_Mega/MySensor2_GatewayMQTT_Sensors_Mega.ino

                    And yes, you still use send() to send messages.

                    • Jan
                    1 Reply Last reply
                    0
                    • TmasterT Offline
                      TmasterT Offline
                      Tmaster
                      wrote on last edited by
                      #21

                      but how gateway node knows that what i send from "embebbed sensor" is to "process" there and will not send through air? its on code that will stay on id 0(gateway)?
                      I know it can be an stupid question for who know the mysensors library in "its core" but not for me :P

                      I want assure that my power meter is uploading measures by serial and not by air,and making unnecessary use from nrf24 modules that cam be used for receive messages from the other nodes .

                      i'm a arduino fan .Even sometimes don't undestanding how to use it :P

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

                        @Tmaster
                        You give each sensor a child id (0-254) in the node.

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


                        11

                        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