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. Troubleshooting
  3. not going in the void receive() function

not going in the void receive() function

Scheduled Pinned Locked Moved Troubleshooting
2 Posts 2 Posters 1.3k Views 2 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.
  • npiotN Offline
    npiotN Offline
    npiot
    wrote on last edited by
    #1

    Hi,
    working on my sensors v2, IDE arduino 1.6.7
    The sketch is working OK, and connects to my jeedom controller no problem.
    I want to use the data received from node directly on my gateway to process it (jeedom is just here to record the data over time).

    on my serial gateway sketch, I added a void receive( const Mymessage &message) {} fonction, and it seems the sketch is never going there, even when messages are received, as I can see in my serial console.

    Any idea someone? Any help much appreciated.

    
    // 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
    
    // Flash leds on rx/tx/err
    #define MY_LEDS_BLINKING_FEATURE
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // 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 
    
    // 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 <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>
    
    #define CHILD_ID_HUM 10
    #define CHILD_ID_TEMP 11
    #define HUMIDITY_SENSOR_DIGITAL_PIN 4  //data pin pour DHT
    
    #define BUREAU_NODE_ID 1
    #define GW_NODE_ID 0
    #define DS18B20 0
    #define THERM 17
    #define TEMP_DHT 11
    #define HRD_HT 10
    
    float bureauds = 0, bureautherm =0, tempdht = 0, hrdht =0;
    
    unsigned long SLEEP_TIME = 10000; // Sleep time between reads (in milliseconds)
    
    DHT dht;
    //float lastTemp;
    //float lastHum;
    boolean metric = true; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    void setup() { 
      // Setup locally attached sensors
      Serial.begin(115200);
      Serial.println();
      Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)");
    
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    }
    
    void presentation() {
      sendSketchInfo("GW Humidity/Temp", "1.0");
     // Present locally attached sensors 
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
    }
    
    void loop() { 
      // Send locally attached sensor data here 
      wait(dht.getMinimumSamplingPeriod());
    
    float temperature = dht.getTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else {
        send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
    
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else {
          send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      }
    
     Serial.print("Dallas: ");
     Serial.println(bureauds);
     Serial.print("Therm: ");
     Serial.println(bureautherm);
     Serial.print("tempDHT: ");
     Serial.println(tempdht);
     Serial.print("HRDHT: ");
     Serial.println(hrdht);
    
      // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
      //sleep(SLEEP_TIME);
      wait(SLEEP_TIME);
        
    }
    
    
    void receive(const MyMessage &message) {
      Serial.print("received something: ");
      Serial.println(message.sender, message.sensor);
      
      switch (message.sender) {
            case BUREAU_NODE_ID:
                 switch (message.sensor){
                       case DS18B20:
                             bureauds = message.getFloat();
                      break; 
                      case THERM:
                             bureautherm = message.getFloat();
                      break;
              } 
              break; 
         case GW_NODE_ID:
                 switch (message.sensor){
                      case TEMP_DHT:
                             tempdht = message.getFloat();
                      break; 
                      case HRD_HT:
                             hrdht = message.getFloat();
                      break; 
            } 
             break; 
      }
     Serial.print("Dallas: ");
     Serial.println(bureauds);
     Serial.print("Therm: ");
     Serial.println(bureautherm);
     Serial.print("tempDHT: ");
     Serial.println(tempdht);
     Serial.print("HRDHT: ");
     Serial.println(hrdht);
       
    }
    
    

    abstract from serial output when a message is received from node 1, with sensors 0 and 17 :
    0;255;3;0;9;TSP:SANCHK:OK
    0;11;1;0;0;25.4
    T: 25.40
    0;10;1;0;1;50.3
    H: 50.30
    Dallas: 0.00
    Therm: 0.00
    tempDHT: 0.00
    HRDHT: 0.00
    0;255;3;0;9;TSP:MSG:READ 1-1-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.5
    1;0;1;0;0;24.5
    0;255;3;0;9;TSP:MSG:READ 1-1-0 s=17,c=1,t=0,pt=7,l=5,sg=0:24.6
    1;17;1;0;0;24.6
    0;255;3;0;9;TSP:MSG:READ 1-1-0 s=255,c=3,t=0,pt=1,l=1,sg=0:94
    1;255;3;0;0;94
    0;255;3;0;9;TSP:MSG:READ 1-1-0 s=20,c=1,t=38,pt=7,l=5,sg=0:3.8
    1;20;1;0;38;3.8
    0;11;1;0;0;25.3
    T: 25.30
    0;10;1;0;1;50.2
    H: 50.20
    Dallas: 0.00
    Therm: 0.00
    tempDHT: 0.00
    HRDHT: 0.00
    0;11;1;0;0;25.3
    T: 25.30
    0;10;1;0;1;50.2
    H: 50.20
    Dallas: 0.00
    Therm: 0.00
    tempDHT: 0.00
    HRDHT: 0.00

    Thanks, Nicolas

    mfalkviddM 1 Reply Last reply
    0
    • npiotN npiot

      Hi,
      working on my sensors v2, IDE arduino 1.6.7
      The sketch is working OK, and connects to my jeedom controller no problem.
      I want to use the data received from node directly on my gateway to process it (jeedom is just here to record the data over time).

      on my serial gateway sketch, I added a void receive( const Mymessage &message) {} fonction, and it seems the sketch is never going there, even when messages are received, as I can see in my serial console.

      Any idea someone? Any help much appreciated.

      
      // 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
      
      // Flash leds on rx/tx/err
      #define MY_LEDS_BLINKING_FEATURE
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Inverses the behavior of leds
      //#define MY_WITH_LEDS_BLINKING_INVERSE
      
      // 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 
      
      // 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 <SPI.h>
      #include <MySensors.h>  
      #include <DHT.h>
      
      #define CHILD_ID_HUM 10
      #define CHILD_ID_TEMP 11
      #define HUMIDITY_SENSOR_DIGITAL_PIN 4  //data pin pour DHT
      
      #define BUREAU_NODE_ID 1
      #define GW_NODE_ID 0
      #define DS18B20 0
      #define THERM 17
      #define TEMP_DHT 11
      #define HRD_HT 10
      
      float bureauds = 0, bureautherm =0, tempdht = 0, hrdht =0;
      
      unsigned long SLEEP_TIME = 10000; // Sleep time between reads (in milliseconds)
      
      DHT dht;
      //float lastTemp;
      //float lastHum;
      boolean metric = true; 
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      void setup() { 
        // Setup locally attached sensors
        Serial.begin(115200);
        Serial.println();
        Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)");
      
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      }
      
      void presentation() {
        sendSketchInfo("GW Humidity/Temp", "1.0");
       // Present locally attached sensors 
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      }
      
      void loop() { 
        // Send locally attached sensor data here 
        wait(dht.getMinimumSamplingPeriod());
      
      float temperature = dht.getTemperature();
        if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
        } else {
          send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
        }
      
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else {
            send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
      
       Serial.print("Dallas: ");
       Serial.println(bureauds);
       Serial.print("Therm: ");
       Serial.println(bureautherm);
       Serial.print("tempDHT: ");
       Serial.println(tempdht);
       Serial.print("HRDHT: ");
       Serial.println(hrdht);
      
        // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
        //sleep(SLEEP_TIME);
        wait(SLEEP_TIME);
          
      }
      
      
      void receive(const MyMessage &message) {
        Serial.print("received something: ");
        Serial.println(message.sender, message.sensor);
        
        switch (message.sender) {
              case BUREAU_NODE_ID:
                   switch (message.sensor){
                         case DS18B20:
                               bureauds = message.getFloat();
                        break; 
                        case THERM:
                               bureautherm = message.getFloat();
                        break;
                } 
                break; 
           case GW_NODE_ID:
                   switch (message.sensor){
                        case TEMP_DHT:
                               tempdht = message.getFloat();
                        break; 
                        case HRD_HT:
                               hrdht = message.getFloat();
                        break; 
              } 
               break; 
        }
       Serial.print("Dallas: ");
       Serial.println(bureauds);
       Serial.print("Therm: ");
       Serial.println(bureautherm);
       Serial.print("tempDHT: ");
       Serial.println(tempdht);
       Serial.print("HRDHT: ");
       Serial.println(hrdht);
         
      }
      
      

      abstract from serial output when a message is received from node 1, with sensors 0 and 17 :
      0;255;3;0;9;TSP:SANCHK:OK
      0;11;1;0;0;25.4
      T: 25.40
      0;10;1;0;1;50.3
      H: 50.30
      Dallas: 0.00
      Therm: 0.00
      tempDHT: 0.00
      HRDHT: 0.00
      0;255;3;0;9;TSP:MSG:READ 1-1-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.5
      1;0;1;0;0;24.5
      0;255;3;0;9;TSP:MSG:READ 1-1-0 s=17,c=1,t=0,pt=7,l=5,sg=0:24.6
      1;17;1;0;0;24.6
      0;255;3;0;9;TSP:MSG:READ 1-1-0 s=255,c=3,t=0,pt=1,l=1,sg=0:94
      1;255;3;0;0;94
      0;255;3;0;9;TSP:MSG:READ 1-1-0 s=20,c=1,t=38,pt=7,l=5,sg=0:3.8
      1;20;1;0;38;3.8
      0;11;1;0;0;25.3
      T: 25.30
      0;10;1;0;1;50.2
      H: 50.20
      Dallas: 0.00
      Therm: 0.00
      tempDHT: 0.00
      HRDHT: 0.00
      0;11;1;0;0;25.3
      T: 25.30
      0;10;1;0;1;50.2
      H: 50.20
      Dallas: 0.00
      Therm: 0.00
      tempDHT: 0.00
      HRDHT: 0.00

      Thanks, Nicolas

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2
      This post is deleted!
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      24

      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