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. Troubleshooting
  3. Publish --> MQTT Gateway very slow

Publish --> MQTT Gateway very slow

Scheduled Pinned Locked Moved Troubleshooting
8 Posts 2 Posters 4.2k Views 1 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
    mickaelh51
    wrote on last edited by
    #1

    Hi,
    I wrote an issue on github: https://github.com/mysensors/Arduino/issues/309
    Do you have an idea please ?

    thanks in advance

    Controller: OpenVZ :: OpenHab 1.8.0 :: MQTT Broker
    Gateway: Arduino UNO :: W5100 :: MQTTClient
    Software: MySensors 1.6beta

    R 1 Reply Last reply
    0
    • M mickaelh51

      Hi,
      I wrote an issue on github: https://github.com/mysensors/Arduino/issues/309
      Do you have an idea please ?

      thanks in advance

      R Offline
      R Offline
      robosensor
      wrote on last edited by
      #2

      @mickaelh51 can you check speed of _ethernetServer.write(_ethernetMsg); call using the same debug code as for esp8266 gateway code here: http://forum.mysensors.org/topic/1870/esp8266-wifi-gateway-port-for-mysensors/225 ?

      Something like this:

              // Send message to connected clients
              #if defined(MY_GATEWAY_ESP8266)
                  for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++)
                  {
                      if (clients[i] && clients[i].connected())
                      {
                          clients[i].write((uint8_t*)_ethernetMsg, strlen(_ethernetMsg));
                      }
                  }
              #else
                  unsigned long start_time = hwMillis();
                  _ethernetServer.write(_ethernetMsg);
                  debug(PSTR("Ethernet transaction time: %u ms\n"), hwMillis() - start_time);
              #endif
      

      File to patch is libraries\MySensors\Core\MyGatewayTransportEthernet.cpp

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mickaelh51
        wrote on last edited by mickaelh51
        #3

        Hi,
        thanks for your answer @robosensor .
        But, I'm sorry, I don't know where add the patch in file :(

        I patched MyGatewayTransportEthernet.cpp with your code, but I don't use ESP8266. I use W5100 + NRF24L01.
        I patched in MY_CONTROLLER_IP_ADDRESS too => no result (not debug in serial monitor)
        For me, when W5100 receive MQTT messages there is a reception problem (because MQTT server send several times the same MQTT message.
        Can you help me to write patch please ;) ?

        thanks in advance

        FYI

        STATUS		0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
        RX_ADDR_P0-1	0x00003B3F00 00003B3F0E 
        RX_ADDR_P2-5	0xFF C4 C5 C6 
        TX_ADDR		0x00003B3F00 
        RX_PW_P0-6	0x20 20 20 00 00 00 
        EN_AA		0x3B 
        EN_RXADDR	0x06 
        RF_CH		0x4C 
        RF_SETUP	0x07 
        CONFIG		0x0E 
        DYNPD/FEATURE	0x3F 06 
        Data Rate	1MBPS
        Model		nRF24L01+
        CRC Length	16 bits
        PA Power	PA_MAX
        

        Controller: OpenVZ :: OpenHab 1.8.0 :: MQTT Broker
        Gateway: Arduino UNO :: W5100 :: MQTTClient
        Software: MySensors 1.6beta

        R 1 Reply Last reply
        0
        • M mickaelh51

          Hi,
          thanks for your answer @robosensor .
          But, I'm sorry, I don't know where add the patch in file :(

          I patched MyGatewayTransportEthernet.cpp with your code, but I don't use ESP8266. I use W5100 + NRF24L01.
          I patched in MY_CONTROLLER_IP_ADDRESS too => no result (not debug in serial monitor)
          For me, when W5100 receive MQTT messages there is a reception problem (because MQTT server send several times the same MQTT message.
          Can you help me to write patch please ;) ?

          thanks in advance

          FYI

          STATUS		0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
          RX_ADDR_P0-1	0x00003B3F00 00003B3F0E 
          RX_ADDR_P2-5	0xFF C4 C5 C6 
          TX_ADDR		0x00003B3F00 
          RX_PW_P0-6	0x20 20 20 00 00 00 
          EN_AA		0x3B 
          EN_RXADDR	0x06 
          RF_CH		0x4C 
          RF_SETUP	0x07 
          CONFIG		0x0E 
          DYNPD/FEATURE	0x3F 06 
          Data Rate	1MBPS
          Model		nRF24L01+
          CRC Length	16 bits
          PA Power	PA_MAX
          
          R Offline
          R Offline
          robosensor
          wrote on last edited by
          #4

          @mickaelh51 I'm sorry, MQTT gateway is slightly different.

          Please replace function in file MyGatewayTransportMQTTClient.cpp

          bool gatewayTransportSend(MyMessage &message) {
          	if (!_client.connected())
          		return false;
          	snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR(MY_MQTT_PUBLISH_TOPIC_PREFIX "/%d/%d/%d/%d/%d"), message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type);
          	debug(PSTR("Sending message on topic: %s\n"), _fmtBuffer);
          	return _client.publish(_fmtBuffer, message.getString(_convBuffer));
          }
          

          With something like this:

          bool gatewayTransportSend(MyMessage &message) {
          	if (!_client.connected())
          		return false;
          	snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR(MY_MQTT_PUBLISH_TOPIC_PREFIX "/%d/%d/%d/%d/%d"), message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type);
          	debug(PSTR("Sending message on topic: %s\n"), _fmtBuffer);
          
          	unsigned long start_time = hwMillis();
          	bool bReturnValue = _client.publish(_fmtBuffer, message.getString(_convBuffer));
          	debug(PSTR("Ethernet transaction time: %u ms\n"), hwMillis() - start_time);
          	return bReturnValue;
          }
          

          I just want to know speed of _client.publish() call, but I don't have W5100.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mickaelh51
            wrote on last edited by mickaelh51
            #5

            the results @robosensor :

            0;0;3;0;9;read: 9-9-0 s=3,c=0,t=3,pt=0,l=0,sg=0:
            0;0;3;0;9;Sending message on topic: mygateway1-out/9/3/0/0/3
            0;0;3;0;9;Ethernet transaction time: 1 ms
            

            1 ms for all received messages. indeed when sensor send temp + humidity from DHT11, the messages the messages arrive quickly to OpenHAB.
            But when I send MQTT message from OpenHAB to Gateway, it's very long (https://youtu.be/zQxLzGmCKlY).

            Controller: OpenVZ :: OpenHab 1.8.0 :: MQTT Broker
            Gateway: Arduino UNO :: W5100 :: MQTTClient
            Software: MySensors 1.6beta

            R 1 Reply Last reply
            0
            • M mickaelh51

              the results @robosensor :

              0;0;3;0;9;read: 9-9-0 s=3,c=0,t=3,pt=0,l=0,sg=0:
              0;0;3;0;9;Sending message on topic: mygateway1-out/9/3/0/0/3
              0;0;3;0;9;Ethernet transaction time: 1 ms
              

              1 ms for all received messages. indeed when sensor send temp + humidity from DHT11, the messages the messages arrive quickly to OpenHAB.
              But when I send MQTT message from OpenHAB to Gateway, it's very long (https://youtu.be/zQxLzGmCKlY).

              R Offline
              R Offline
              robosensor
              wrote on last edited by
              #6

              @mickaelh51 thank you very much for test results! Where is openhab located? Raspberry Pi? Or PC?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mickaelh51
                wrote on last edited by mickaelh51
                #7

                @robosensor openhab is located on a proxmox server (it's a container).
                Openhab server: 172.16.13.237/24 --> MQTTGateway: 172.16.13.145/24
                I have many others sensors on arduino that are using MQTT directly (Not mysensors Framework) and they're ok and fast ;)
                I think, the MQTT gateway is very slow at some moments and it don't process MQTT messages received (as you can see in my youtube video).
                but at some others moments it can process this messages

                For your information, MQTT message is slow before incomingMQTT

                void incomingMQTT(char* topic, byte* payload,
                                        unsigned int length)
                {
                debug(PSTR("Message arrived on topic: %s\n"), topic);
                

                Because when I send MQTT message with OpenHAB or MQTT.fx to mosquitto, it's send immediatly this message.
                After X seconds I can see in serial monitor log: "Message arrived...."

                Have you an idea ?

                thanks a lot !

                Controller: OpenVZ :: OpenHab 1.8.0 :: MQTT Broker
                Gateway: Arduino UNO :: W5100 :: MQTTClient
                Software: MySensors 1.6beta

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mickaelh51
                  wrote on last edited by
                  #8

                  HAAAAAAAAAAAAAAAAAA !!!!!! pffffffffffff !!!!
                  so noob I am :(

                  it's work now !

                  I have a lot of arduino in my network, and there are diffrent MAc address => normal !
                  But in arduino with my sensor there wasn't MY_MAC_ADDRESS defined.
                  and... two arduino with the same MAC (default MAC) ... pffff ==> doesn't work fine!!!!

                  now it's work perfectly ! I'm sorry for you waste time !

                  thanks !

                  Controller: OpenVZ :: OpenHab 1.8.0 :: MQTT Broker
                  Gateway: Arduino UNO :: W5100 :: MQTTClient
                  Software: MySensors 1.6beta

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


                  8

                  Online

                  11.7k

                  Users

                  11.2k

                  Topics

                  113.0k

                  Posts


                  Copyright 2019 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