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. MQTT Client gateway

MQTT Client gateway

Scheduled Pinned Locked Moved Development
91 Posts 33 Posters 52.0k Views 14 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.
  • GizMoCuzG GizMoCuz

    Questions (Sorry)

    I have rebuild the whole original MQTT sketch so it supports the standard mysensors protocol (the serial/ethernet gateway).
    With this, we have all functionality that the original mysensor serial gateway supports.

    What would be the downside with this implementation ?

    The data being transferred is like

    http://www.mysensors.org/download/serial_api_14

    It is now also very easy to pass the payload an internal serial/ethernet gateway handler, but the payload is not easily interpreted as human text of course.

    Would this be something to submit as a replacement of the original MQTT library?

    Devs just need to push the payload to their original serial/ethernet handler, and sending messages is also in the same format

    AWIA Offline
    AWIA Offline
    AWI
    Hero Member
    wrote on last edited by
    #41

    @GizMoCuz Can you elaborate a little on your rebuild? ie. what was the objective?

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

      Could someone please post the latest working version of the MQTT Client gateway sketch?

      1 Reply Last reply
      0
      • TD22057T Offline
        TD22057T Offline
        TD22057
        Hardware Contributor
        wrote on last edited by
        #43

        Does anyone have a version of this reworked for the new 1.5 client? Looking through the MySensor class, it looks like a lot of the code in MyMQTTClient.cpp can be removed as it's now in the sensor class. I'd like to use this for my gateway as it's a much better system than the broker gateway that's in the standard library but it needs to support message signing and the newer 1.5 code base. If someone else finished this already I'll just use that, otherwise I'll start working on it. I have family coming in town so I don't expect to get much done in the next week but assuming that the MQTT code is working fine (I have no experience with that writing an MQTT client), it shouldn't take much work to refactor the client to use the new MySensor base.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tomkxy
          wrote on last edited by
          #44

          I just did an adaptation. I removed the MyMQTTClient.cpp completely. It looks codewise more than the MQTTGateway. I am in the process of testing it.

          You can find it here https://github.com/tomkxy/Arduino.git in the branch MQTTClient.

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

            @tomkxy Any updates to this? my setup has been running well for a long time, but i am itchy to see if it will survive with 1.5.. i know i should just leave it alone :D but i cannot help but tinker with it.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tomkxy
              wrote on last edited by
              #46

              Well it seems to work. Only point I saw and don't understand is that the gateway tries to send a message back to the sensor which does not seem to be an ACK. See my post here http://forum.mysensors.org/topic/1782/gateway-is-sending-command-1-type-1-c-1-t-1-message-to-sensor but so far no feedback on that. Functional wise it works, at least with my test temp and humidity sensor.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                ruslan
                wrote on last edited by
                #47

                Please help! This MQTT client gateway fails to compile. I use 1.6.5. IDE, 1.5 library. Applied patches as suggested by ntruchsess and still get this error:

                MyMQTTClient.cpp: In constructor 'MyMQTTClient::MyMQTTClient(PubSubClient, uint8_t, uint8_t)':
                MyMQTTClient.cpp:108: error: no matching function for call to 'MySensor::MySensor(uint8_t&, uint8_t&)'
                     MySensor(_cepin, _cspin), buffsize(0)
                                                         ^
                MyMQTTClient.cpp:108:41: note: candidates are:
                In file included from MyMQTTClient.h:16:0,
                                 from MyMQTTClient.cpp:14:
                R:\Arduino\libraries\MySensors/MySensor.h:153:2: note: MySensor::MySensor(MyTransport&, MyHw&)
                  MySensor(MyTransport &radio =*new MyTransportNRF24(), MyHw &hw=*new MyHwDriver()
                  ^
                R:\Arduino\libraries\MySensors/MySensor.h:153:2: note:   no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'MyTransport&'
                R:\Arduino\libraries\MySensors/MySensor.h:144:7: note: MySensor::MySensor(const MySensor&)
                 class MySensor
                       ^
                R:\Arduino\libraries\MySensors/MySensor.h:144:7: note:   candidate expects 1 argument, 2 provided
                MyMQTTClient.cpp: In member function 'void MyMQTTClient::begin(rf24_pa_dbm_e, uint8_t, rf24_datarate_e, uint8_t, uint8_t, uint8_t)':
                MyMQTTClient.cpp:148: error: 'setupRepeaterMode' was not declared in this scope
                   setupRepeaterMode();
                                     ^
                MyMQTTClient.cpp:154: error: 'setupRadio' was not declared in this scope
                   setupRadio(paLevel, channel, dataRate);
                                                        ^
                MyMQTTClient.cpp:155: error: 'BASE_RADIO_ID' was not declared in this scope
                   RF24::openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
                                                     ^
                MyMQTTClient.cpp:157: error: cannot call member function 'void RF24::startListening()' without object
                   RF24::startListening();
                                        ^
                no matching function for call to 'MySensor::MySensor(uint8_t&, uint8_t&)'
                
                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tomkxy
                  wrote on last edited by
                  #48

                  @tomkxy said:

                  here https://github.com/tomkxy/Arduino.git in the branch MQTTClient.

                  Did you have a look at my repository above? Functional wise it is the same adapted for version 1.5. I have it in use for quite a while now.

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    ruslan
                    wrote on last edited by
                    #49

                    to tomkhy: your gateway sketch compiles, but Arduino runs out of memory (I use Nano with W5100 ethernet module, SOFTSPI enabled). It does fit with MY_SIGNING_FEATURE and DEBUG disabled, but I need debug - somehow it is not registering with MQTT server. Please tell me how to reduce memory footprint.

                    greglG 1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tomkxy
                      wrote on last edited by
                      #50

                      I am using this sketch with a Mega exactly because of that problem. If you post your MQTTClientGateway sketch I can have a look. If you use Mosquito as MQTT broker you may also post the Mosquito config file.

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        ruslan
                        wrote on last edited by
                        #51

                        Many thanks to @tomkhy!
                        I built my MQTT client with his code. No modifications were needed.

                        BTW, Will this or any other code get included into the official MySensors library?

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          tomkxy
                          wrote on last edited by
                          #52

                          It is now in the Development branch.

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            ahhk
                            Hardware Contributor
                            wrote on last edited by ahhk
                            #53

                            Hi,

                            can this run on ESP8266 (as wifi-mqttclient-gateway), too?
                            Greetings

                            Andreas

                            M 1 Reply Last reply
                            0
                            • T Offline
                              T Offline
                              tomkxy
                              wrote on last edited by
                              #54

                              I don't know, you have to try it. What I can say that with signing support enabled it doesn't fit into the memory of a ProMini. I run it in a Mega.

                              1 Reply Last reply
                              0
                              • R ruslan

                                to tomkhy: your gateway sketch compiles, but Arduino runs out of memory (I use Nano with W5100 ethernet module, SOFTSPI enabled). It does fit with MY_SIGNING_FEATURE and DEBUG disabled, but I need debug - somehow it is not registering with MQTT server. Please tell me how to reduce memory footprint.

                                greglG Offline
                                greglG Offline
                                gregl
                                Hero Member
                                wrote on last edited by
                                #55

                                @ruslan said:

                                to tomkhy: your gateway sketch compiles, but Arduino runs out of memory (I use Nano with W5100 ethernet module, SOFTSPI enabled). It does fit with MY_SIGNING_FEATURE and DEBUG disabled, but I need debug - somehow it is not registering with MQTT server. Please tell me how to reduce memory footprint.

                                Looks like you have it working now, but just incase, Previously when I have had memory issues , I have upgraded my bootloader to use Optiboot which gives you a little bit more.

                                HTH

                                1 Reply Last reply
                                0
                                • A ahhk

                                  Hi,

                                  can this run on ESP8266 (as wifi-mqttclient-gateway), too?
                                  Greetings

                                  Andreas

                                  M Offline
                                  M Offline
                                  mlava
                                  wrote on last edited by
                                  #56

                                  @ahhk
                                  Hello all, first post here and a bit new to the mysensors field.
                                  I also want to know the answer as to whether this will run on the ESP8266 as hope to run a wifi gateway.
                                  Thanks in advance! :)

                                  1 Reply Last reply
                                  0
                                  • C Offline
                                    C Offline
                                    chris021
                                    wrote on last edited by
                                    #57

                                    Also keen to run this on an ESP8266 would be a great for bridging.

                                    1 Reply Last reply
                                    0
                                    • John ConnollyJ Offline
                                      John ConnollyJ Offline
                                      John Connolly
                                      wrote on last edited by
                                      #58

                                      OK. I've got the gateway to compile and get the following:

                                      Started!
                                      0;0;3;0;9;read: 110-110-0 s=1,c=1,t=0,pt=7,l=5:13.2
                                      0;0;3;0;9;read: 105-105-0 s=0,c=1,t=1,pt=7,l=5:70.0
                                      0;0;3;0;9;read: 110-110-0 s=0,c=1,t=1,pt=7,l=5:58.3
                                      0;0;3;0;9;read: 105-105-0 s=0,c=1,t=1,pt=7,l=5:69.9
                                      0;0;3;0;9;read: 110-110-0 s=0,c=1,t=1,pt=7,l=5:58.2
                                      0;0;3;0;9;read: 105-105-0 s=0,c=1,t=1,pt=7,l=5:70.0
                                      0;0;3;0;9;read: 110-110-0 s=0,c=1,t=1,pt=7,l=5:58.3
                                      0;0;3;0;9;read: 105-105-0 s=0,c=1,t=1,pt=7,l=5:69.9
                                      0;0;3;0;9;read: 110-110-0 s=0,c=1,t=1,pt=7,l=5:58.2
                                      0;0;3;0;9;read: 110-110-0 s=0,c=1,t=1,pt=7,l=5:58.3
                                      0;0;3;0;9;read: 105-105-0 s=0,c=1,t=1,pt=7,l=5:69.8
                                      0;0;3;0;9;read: 110-110-0 s=1,c=1,t=0,pt=7,l=5:13.3
                                      0;0;3;0;9;read: 110-110-0 s=0,c=1,t=1,pt=7,l=5:58.5
                                      

                                      I can ping the MQTTClinetGateway from another machine and I've confirmed Mosquitto is running OK with a series of pub/subs from other machines/devices and that side of things is working perfectly fine.

                                      I'm not seeing any of the above gateway readings publish to my broker. Thoughts?

                                      Cheers.

                                      1 Reply Last reply
                                      0
                                      • T Offline
                                        T Offline
                                        tomkxy
                                        wrote on last edited by
                                        #59

                                        Following points to verify and check:

                                        • is the gateway connected to the broker. As far as I remember you can check that by subscribiing to Mosquitto status messages
                                        mosquitto_sub -v -t \$SYS/#
                                        

                                        If not check what the authentication method is mosquitto is. If it allows anonymous access make sure that "MQTT_AUTH_REQUIRED" is not defined in the MQTTClientGateway sketch. If username and password are set correctly.

                                        It seems that you are not using signing. So ensure that your MQTTClientGateway is compiled with the signing feature disabled. That are the two points I can imagine now provided that you are sure that you have of course a working ethernet connection.

                                        1 Reply Last reply
                                        0
                                        • John ConnollyJ Offline
                                          John ConnollyJ Offline
                                          John Connolly
                                          wrote on last edited by
                                          #60

                                          I downloaded and installed the development branch and got the MQTTClientGateway running on an UNO with a W5100 shield (that I'm suspicious of, in terms of its reliability). The sketch runs great for a while publishing data to Mosquitto on my Mac Mini, but then stops responding after a while. I'm pretty sure the cause of the problem is the ethernet shield as it bombs out when running other sketches - the webserver one for example.

                                          I have a few of these ENC28J60 boards and I'd like to use one of those instead, but have had some problems.

                                          http://www.aliexpress.com/item/ENC28J60-LAN-Ethernet-Network-Board-Module-for-arduino-25MHZ-Crystal-AVR-51-LPC-STM32-3-3V/1956963721.html

                                          I notice in the MQTTClientGateway sketch that I should just need to comment out the one W5100 Ethernet.h library and substitute with the UIPEthernet.h one, but I tried that and had no joy. Does anyone have a working sketch based on the ENC28J60 that they could post, along with the wiring diagram to connect that board in along with any additional tweaks necessary to get it running on an Uno? Thanks in advance. Cheers.

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


                                          14

                                          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