[SOLVED] No Serial prints for loop(), using MySensors 2.1.1



  • Hi,

    I'm getting all the debug messages if I define #MY_DEBUG, but none of my Serial prints in the loop functions are shown.
    However, Serial prints in the receive function are shown.

    Example sketch:

    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Enable repeater functionality for this node
    #define MY_REPEATER_FEATURE
    
    #define MY_NODE_ID 20
    
    #include <MySensors.h>
    
    #define RELAY_1  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    
    void before()
    {
    	for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
    		// Then set relay pins in output mode
    		pinMode(pin, OUTPUT);
    		// Set relay to last known state (using eeprom storage)
    		digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
    	}
    }
    
    void setup()
    {
    
    }
    
    void presentation()
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("Relay", "1.0");
    
    	for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
    		// Register all sensors to gw (they will be created as child devices)
    		present(sensor, S_BINARY);
    	}
    }
    
    
    void loop()
    {
      Serial.println("This doesn't print :(");
      delay(1000);
      
    }
    
    void receive(const MyMessage &message)
    {
    	// We only expect one type of message from controller. But we better check anyway.
    	if (message.type==V_STATUS) {
    		Serial.println("This does print!");
    	}
    }
    

    It would be really nice if someone could help me with this problem.



  • I found the problem, but not the solution.

    First, I added #define MY_TRANSPORT_WAIT_READY_MS 1 to the sketch.
    Now the loop()-Function gets executed.
    Problem: My node isn't registered by the gateway:

    New Motion State: 1
    80949 !MCO:SND:NODE NOT REG
    81582 TSF:MSG:READ,0-0-20,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    81588 TSF:MSG:FPAR OK,ID=0,D=1
    82950 TSM:FPAR:OK
    82952 TSM:ID
    82952 TSM:ID:OK
    82954 TSM:UPL
    82958 TSF:MSG:SEND,20-20-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    84967 TSM:UPL
    84969 TSF:MSG:SEND,20-20-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 
    

    âž¡ My Gateway is running on an old version of MySensors, I believe it's 1.5.4
    Do I have to update the gateway? I thought I could leave it at 1.5.4.


  • Hero Member

    I think that 1.5.x GW does not work with 2.x nodes but 2.x GW works with 1.5.x nodes.
    Please update your GW 😉



  • @korttoma thanks! It works now. 🙂
    Could have saved me hours of troubleshooting if I knew that prior 😕


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 1
  • 5
  • 6
  • 1

69
Online

11.4k
Users

11.1k
Topics

112.7k
Posts