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. Serial Gateway with Sensors

Serial Gateway with Sensors

Scheduled Pinned Locked Moved Development
8 Posts 3 Posters 3.2k Views 4 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.
  • A Offline
    A Offline
    alfredocdmiranda
    wrote on last edited by
    #1

    Hi guys,

    Sorry if there is already a topic with this, however I couldn't find any helpful information.

    There is a long time since last time I have "played" with MySensors.

    Then, I am trying to run a Serial Gateway with a relay attached. However, it seems that it is not calling the presentation() function.

    My code:

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    //#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)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    // 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
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // 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 <MySensors.h>
    
    #define CHILD_ID 1
    
    void setup() {
      // Setup locally attached sensors
    }
    
    void presentation() {
     sendSketchInfo("Relay", "1.0");
     present(CHILD_ID, S_LIGHT);
    
    }
    
    void loop() {
      // Send locally attached sensor data here
    }
    
    

    My output:

    0;255;3;0;9;Starting gateway (R-NGA-, 2.0.0)
    0;255;3;0;14;Gateway startup complete.
    0;255;3;0;9;No registration required
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
    

    Another question that I couldn't find in docs is how can I set hardcode the node ID?

    mfalkviddM 1 Reply Last reply
    0
    • A alfredocdmiranda

      Hi guys,

      Sorry if there is already a topic with this, however I couldn't find any helpful information.

      There is a long time since last time I have "played" with MySensors.

      Then, I am trying to run a Serial Gateway with a relay attached. However, it seems that it is not calling the presentation() function.

      My code:

      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      //#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)
      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif
      
      // 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
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Inverses the behavior of leds
      //#define MY_WITH_LEDS_BLINKING_INVERSE
      
      // Flash leds on rx/tx/err
      // 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 <MySensors.h>
      
      #define CHILD_ID 1
      
      void setup() {
        // Setup locally attached sensors
      }
      
      void presentation() {
       sendSketchInfo("Relay", "1.0");
       present(CHILD_ID, S_LIGHT);
      
      }
      
      void loop() {
        // Send locally attached sensor data here
      }
      
      

      My output:

      0;255;3;0;9;Starting gateway (R-NGA-, 2.0.0)
      0;255;3;0;14;Gateway startup complete.
      0;255;3;0;9;No registration required
      0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
      

      Another question that I couldn't find in docs is how can I set hardcode the node ID?

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

      @alfredocdmiranda the id of a gateway is always 0, it can not be changed.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alfredocdmiranda
        wrote on last edited by
        #3

        About the Gateway ID it is fine. My main problem is that it seems presentation function is not being run.

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

          Please use the development branch. There was a bug fixed related to presentations of gateway attached sensors.

          A 1 Reply Last reply
          1
          • hekH hek

            Please use the development branch. There was a bug fixed related to presentations of gateway attached sensors.

            A Offline
            A Offline
            alfredocdmiranda
            wrote on last edited by
            #5

            @hek Thanks! Now it worked :)

            Hey, and can you answer me about how to set hardcode ID in some other node(not gateway)?

            mfalkviddM 1 Reply Last reply
            0
            • A alfredocdmiranda

              @hek Thanks! Now it worked :)

              Hey, and can you answer me about how to set hardcode ID in some other node(not gateway)?

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

              @alfredocdmiranda #define MY_NODE_ID
              See https://www.mysensors.org/download/sensor_api_20 for details

              A 1 Reply Last reply
              1
              • mfalkviddM mfalkvidd

                @alfredocdmiranda #define MY_NODE_ID
                See https://www.mysensors.org/download/sensor_api_20 for details

                A Offline
                A Offline
                alfredocdmiranda
                wrote on last edited by
                #7

                @mfalkvidd
                Oh, okay! Thanks. I haven't seen this code!

                Really thanks for your help, guys :)

                mfalkviddM 1 Reply Last reply
                1
                • A alfredocdmiranda

                  @mfalkvidd
                  Oh, okay! Thanks. I haven't seen this code!

                  Really thanks for your help, guys :)

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

                  @alfredocdmiranda you're wlecome. We're happy to be of assistance.

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


                  15

                  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