Guide: Setting up and testing MQTT Client Gateway
-
@hek
That thread does not directly touch on the issue I noticed, although that might be connected.Some other questions:
Why is the topic structure as it is? I like my MQTT topics in hierarchical order. So, having different prefixes for send and receive (in and out) is not nice, but ok. BUt why is the ACK flag before the data type, which is usually linked to a value or variable in the sensor? I would consider ACK to be a sub-value of that one.And is there a way to have more speaky names instead of numbers? So, the source does not have that option and as that gateway is now included in the library I only see the possibility of changing the source in the library, which will disconnect from updates. Not nice. What about an option of excluding gatewayTransportSend and incomingMQTT via define from the library and define then in the own sketch?
-
What is the correct way to run DHCP? Tried commenting out
#define MY_IP_ADDRESS
but that didn't help.Also is it possible to use fqdn for the mqtt broker instead of the ip?
-
What is the correct way to run DHCP? Tried commenting out
#define MY_IP_ADDRESS
but that didn't help.Also is it possible to use fqdn for the mqtt broker instead of the ip?
I also tried to use DHCP and fqdn for mosqitto, but no luck....so I cant help but I too would like to know if its possible.
-
Finally I have the ESP8266 gateway running with Mosquitto and Openhab. Because the ESP8266 Gateway installation was painless and Mosquitto and Openhab the major problems I have posted some general info at this link in case anyone is interested, see http://forum.mysensors.org/topic/3005/switching-from-v1-5-mqtt-gateway-to-esp8266-mqtt-client-gateway.
(Sorry if this is the wrong procedure but found no way to add other tags to a message in this thread). -
A PR was merged 5 days ago where you can specify
MY_CONTROLLER_URL_ADDRESShttps://github.com/mysensors/Arduino/pull/375
I haven't verified it myself yet though.
-
I have been successfully running the MQTT client gateway receiving the data from sensors. Now build the first mysensors relay and would like to know if the MQTT client gateway can act as a transmitter?
I have assigned the nod id of 55 to the relay sensor and trying to send
mosquitto_pub -t mygateway1-in/55/1/0/0/3 -m "1"But doesn't seem to help
-
Resolved. Power supply was the problem
-
Finally I have the ESP8266 gateway running with Mosquitto and Openhab. Because the ESP8266 Gateway installation was painless and Mosquitto and Openhab the major problems I have posted some general info at this link in case anyone is interested, see http://forum.mysensors.org/topic/3005/switching-from-v1-5-mqtt-gateway-to-esp8266-mqtt-client-gateway.
(Sorry if this is the wrong procedure but found no way to add other tags to a message in this thread).@mbj said:
Finally I have the ESP8266 gateway running with Mosquitto and Openhab. Because the ESP8266 Gateway installation was painless and Mosquitto and Openhab the major problems I have posted some general info at this link in case anyone is interested, see http://forum.mysensors.org/topic/3005/switching-from-v1-5-mqtt-gateway-to-esp8266-mqtt-client-gateway.
(Sorry if this is the wrong procedure but found no way to add other tags to a message in this thread).Do not know if this info is of any interest but my ESP8266 MQTT gateway (based on a NodeMCU board) has been running without hiccups for almost a month now. So it has been very stable. I have also made a very short test using a Wemos D1 Mini for the gateway and this one seemed to be working as expected as well (not very surprised but you never know until it has been tested :-)).
-
Hi,
I've uploaded the GatewayW5100MQTTClient.ino to a UNO with W5100.
I have changed IP adresses to my Mosquitto broker (on Raspberry Pi) as instructed.
However,
I don't see the gateway connecting to the Mosquitto (in the /var/log/mosquitto/mosquitto.log on RPI) and also I don't see anything in the serial monitor. I've got 10+ sensornodes that work well when using another gateway (to OpenHab).
What am I overlooking here ?The same hardware UNO+W5100 worked before as MQTTgateway(+broker), so I'm guessing it's not the hardware?
Any help is appreciated.
Thanks,
DirkB -
Hi,
I've uploaded the GatewayW5100MQTTClient.ino to a UNO with W5100.
I have changed IP adresses to my Mosquitto broker (on Raspberry Pi) as instructed.
However,
I don't see the gateway connecting to the Mosquitto (in the /var/log/mosquitto/mosquitto.log on RPI) and also I don't see anything in the serial monitor. I've got 10+ sensornodes that work well when using another gateway (to OpenHab).
What am I overlooking here ?The same hardware UNO+W5100 worked before as MQTTgateway(+broker), so I'm guessing it's not the hardware?
Any help is appreciated.
Thanks,
DirkB -
Hi,
I've uploaded the GatewayW5100MQTTClient.ino to a UNO with W5100.
I have changed IP adresses to my Mosquitto broker (on Raspberry Pi) as instructed.
However,
I don't see the gateway connecting to the Mosquitto (in the /var/log/mosquitto/mosquitto.log on RPI) and also I don't see anything in the serial monitor. I've got 10+ sensornodes that work well when using another gateway (to OpenHab).
What am I overlooking here ?The same hardware UNO+W5100 worked before as MQTTgateway(+broker), so I'm guessing it's not the hardware?
Any help is appreciated.
Thanks,
DirkB@DirkB19 If you do not see anything in the serial monitor for the gateway then the problem must be with the gateway itself. Have you observed that there is a special #define MY_W5100_SPI_EN to uncomment when compiling for an Uno with the shield installed ? If not, you can try that.
-
@DirkB19 If you do not see anything in the serial monitor for the gateway then the problem must be with the gateway itself. Have you observed that there is a special #define MY_W5100_SPI_EN to uncomment when compiling for an Uno with the shield installed ? If not, you can try that.
-
@mbj said:
MY_W5100_SPI_EN
Sorry for this NOOB question, but where is this to be uncommented.
I don't see it in the gateway sketch ?
I use this sketch GatewayW5100MQTTClient.ino -
It is looking like this, just uncomment the #define - line:
// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
//#define MY_W5100_SPI_EN 4Thanks for the help, but I'm still very confused because OK, I found the line to uncomment.
I uncommented, but still nothing on serial monitor.
So then I see lines below this in the sketch and I realize that my radio is wired as follows ;
SCK -- Pin 13
MISO -- Pin 12
MOSI -- Pin 11
CS -- Pin 6
CE -- Pin 5
?
But there's no Pins 14,15,16 to be found on my W5100/UNO ? So I'm very confused ...#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
#define MY_SOFTSPI
#define MY_SOFT_SPI_SCK_PIN 14
#define MY_SOFT_SPI_MISO_PIN 16
#define MY_SOFT_SPI_MOSI_PIN 15
#endif// When W5100 is connected we have to move CE/CSN pins for NRF radio
#define MY_RF24_CE_PIN 5
#define MY_RF24_CS_PIN 6 -
Thanks for the help, but I'm still very confused because OK, I found the line to uncomment.
I uncommented, but still nothing on serial monitor.
So then I see lines below this in the sketch and I realize that my radio is wired as follows ;
SCK -- Pin 13
MISO -- Pin 12
MOSI -- Pin 11
CS -- Pin 6
CE -- Pin 5
?
But there's no Pins 14,15,16 to be found on my W5100/UNO ? So I'm very confused ...#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
#define MY_SOFTSPI
#define MY_SOFT_SPI_SCK_PIN 14
#define MY_SOFT_SPI_MISO_PIN 16
#define MY_SOFT_SPI_MOSI_PIN 15
#endif// When W5100 is connected we have to move CE/CSN pins for NRF radio
#define MY_RF24_CE_PIN 5
#define MY_RF24_CS_PIN 6In this case I think pin 14-16 are meant to be aliases for analog pins A0-A2.
Read the build page for the Ethernet gateway. You have to wire the radio in a non standard way in combination with the 5100.
But it's optional when using the shield. You could enable the SPI for that instead, like you were talking about a few posts up.
-
Thanks for the help, but I'm still very confused because OK, I found the line to uncomment.
I uncommented, but still nothing on serial monitor.
So then I see lines below this in the sketch and I realize that my radio is wired as follows ;
SCK -- Pin 13
MISO -- Pin 12
MOSI -- Pin 11
CS -- Pin 6
CE -- Pin 5
?
But there's no Pins 14,15,16 to be found on my W5100/UNO ? So I'm very confused ...#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
#define MY_SOFTSPI
#define MY_SOFT_SPI_SCK_PIN 14
#define MY_SOFT_SPI_MISO_PIN 16
#define MY_SOFT_SPI_MOSI_PIN 15
#endif// When W5100 is connected we have to move CE/CSN pins for NRF radio
#define MY_RF24_CE_PIN 5
#define MY_RF24_CS_PIN 6@DirkB19 The Arduino pinouts are, to say the least, confusing and it helps to look at one of the pinout sketches you can find on the net, for example http://marcusjenkins.com/wp-content/uploads/2014/06/ARDUINO_V2.png. So the pins are, as Martin said, (A0-A2) which must be exactly as you had them wired before if you had a "previous version" working MQTT Ethernet gateway. I have such a gateway (nowadays used as a spare) but built with a nano and a W5100 unit and it compiled and worked right away using the GatewayW5100MQTTClient.ino sketch from the development branch.
As you see nothing in the serial monitor there must be something else. Even if you upload the sketch to a completely barebone UNO without radio or anything else attached you will get a message in the serial monitor, in this case:
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0-beta)
0;255;3;0;9;Radio init failed. Check wiring.So if you see nothing at all there is something really basic wrong.
Presumably your sketch compiles OK so I assume you have exchanged all Arduino libraries to the libraries which belong to the Mysensors development branch. -
@DirkB19 The Arduino pinouts are, to say the least, confusing and it helps to look at one of the pinout sketches you can find on the net, for example http://marcusjenkins.com/wp-content/uploads/2014/06/ARDUINO_V2.png. So the pins are, as Martin said, (A0-A2) which must be exactly as you had them wired before if you had a "previous version" working MQTT Ethernet gateway. I have such a gateway (nowadays used as a spare) but built with a nano and a W5100 unit and it compiled and worked right away using the GatewayW5100MQTTClient.ino sketch from the development branch.
As you see nothing in the serial monitor there must be something else. Even if you upload the sketch to a completely barebone UNO without radio or anything else attached you will get a message in the serial monitor, in this case:
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0-beta)
0;255;3;0;9;Radio init failed. Check wiring.So if you see nothing at all there is something really basic wrong.
Presumably your sketch compiles OK so I assume you have exchanged all Arduino libraries to the libraries which belong to the Mysensors development branch.Aha !! Finally, it WORKS :)
mbj gave me the right hint about using the development libraries !!!So for others to learn from my mistakes, to get a UNO&W5100 shield to work with this MQTT Client Gateway sketch, you need your nRF24 radio connected to these pins nrs. on the W5100 shield ;
SCK -- Pin 13
MISO -- Pin 12
MOSI -- Pin 11
CS -- Pin 6
CE -- Pin 5AND (!) you need to install the libraries from the development branch.
(I first removed the 1.5 libraries)I just hope that installing the libraries from development branch will not get me into trouble with my the rest of my nodes (upladed with 1.5).
Is there an easy way to switch between 1.5 & development branch libraries when uploading sketches ?
Anyway, thanks to all those who responded and special thanks to mbj.
Some things are so obvious, but for newbies (like me) it can be a struggle ...
-
Aha !! Finally, it WORKS :)
mbj gave me the right hint about using the development libraries !!!So for others to learn from my mistakes, to get a UNO&W5100 shield to work with this MQTT Client Gateway sketch, you need your nRF24 radio connected to these pins nrs. on the W5100 shield ;
SCK -- Pin 13
MISO -- Pin 12
MOSI -- Pin 11
CS -- Pin 6
CE -- Pin 5AND (!) you need to install the libraries from the development branch.
(I first removed the 1.5 libraries)I just hope that installing the libraries from development branch will not get me into trouble with my the rest of my nodes (upladed with 1.5).
Is there an easy way to switch between 1.5 & development branch libraries when uploading sketches ?
Anyway, thanks to all those who responded and special thanks to mbj.
Some things are so obvious, but for newbies (like me) it can be a struggle ...
You can use git to easily change between different branches with libraries and sketches.
The take home message from the first sentence in the top post of this thread, is that dev branch libs are required with this sketch.
You should take care not to mix old style sketches with dev branch library and vice versa. Node to node to gateway comm should be OK as long as all nodes and gateway know the message types being used.