Serial Gateway with Sensors



  • 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?


  • Mod

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



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


  • Admin

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



  • @hek Thanks! Now it worked 🙂

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


  • Mod



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

    Really thanks for your help, guys 🙂


  • Mod

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


Log in to reply
 

452
Online

6.7k
Users

7.6k
Topics

80.5k
Posts

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.