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. Development
  3. Debug messages over Wi-Fi

Debug messages over Wi-Fi

Scheduled Pinned Locked Moved Development
7 Posts 5 Posters 1.9k Views 8 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.
  • M Offline
    M Offline
    marceloaqno
    Code Contributor
    wrote on last edited by marceloaqno
    #1

    I wrote a library to be able to watch the debug messages from a ethernet gateway over Wi-Fi (or ethernet).
    It opens port 2300, so you can connect with putty (change the "Connection type" to Telnet or Raw).

    If anyone is interested, here is the code: https://github.com/marceloaqno/MyNetDebug

    To use it, add the following lines in your sketch before MySensors.h

    #include <MyNetDebug.h>
    #define MY_SERIALDEVICE NetDebug
    

    And into your loop function:

    void loop()
    {
      (void)NetDebug.available();
      ...
    

    For more details, please check the examples.

    alexsh1A 1 Reply Last reply
    4
    • M marceloaqno

      I wrote a library to be able to watch the debug messages from a ethernet gateway over Wi-Fi (or ethernet).
      It opens port 2300, so you can connect with putty (change the "Connection type" to Telnet or Raw).

      If anyone is interested, here is the code: https://github.com/marceloaqno/MyNetDebug

      To use it, add the following lines in your sketch before MySensors.h

      #include <MyNetDebug.h>
      #define MY_SERIALDEVICE NetDebug
      

      And into your loop function:

      void loop()
      {
        (void)NetDebug.available();
        ...
      

      For more details, please check the examples.

      alexsh1A Offline
      alexsh1A Offline
      alexsh1
      wrote on last edited by
      #2

      @marceloaqno interesting. Did you try it on atmega328p only? Other MCU?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ricorico94
        wrote on last edited by
        #3

        Hi,
        Your initiative seems a bright idea, thanks for that !
        I tried your library to debug a gateway on a wemos D1 mini with Mysensors 2.3.0, but I got error messages when compiling. Maybe it's because I didn't follow proper installation of your library as I'm not friendly with Arduino IDE library system.
        I did symply download your folders from github and installed Mynetdebug-master folder in same folder than Mysensors library folder. IN the Mynetdebug folder, I have a keywords.txt file and a library.json and library.master, and a src folder where I have the .cpp and .h files.
        Is it correct ?
        I used your example for ESP8266 to modify my working gateway .ino.
        Then, when I compiled, I got following error messages:

        Arduino: 1.8.5 (Windows 7), Board: "WeMos D1 R2 & mini, 80 MHz, 115200, 4M (3M SPIFFS)"
        
        WARNING: Category 'MySensors' in library MyNetDebug is not valid. Setting to 'Uncategorized'
        In file included from d:\userdata\myname\My Documents\Arduino\libraries\MySensors/MySensors.h:212:0,
        
                         from D:\userdata\myname\My Documents\Arduino\LoraGTWperso04Mynetdebug\LoraGTWperso04Mynetdebug.ino:67:
        
        d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportInit()':
        
        d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:28:22: error: 'MY_ESP8266_SSID' was not declared in this scope
        
         #define MY_WIFI_SSID MY_ESP8266_SSID
        
                              ^
        
        d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:163:19: note: in expansion of macro 'MY_WIFI_SSID'
        
          (void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID);
        
                           ^
        
        d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:34:26: error: 'MY_ESP8266_PASSWORD' was not declared in this scope
        
         #define MY_WIFI_PASSWORD MY_ESP8266_PASSWORD
        
                                  ^
        
        d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:163:33: note: in expansion of macro 'MY_WIFI_PASSWORD'
        
          (void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID);
        
                                         ^
        
        exit status 1
        Error compiling for board WeMos D1 R2 & mini.
        
        This report would have more information with
        "Show verbose output during compilation"
        option enabled in File -> Preferences.
        
        
        

        Can you help me ?
        br,
        Ricorico94

        mfalkviddM 1 Reply Last reply
        0
        • R ricorico94

          Hi,
          Your initiative seems a bright idea, thanks for that !
          I tried your library to debug a gateway on a wemos D1 mini with Mysensors 2.3.0, but I got error messages when compiling. Maybe it's because I didn't follow proper installation of your library as I'm not friendly with Arduino IDE library system.
          I did symply download your folders from github and installed Mynetdebug-master folder in same folder than Mysensors library folder. IN the Mynetdebug folder, I have a keywords.txt file and a library.json and library.master, and a src folder where I have the .cpp and .h files.
          Is it correct ?
          I used your example for ESP8266 to modify my working gateway .ino.
          Then, when I compiled, I got following error messages:

          Arduino: 1.8.5 (Windows 7), Board: "WeMos D1 R2 & mini, 80 MHz, 115200, 4M (3M SPIFFS)"
          
          WARNING: Category 'MySensors' in library MyNetDebug is not valid. Setting to 'Uncategorized'
          In file included from d:\userdata\myname\My Documents\Arduino\libraries\MySensors/MySensors.h:212:0,
          
                           from D:\userdata\myname\My Documents\Arduino\LoraGTWperso04Mynetdebug\LoraGTWperso04Mynetdebug.ino:67:
          
          d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportInit()':
          
          d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:28:22: error: 'MY_ESP8266_SSID' was not declared in this scope
          
           #define MY_WIFI_SSID MY_ESP8266_SSID
          
                                ^
          
          d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:163:19: note: in expansion of macro 'MY_WIFI_SSID'
          
            (void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID);
          
                             ^
          
          d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:34:26: error: 'MY_ESP8266_PASSWORD' was not declared in this scope
          
           #define MY_WIFI_PASSWORD MY_ESP8266_PASSWORD
          
                                    ^
          
          d:\userdata\myname\My Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:163:33: note: in expansion of macro 'MY_WIFI_PASSWORD'
          
            (void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID);
          
                                           ^
          
          exit status 1
          Error compiling for board WeMos D1 R2 & mini.
          
          This report would have more information with
          "Show verbose output during compilation"
          option enabled in File -> Preferences.
          
          
          

          Can you help me ?
          br,
          Ricorico94

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          @ricorico94 did you define these in your sketch, before including MySensors.h?

          #define MY_ESP8266_SSID "MySSID"
          #define MY_ESP8266_PASSWORD "MyVerySecretPassword"
          
          1 Reply Last reply
          0
          • R Offline
            R Offline
            ricorico94
            wrote on last edited by
            #5

            Hi,
            Thanks for your help.
            Yes, I defined them before the Mysesnors.h.
            here's my ino (I anonymised ssid and password):

            // Application details
            #define APPLICATION_NAME    "Gateway RFM95 Eric"
            #define APPLICATION_VERSION "0.0.0.Beta Eric"
            
            // Enable debug prints to serial monitor
            #define MY_DEBUG
            
            // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
            #define MY_BAUD_RATE 115200 
            
            // Enable and select radio type attached
            #define   MY_RADIO_RFM95
            
            #define   MY_DEBUG_VERBOSE_RFM95
            //#define   MY_DEBUG_VERBOSE_RFM95_REGISTERS
            //#define MY_RFM95_ATC_TARGET_RSSI (-70)  // target RSSI -70dBm
            //#define   MY_RFM95_MAX_POWER_LEVEL_DBM (20)   // max. TX power 10dBm = 10mW
            #define   MY_RFM95_FREQUENCY (RFM95_434MHZ)
            //#define   MY_RFM95_MODEM_CONFIGRUATION (RFM95_BW500CR45SF128)
            //below was used in first successful testings then modified to try improving coverage
            //#define MY_RFM95_MODEM_CONFIGRUATION RFM95_BW125CR45SF128
            #define MY_RFM95_MODEM_CONFIGRUATIONRFM95_BW125CR48SF4096
            #define MY_TRANSPORT_STATE_TIMEOUT_MS  (3*1000ul)
            #define RFM95_RETRY_TIMEOUT_MS  (3000ul) 
            
            #define   MY_RFM95_IRQ_PIN 5
            #define   MY_RFM95_IRQ_NUM MY_RFM95_IRQ_PIN
            #define   MY_RFM95_CS_PIN 15
            
            
            #define MY_GATEWAY_ESP8266
            
            
            // Set WIFI SSID and password
            #define MY_ESP8266_SSID "nameofmywifi"
            #define MY_ESP8266_PASSWORD "mypassword"
            
            #define MY_HOSTNAME "lora-gateway"
            
            #define MY_PORT 5003
            
            //added for MyNetdebug
            // How many clients should be able to connect to this gateway (default 1)
            #define MY_GATEWAY_MAX_CLIENTS 2
            
            #if defined(MY_USE_UDP)
            #include <WiFiUdp.h>
            #endif
            // end added for Mynetdebug
            
            #include <ESP8266WiFi.h>
            
            //added for Mynetdebug
            #include <MyNetDebug.h>
            #define MY_SERIALDEVICE NetDebug
            // end added
            
            #include <MySensors.h>
            
            void setup()
            {
              //all block below added for Mynetdebug
            
                 // Echo all data sent by the debug client
              NetDebug.echo(true);
              // Send a carriage return before each line feed
              NetDebug.crBeforeLF(true);
              // If you want the debug message to also be sent to Serial port
              NetDebug.mirror(&Serial);
              // Initialize the serial port if you plan to use it in your sketch or if you are using the mirror function
              // MySensors usually does this for us, however, since we've set up our serial device to be NetDebug,
              // we have to do it ourselves
              Serial.begin(MY_BAUD_RATE);
            
              // end added Mynetdebug
                // Setup locally attached sensors
            }
            
            void presentation()
            {
                // Present locally attached sensors here
              sendSketchInfo(APPLICATION_NAME, APPLICATION_VERSION);
            
            }
            
            void loop()
            {
              //added for Mynetdebug
               (void)NetDebug.available();
            // end added for Mynetdebug
                
                // Send locally attached sensors data here
            
            
            }
            

            For your info, before I make these changes, it was compiling OK. My changes are embedded within the comments "added for Mynetdebug".
            In IDE, I use the setting wemos D1R2 & mini, 80MHz and "4M(3M SPIFFS)".
            Maybe I installed the library i a wrong manner ? Shoudl I move the .h and .cpp one level up in folders ?

            Thanks,

            1 Reply Last reply
            0
            • R Offline
              R Offline
              ricorico94
              wrote on last edited by ricorico94
              #6

              Hi,
              I found the cause of the error..
              Since 2.3.0, we shouldn't write anymore:

              #define MY_ESP8266_SSID "MySSID"
              #define MY_ESP8266_PASSWORD "MyVerySecretPassword"
              

              but:

              #define MY_WIFI_SSID "MySSID"
              #define MY_WIFI_PASSWORD "MyVerySecretPassword"
              

              I found because I discovered than compiling was OK with 2.2.0 and not anymore with 2.3.0 (even without the MyNetDebug library) and I looked at the example in the 2.3.0 library..
              I had been misleaded by the fact than in release description, it was stated that 2.3 is backward compatible and that network had not to be modified.. So I had thought that no change was required in the sketch..

              I could test the library MyNetDebug and it seems working: the only thing is that it seems slow. Letters show up one after the other fairly slowly (much more slowly than if Serial Monitor used alone). I hope it's not disturbing radio communication..
              But it's great to be able to catch debug messages without plugging the ESP8266 in a computer ! I'll have to investigate if the debug status can be switched on/off by a remote command to the ESP8266 gateway to avoid overloading the device if not necessary.

              Thanks again for your efforts!

              1 Reply Last reply
              1
              • electrikE Offline
                electrikE Offline
                electrik
                wrote on last edited by
                #7

                Hello
                I've tried to use this with an ESP32 (I modified some defines for the architecture, to make it compatible). In MyHwESP32.h I've changed

                #define MY_SERIALDEVICE Serial
                

                to

                #ifndef MY_SERIALDEVICE
                  #define MY_SERIALDEVICE Serial
                #endif
                

                I think this why it doesn't work for you @ricorico94 with version 2.3 of MySensors.

                It worked sometimes, but usually Putty responds "Network error: Connection refused"

                Any ideas?

                1 Reply Last reply
                1
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                23

                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