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. Controllers
  3. MQTT controller - ping but Connection timeout on MQTT clients

MQTT controller - ping but Connection timeout on MQTT clients

Scheduled Pinned Locked Moved Controllers
portnetworkingnrf24l01+mqttnrf24l01
17 Posts 6 Posters 11.3k Views 4 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.
  • JohnJ Offline
    JohnJ Offline
    John
    Plugin Developer
    wrote on last edited by
    #2

    As far as i also know there is no register needed because it broadcasts to any connected client. But trying to do so on "MyMQTT/#" (which is the prefix, without trailing /) would do no harm.

    My Domotica project: http://www.pidome.org

    1 Reply Last reply
    0
    • caycoC Offline
      caycoC Offline
      cayco
      wrote on last edited by cayco
      #3

      Thanks for the answer but it's not the point - mosquitto_sub doesn't even connect to the server (Connection timed out).

      How can I send you more data? I tried to println to serial:

      int main(void) {
      	init();
      	Ethernet.begin(TCP_MAC, TCP_IP);
          Serial.println("Ether initialized");
      	delay(1000);   // Wait for Ethernet to get configured.
      	gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
      	Serial.println("GW started");
      

      but it does not print anything besides some machine characters (ÿûï). If I add Serial.begin(9600); just after init I got "Ether initialized" but no GW started message.

      Putting Serial.println in MyMQTT.cp after first line in this procedure doesn't print anything:

      void MyMQTT::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate, void (*inDataCallback)
      		(const char *, uint8_t *), uint8_t _rx, uint8_t _tx, uint8_t _er) {
      	Serial.begin(BAUD_RATE);
      	Serial.println("Beginning GW begin");
      	repeaterMode = true;
      	isGateway = true;
      	MQTTClientConnected = false;
      

      I got:

      Ether initialized
      \Ú
      
      JohnJ 1 Reply Last reply
      0
      • caycoC cayco

        Thanks for the answer but it's not the point - mosquitto_sub doesn't even connect to the server (Connection timed out).

        How can I send you more data? I tried to println to serial:

        int main(void) {
        	init();
        	Ethernet.begin(TCP_MAC, TCP_IP);
            Serial.println("Ether initialized");
        	delay(1000);   // Wait for Ethernet to get configured.
        	gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
        	Serial.println("GW started");
        

        but it does not print anything besides some machine characters (ÿûï). If I add Serial.begin(9600); just after init I got "Ether initialized" but no GW started message.

        Putting Serial.println in MyMQTT.cp after first line in this procedure doesn't print anything:

        void MyMQTT::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate, void (*inDataCallback)
        		(const char *, uint8_t *), uint8_t _rx, uint8_t _tx, uint8_t _er) {
        	Serial.begin(BAUD_RATE);
        	Serial.println("Beginning GW begin");
        	repeaterMode = true;
        	isGateway = true;
        	MQTTClientConnected = false;
        

        I got:

        Ether initialized
        \Ú
        
        JohnJ Offline
        JohnJ Offline
        John
        Plugin Developer
        wrote on last edited by John
        #4

        @cayco

        As the documentation states:

        define TCPDUMP and connect serial interface if you have problems, please write on
        http://forum.mysensors.org/ and explain your problem, include serial output. Don't forget to
        turn on DEBUG in libraries\MySensors\MyConfig.h also.
        

        Have you tried this part (define tcpdump and uncomment debug)?

        [EDIT] yes you did, sorry for not correct reading[/EDIT]

        My Domotica project: http://www.pidome.org

        1 Reply Last reply
        0
        • gaduG Offline
          gaduG Offline
          gadu
          wrote on last edited by
          #5

          @cayco Have you tried ntruchsess gateway sketch? Worked fine for me.

          https://github.com/ntruchsess/MySensors/tree/mqttclient/libraries/MySensors/examples/MQTTClientGateway

          1 Reply Last reply
          0
          • caycoC Offline
            caycoC Offline
            cayco
            wrote on last edited by cayco
            #6

            I can't compile this... After applying the patch I got some new error. @gadu Could you possibly share source files and version of your Arduino IDE?

            	  This report would have more information with
            	  "Show verbose output during compilation"
            	  enabled in File > Preferences.
            	Arduino: 1.0.6 (Mac OS X), Board: "Arduino Uno"
            	MyMQTTClient.cpp.o: In function `MyMQTTClient::SendMQTT(MyMessage&)':
            	MyMQTTClient.cpp:275: undefined reference to `MySensor::loadState(unsigned char)'
            	MyMQTTClient.cpp:280: undefined reference to `MySensor::saveState(unsigned char, unsigned char)'
            	MyMQTTClient.cpp:294: undefined reference to `MySensor::loadState(unsigned char)'
            	MyMQTTClient.cpp:300: undefined reference to `MySensor::sendRoute(MyMessage&)'
            	MyMQTTClient.cpp.o: In function `MyMQTTClient::processMQTTMessage(char*, unsigned char*, unsigned int)':
            	MyMQTTClient.cpp:246: undefined reference to `MySensor::sendRoute(MyMessage&)'
            	MyMQTTClient.cpp.o: In function `MyMQTTClient::processRadioMessage()':
            	MyMQTTClient.cpp:176: undefined reference to `MySensor::process()'
            	MyMQTTClient.cpp:179: undefined reference to `MySensor::getLastMessage()'
            	MyMQTTClient.cpp.o: In function `MyMQTTClient::begin(rf24_pa_dbm_e, unsigned char, rf24_datarate_e, unsigned char, 	unsigned char, unsigned char)':
            	MyMQTTClient.cpp:147: undefined reference to `MySensor::setupRepeaterMode()'
            	MyMQTTClient.cpp:153: undefined reference to `MySensor::setupRadio(rf24_pa_dbm_e, unsigned char, rf24_datarate_e)'
            	MyMQTTClient.cpp.o: In function `MyMQTTClient':
            	MyMQTTClient.cpp:107: undefined reference to `MySensor::MySensor(unsigned char, unsigned char)'
            
            1 Reply Last reply
            0
            • gaduG Offline
              gaduG Offline
              gadu
              wrote on last edited by
              #7

              I'm pretty far from my computer today and tomorrow,but I'll check.
              I have the latest IDE at least.

              Meanwhile perhaps @ntruchsess himself can help? :)

              1 Reply Last reply
              0
              • caycoC Offline
                caycoC Offline
                cayco
                wrote on last edited by
                #8

                Last night I downloaded whole https://github.com/ntruchsess/MySensors/tree/mqttclient branch and tried to compile it - I got errors that ntruchsess supposed to fix in this branch (https://github.com/knolleary/pubsubclient/pull/47). Which is weird, I suspect some problems with my IDE... I will look into this today.

                1 Reply Last reply
                0
                • gaduG Offline
                  gaduG Offline
                  gadu
                  wrote on last edited by
                  #9

                  I use the latest 1.0.6 IDE on Win7 and loaded the latest MySensor libraries
                  https://github.com/mysensors/Arduino/
                  Added the attached libraries and they compiled just fine for me...

                  MyMQTTGateway.zip
                  Note1: Included is MyMQTTGateway and Pubsubclient.

                  Note2: This will make the gateway act as a MQTT client so you need Mosquitto (or similar) where you publish the topics from the gateway.

                  Note3: Remember to change the IP and Mac.

                  1 Reply Last reply
                  1
                  • caycoC Offline
                    caycoC Offline
                    cayco
                    wrote on last edited by
                    #10

                    @gadu - thank you very much!

                    In the meanwhile I managed to compile on @ntruchsess code. I got past compiler error and also I noticed that my baund rater for serial monitor was incorrect (so I couldn't see anything usefull). Anyway I got this:

                    0;0;3;0;9;check wires

                    On all controllers: MQTTGateway, Ethernet gateway, Serial... I checked those wires many times, even I switched the radio. No luck. Then I noticed that I bought NRF24L01 - the verison withot + at the and. It should be NRF24L01+

                    Does it matter? I found that NRF24L01+ it differs only slightly from NRF24L01 version but I think that might be the casue. Anyone had such experience? It's hard to search for it on the forum since everyone is writing about NRF24L01+ only...

                    B 1 Reply Last reply
                    0
                    • caycoC cayco

                      @gadu - thank you very much!

                      In the meanwhile I managed to compile on @ntruchsess code. I got past compiler error and also I noticed that my baund rater for serial monitor was incorrect (so I couldn't see anything usefull). Anyway I got this:

                      0;0;3;0;9;check wires

                      On all controllers: MQTTGateway, Ethernet gateway, Serial... I checked those wires many times, even I switched the radio. No luck. Then I noticed that I bought NRF24L01 - the verison withot + at the and. It should be NRF24L01+

                      Does it matter? I found that NRF24L01+ it differs only slightly from NRF24L01 version but I think that might be the casue. Anyone had such experience? It's hard to search for it on the forum since everyone is writing about NRF24L01+ only...

                      B Offline
                      B Offline
                      boozz
                      wrote on last edited by
                      #11

                      @cayco
                      Yes, the non-plus variant is pretty useless. You can make it work (select 1MBPS instead of 250 kbps), but the price you have to pay is the distance you can maintain between sensor nodes, repeater(s) and gateway.
                      I personally invested many hours to get it working, but was very disappointed with the distance.
                      I bought new radio's (nrf24l01+) and found out that I wasted my time 😔

                      Succes!

                      Boozz

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        Gambituk
                        wrote on last edited by
                        #12

                        Just a THANK YOU for @gadu, the info above was exactly what i was looking for. Now i can continue with the rest of my project!! :+1:

                        1 Reply Last reply
                        0
                        • gaduG Offline
                          gaduG Offline
                          gadu
                          wrote on last edited by
                          #13

                          glad to help!

                          1 Reply Last reply
                          0
                          • caycoC Offline
                            caycoC Offline
                            cayco
                            wrote on last edited by
                            #14

                            I also managed to get it working! Besides non '+' radio I did not have SoftSPI enabled. I thought that I do not need it since I have a Ethernet Shield version. After enabling MQTT Gateway and MQTT ClientGateway started.

                            Now it's time for some soldering to make a client :)

                            1 Reply Last reply
                            0
                            • gaduG Offline
                              gaduG Offline
                              gadu
                              wrote on last edited by
                              #15

                              great!

                              My working setup is
                              Sensors -> ETH MQTT ClientGateway -> Mosquitto -> OpenHAB

                              Capture.PNG

                              (sorry for the swedish)

                              1 Reply Last reply
                              0
                              • T Offline
                                T Offline
                                TommySharp
                                wrote on last edited by
                                #16

                                @gadu

                                When I try your files I get this error when compiling...

                                Any ideas? I'm using the Arduino 1.6.3 application.

                                In file included from C:\Users\Tommy\Documents\Arduino\libraries\MyMQTTClient/MyMQTTClient.h:16:0,
                                from MyMQTTClient.ino:46:
                                C:\Users\Tommy\Documents\Arduino\libraries\MyMQTTClient/PubSubClient.h:72:46: error: section attribute not allowed for '<anonymous>'
                                boolean publish_P(char *, uint8_t PROGMEM *, unsigned int, boolean);

                                1 Reply Last reply
                                0
                                • gaduG Offline
                                  gaduG Offline
                                  gadu
                                  wrote on last edited by
                                  #17

                                  @TommySharp
                                  Hmm dont really remember, but I think this was the solution
                                  https://github.com/knolleary/pubsubclient/issues/46

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


                                  19

                                  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