Correct Usage of MY_DEBUGDEVICE



  • Maybe I am missing the obvious, but I do not get along with the use of MY_DEBUGDEVICE.
    My Arduino Sketch on a Pro Mini looks as follows:

    #define MY_DEBUG 
    #define MY_DISABLED_SERIAL    // I want to use the hardware serial myself
    #define MY_SPLASH_SCREEN_DISABLED   // as per some forum post 
    // #define MY_BAUD_RATE 75   // unclear to what device it refers, assuming HW serial
    
    // Setting up SoftwareSerial. 
    // For Pro Mini (AtMega 328P) all pins are allowed
    // TX pin is onboard LED, so I should see it flicker on transmit.
    int Soft_TX = 3;      // Port D3
    int Soft_RX = 5;      // Port D5, only needed for init
    #include <SoftwareSerial.h> 
    SoftwareSerial mySerial(Soft_RX, Soft_TX);
    
    // Switch debug output for MySensors
    #define MY_DEBUGDEVICE mySerial;
    #include <MySensors.h>
    
    void setup()  
    {  
    }
    
    void loop() 
    {
      mySerial.begin(75);
      mySerial.print("always visible"); 
    
      #ifdef MY_DEBUG
       mySerial.print("only visible with DEBUG flag");
      #endif
    
     }
    

    Result: The onboard LED on Port D3 lights constantly.
    If I connect a serial-to-USB converter and watch the output on a terminal, I see no text.

    If I remove all references to MySensors, i.e. only initialize SoftSerial, the LED is flickering as expected.
    So far I conclude I am using the re-definition of MY_DISABLED_SERIAL and MY_DEBUGDEVICE incorrectly.



  • MY_DISABLED_SERIAL wil output nothing on the serial, no matter software or hardware serial. So in your case you don't need to define it.
    And try removing the semicolon after

    #define MY_DEBUGDEVICE mySerial;
    


  • Thank you! Now I can see my debug message on SoftSerial.



  • @TheOtherMatt All pro minis I have seen have led on D13 and not D3 (unless you have cut tracks and re-routed it).

    If the D13 led is on constantly it is probably because you have not given mysensors any clue about radios attached and it is trying to initialise a non-existant radio module.

    Add to your code the radio setup you will use and connect your radio to it correctly as I suspect it is just looping trying to get a response.

    Also, I always put a wait(100); after every send to allow the power line to settle and the capacitor to recharge.



  • Yes, I had to state a radio definition too. I now see my soft serial prints as well as the debug transport layer messages to the (not yet connected) radio. All is as expected now. Now I can hook up the hardware serial to my periphery and build my node 🙂



  • @skywatch Ah, and you are right about the LED. I re-designed the circuitry a while ago to accommodate a RFM69 on the PCB back side, and meanwhile forgot the fact that my LED is now connected to Atmega328‘s port D3 now. For the serial function test it does not make a difference, however.


Log in to reply
 

Suggested Topics

  • 7
  • 1
  • 9
  • 9
  • 2
  • 7
  • 14
  • 7

147
Online

10.3k
Users

10.7k
Topics

109.8k
Posts