MQTT controller - ping but Connection timeout on MQTT clients



  • Hi!

    I am having problems with setting MQTTEthernet Controller (using stock MQTTGateway.ino). I have Arduino Uno with Ethernet shield (I've also attached radion but I'm not using it now). I changed MAC, IP addresss and uploaded to the board. It starts and I am able to ping it:

    pi@raspberrypi ~ $ ping 10.0.0.150
    PING 10.0.0.150 (10.0.0.150) 56(84) bytes of data.
    64 bytes from 10.0.0.150: icmp_req=1 ttl=128 time=0.515 ms
    64 bytes from 10.0.0.150: icmp_req=2 ttl=128 time=0.508 ms
    ^C
    --- 10.0.0.150 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1001ms
    rtt min/avg/max/mdev = 0.508/0.511/0.515/0.022 ms

    but clients are having trouble communicating:

    pi@raspberrypi ~ $ mosquitto_sub -h 10.0.0.150 -t '#'
    Error: Connection timed out
    pi@raspberrypi ~ $ mosquitto_pub -h 10.0.0.150 -p 1883 -m "test" -t "/MyMQTT/20/1"
    Error: Connection timed out

    Scanning on port 1883 reveals nothing (port closed).

    What could be the cause? How can I debug this?

    P.S. Debugging on serial shows that is stopps on
    gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);

    commenting this line and also additionaly
    gw.processRadioMessage();

    doesn't make it respond to mqtt clients...


  • Plugin Developer

    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.



  • 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
    \Ú

  • Plugin Developer

    @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]





  • 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)'


  • 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? 🙂



  • 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.



  • 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.



  • @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...



  • @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



  • 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!! 👍



  • glad to help!



  • 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 🙂



  • great!

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

    Capture.PNG

    (sorry for the swedish)



  • @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);



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



Suggested Topics

  • 2
  • 13
  • 12
  • 10
  • 21
  • 3
  • 3
  • 56

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts