[Solved] API 2.0 void receive(const MyMessage& message) Problem



  • Hello, unfortunately is triggered no message here. The "textField" I applied and it is also available with a value. It is not even the "println" will be displayed. What am I doing wrong?

    sleep(SLEEP_TIME); //sleep for: sleepTime
    }
    //incomingMessage_____________________________________________________
    void receive(const MyMessage& message)
    {
      gasSensor.setR0(R0C);
     Serial.println(F("Incoming Message:"));
    }
    

  • Contest Winner

    @paqor I wouldn't put sensor readings in a message handler. Could you try this, just to test the messages?

    wait(SLEEP_TIME); //sleep for: sleepTime // byTheo: Changed
    }
    //incomingMessage_____________________________________________________
    void receive(const MyMessage& message)
    {
    //  gasSensor.setR0(R0C);  // byTheo: Changed
    // Serial.println(F("Incoming Message:")); // byTheo: Changed
    Serial.println("Incoming Message:");
    }
    

    And I also advice not to use sleep when having a node that can receive messages.



  • VIELEN VIELEN DANK!!!!
    Thanks alot😃


  • Contest Winner

    @paqor That it solve your problem?




  • Contest Winner

    @paqor That's great. I looked at the Sketch you posted on your site and noticed you're still using a delay. Which as short as it may be can cause messages to be missed.

    void loop(){
    //-----------------------------------------------------------------------------
    //TEMP_FEUCHTE 
    delay(dht.getMinimumSamplingPeriod());
    

    My advice is to do this with a wait as well.

    void loop(){
    //-----------------------------------------------------------------------------
    //TEMP_FEUCHTE 
    wait(dht.getMinimumSamplingPeriod()); // Changed ByTheo
    

    That way you don't block incoming messages. Generally, if you want your sketch to wait use a wait.



  • Okay, super, Thank you very much for your effort. I will correct it immediately



  • @TheoL said:

    @paqor That's great. I looked at the Sketch you posted on your site and noticed you're still using a delay. Which as short as it may be can cause messages to be missed.

    void loop(){
    //-----------------------------------------------------------------------------
    //TEMP_FEUCHTE 
    delay(dht.getMinimumSamplingPeriod());
    

    My advice is to do this with a wait as well.

    void loop(){
    //-----------------------------------------------------------------------------
    //TEMP_FEUCHTE 
    wait(dht.getMinimumSamplingPeriod()); // Changed ByTheo
    

    That way you don't block incoming messages. Generally, if you want your sketch to wait use a wait.

    genial, works perfectly....


 

381
Online

8.0k
Users

8.8k
Topics

94.4k
Posts