Can't get the void receive() to work, on Repeater and Node's



  • Hi.

    I use the last 2.0.1-beta dev. version (from last night), and I can't get the function void receive(const MyMessage &message) to work.
    It works fine on a Gateway setup.

    Have tryed 2 types of setups.

    1. Node(ID6) to a Repeater(ID7). I see the debug data on the repeater, but can't get any data via the void receive().
    2. Node(ID6) to Node(ID7). Also here, I see the data on Node(ID7), but can't get any data via the void receive() funktion.

    Any ideas?
    Node(ID6) has a Static parent to Node-ID7, and Node(ID7) has a Static parent to Node-ID6

    The void receive(const MyMessage &message) funktion, now works fine, from version 2.0.1-beta, on at GatewaySerial setup.


  • Hero Member

    @delinend Can you post the sketch.



  • @AWI
    Here the Node6, that sends temperatur, from a IR sensor to Parent-ID7

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #define MY_NODE_ID 6
    //#define MY_DEFAULT_ERR_LED_PIN 4
    #define MY_RF24_CHANNEL 123
    #define MY_RF24_PA_LEVEL RF24_PA_HIGH
    
    #define MY_PARENT_NODE_ID 7
    #define MY_PARENT_NODE_IS_STATIC
    
    //#define MY_REGISTRATION_FEATURE
    #define MY_TRANSPORT_DONT_CARE_MODE
    
    //#define MY_REPEATER_FEATURE
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <Wire.h>
    #include <Adafruit_MLX90614.h>
    
    Adafruit_MLX90614 mlx = Adafruit_MLX90614();
    
    unsigned long SLEEP_TIME = 500; // Sleep time between reads (in milliseconds)
    
    // Initialize temperature message
    MyMessage msg(0,V_TEMP);
    
    float temperature;
    
    
    
    void setup()  
    { 
     mlx.begin();
    }
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Temperature Sensor", "1.1");
      present(0, S_TEMP);
    }
    
    void loop()     
    {     
    
    //  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); 
    //  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
    
     temperature = mlx.readObjectTempC();
     Serial.println(temperature,1);
          // Send in the new temperature
          send(msg.setSensor(0).set(temperature,1));
    
       
      
      sleep(SLEEP_TIME);
    }
    

    Ande here Node7, from where I can see the temperatur data, via MY_DEBUG, but not via the void receive() function,

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    //#define MY_SPECIAL_DEBUG
    //#define MY_DEBUG_VERBOSE_SIGNING
    //#define MY_DISABLED_SERIAL
    
    
    
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #define MY_NODE_ID 7
    //#define MY_DEFAULT_ERR_LED_PIN 4
    #define MY_RF24_CHANNEL 123
    #define MY_RF24_PA_LEVEL RF24_PA_HIGH
    
    
    #define MY_PARENT_NODE_ID 6
    #define MY_PARENT_NODE_IS_STATIC
    #define MY_TRANSPORT_DONT_CARE_MODE
    
    // 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 MY_GATEWAY_W5100
    //#define MY_REPEATER_FEATURE
    
    
    
    
    #include <MySensors.h>
    
    
    
    
    void setup() {
    //  Serial.begin(19200);
    //  Serial.begin(MY_BAUD_RATE);
      Serial.println("Started . Please wait...");
      // Setup locally attached sensors
    }
    
    void presentation() {
     // Present locally attached sensors
     //sendSketchInfo("Temperature Sensor", "1.1");
    }
    
    void loop() {
      // Send locally attached sensor data here
    //Serial.println(tempp,1);
    delay(10);
    
    }
    
    void receive(const MyMessage &message) {
    //wait(10);
      Serial.println("received something: ");
    //Serial.println(message.type);
      Serial.println(message.sender);
    //  Serial.println(message.sensor);
    //  Serial.println(message.getBool());
    
    }
    

  • Hero Member

    @delinend said:
    send(msg.setSensor(0).set(temperature,1));

    shouldn't that be

    send(msg.setDestination(7).setSensor().set(temperature,1));

    in order to have messages delivered at the right destination == 7



  • @AWI
    You hare a Hero 🙂 That works!
    Btw. Is the setting #define MY_TRANSPORT_DONT_CARE_MORE the right setting, when in a 2 Node's only setup ? I can't else get the Node6 beginning transmitting data.


  • Hero Member

    @delinend The "royal way" is to have one node be a gateway. Else you need the "don't care"


Log in to reply
 

Suggested Topics

25
Online

11.4k
Users

11.1k
Topics

112.7k
Posts