MQTT Client gateway
-
I've ordered a new W5100 module - this time the red mini W5100 board missing the SD Card slot to see if I have better luck. Still keen to see code for an ENC based MQTTClientGateway though, as this will take a while to arrive... ;)
-
To developers of the MQTT client:
I just tried the GatewayW5100MQTTClient in the latest development branch - it gives me "0;0;3;0;9;Radio init fail" error, while GatewayW5100 sketch works fine. What could be the reason? I noticed that the declarations parts in these sketches are rather different.
My setup: ARduino nano clone + W5100 module + NRF24L01 radio. All wired as in the MySensors ethernet gateway guide ([http://www.mysensors.org/build/ethernet_gateway]) -
For the W5100 SOFTSPI has to be enabled. I see that this is missing from the sketch..
Try adding (coming from the normal W5100 sketch)
// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. #if !defined(MY_W5100_SPI_EN) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 #define MY_SOFT_SPI_MOSI_PIN 15 #endifI'll update the repository.
-
Is this MQTTClientGateway in the dev branch only? I didn't see something like this in the 1.5 release/master.
I would prefer to use my gateway as client, but I am not skilled enough to use the dev branch and work around resulting problems :sa:greetings
Dakkyedit:
@tomkxy said:@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.
hmm is this repo still functional? with the signing_feature enabled i'm getting compile errors:
mqttClientGateway:175: error: 'signer' was not declared in this scope , signer ^ -
Is this MQTTClientGateway in the dev branch only? I didn't see something like this in the 1.5 release/master.
I would prefer to use my gateway as client, but I am not skilled enough to use the dev branch and work around resulting problems :sa:greetings
Dakkyedit:
@tomkxy said:@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.
hmm is this repo still functional? with the signing_feature enabled i'm getting compile errors:
mqttClientGateway:175: error: 'signer' was not declared in this scope , signer ^ -
I Think HERE is the answer of our problem!!!!
-
Good afternoon gents!
So I have been playing with openHab and an arduino as a mqtt gateway and this has been successful. The only thing I don't like is that the arduino does not seem to like multiple connections to the MQTT broker.
My next step then is to use an MQTT broker (mosquitto) on the pi and then subscribe to this from the arduino. If I understand correctly, this is exactly what this thread is discussing.
So - I have downloaded the codes and without changing anything, tried to compile. This fails with numerous errors. I have te latest libraries installed and to be honest, I am a little lost as to what is wrong. Before I post lots of error messages, are there any known 'tricks' to get the latest version working?
Hopefully someone can help - Thanks guys :-)
-
Good afternoon gents!
So I have been playing with openHab and an arduino as a mqtt gateway and this has been successful. The only thing I don't like is that the arduino does not seem to like multiple connections to the MQTT broker.
My next step then is to use an MQTT broker (mosquitto) on the pi and then subscribe to this from the arduino. If I understand correctly, this is exactly what this thread is discussing.
So - I have downloaded the codes and without changing anything, tried to compile. This fails with numerous errors. I have te latest libraries installed and to be honest, I am a little lost as to what is wrong. Before I post lots of error messages, are there any known 'tricks' to get the latest version working?
Hopefully someone can help - Thanks guys :-)
@cowen71 - Could you please give us a little more information to help troubleshoot your issues.
What ethernet module are you using? W5100? If so you need to makesure that you have enabled soft SPI for NRF radio as it doesn't like it being on the same bus. We also have to move the CE/CSN pins for the radio too. All this is explained inside of the sketch itself.
-
Hi Samuel,
OK, I was hoping there was a known 'trick' to get things working, but maybe I was just dreaming. Of course, if not - much more information is needed!
At the moment I am testing with a Mega2560 with an arduino ethernet shield attached. This has (and still does) work well with the mqtt gateway downloaded from mysensors after a few minor pin assignment changes.
The problem I am having is that I cannot compile the mqttClientGateway code. I get errors. I have to be honest that whilst I had experience 20 years ago with PIC's and other uC's, I am incredibly rusty with C and completely new to Arduinos. So it is a steep learning curve currently. In this case, I would not be surprised if I have made a real schoolboy error!
So what did I do?....
At the moment I installed the PubSubLient library into the Arduino libraries file.
I copied the code from here: https://github.com/ntruchsess/MySensors/tree/mqttclient/libraries/MySensors/examples/MQTTClientGateway
creating the three files in my mqttClientGateway development folder.I changed nothing (accept target and com port and hit the compile button! This fails with the following error initially:
sketch\MyMQTTClient.cpp:14:30: fatal error: utility/MsTimer2.h: No such file or directory
#include "utility/MsTimer2.h"I modified the include text to: #include "MsTimer2.h"
and tried to compile again again. The result is:sketch\MyMQTTClient.cpp: In constructor 'MyMQTTClient::MyMQTTClient(PubSubClient, uint8_t, uint8_t)':
MyMQTTClient.cpp:106: error: no matching function for call to 'MySensor::MySensor(uint8_t&, uint8_t&)'
MySensor(_cepin, _cspin), buffsize(0) ^sketch\MyMQTTClient.cpp:106:41: note: candidates are:
In file included from sketch\MyMQTTClient.h:15:0,
from sketch\MyMQTTClient.cpp:13:C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:158:2: note: MySensor::MySensor(MyTransport&, MyHw&)
MySensor(MyTransport &radio =*new MyTransportNRF24(), MyHw &hw=*new MyHwDriver()
^
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:158:2: note: no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'MyTransport&'
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: constexpr MySensor::MySensor(const MySensor&)
class MySensor
^C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: candidate expects 1 argument, 2 provided
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: constexpr MySensor::MySensor(MySensor&&)
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: candidate expects 1 argument, 2 provided
sketch\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:146: error: 'setupRepeaterMode' was not declared in this scope
setupRepeaterMode();
^MyMQTTClient.cpp:152: error: 'setupRadio' was not declared in this scope
setupRadio(paLevel, channel, dataRate);
^MyMQTTClient.cpp:153: error: 'BASE_RADIO_ID' was not declared in this scope
RF24::openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
^MyMQTTClient.cpp:155: error: cannot call member function 'void RF24::startListening()' without object
RF24::startListening();
My suspicion is I have a compatibility problem between library versions and/or the sketch I have downloaded. The radio stuff I can probably solve (hopefully) its the issues before that I am struggling with.
Any advice would be appreciated.
Cheers
-
Hi Samuel,
OK, I was hoping there was a known 'trick' to get things working, but maybe I was just dreaming. Of course, if not - much more information is needed!
At the moment I am testing with a Mega2560 with an arduino ethernet shield attached. This has (and still does) work well with the mqtt gateway downloaded from mysensors after a few minor pin assignment changes.
The problem I am having is that I cannot compile the mqttClientGateway code. I get errors. I have to be honest that whilst I had experience 20 years ago with PIC's and other uC's, I am incredibly rusty with C and completely new to Arduinos. So it is a steep learning curve currently. In this case, I would not be surprised if I have made a real schoolboy error!
So what did I do?....
At the moment I installed the PubSubLient library into the Arduino libraries file.
I copied the code from here: https://github.com/ntruchsess/MySensors/tree/mqttclient/libraries/MySensors/examples/MQTTClientGateway
creating the three files in my mqttClientGateway development folder.I changed nothing (accept target and com port and hit the compile button! This fails with the following error initially:
sketch\MyMQTTClient.cpp:14:30: fatal error: utility/MsTimer2.h: No such file or directory
#include "utility/MsTimer2.h"I modified the include text to: #include "MsTimer2.h"
and tried to compile again again. The result is:sketch\MyMQTTClient.cpp: In constructor 'MyMQTTClient::MyMQTTClient(PubSubClient, uint8_t, uint8_t)':
MyMQTTClient.cpp:106: error: no matching function for call to 'MySensor::MySensor(uint8_t&, uint8_t&)'
MySensor(_cepin, _cspin), buffsize(0) ^sketch\MyMQTTClient.cpp:106:41: note: candidates are:
In file included from sketch\MyMQTTClient.h:15:0,
from sketch\MyMQTTClient.cpp:13:C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:158:2: note: MySensor::MySensor(MyTransport&, MyHw&)
MySensor(MyTransport &radio =*new MyTransportNRF24(), MyHw &hw=*new MyHwDriver()
^
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:158:2: note: no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'MyTransport&'
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: constexpr MySensor::MySensor(const MySensor&)
class MySensor
^C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: candidate expects 1 argument, 2 provided
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: constexpr MySensor::MySensor(MySensor&&)
C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:149:7: note: candidate expects 1 argument, 2 provided
sketch\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:146: error: 'setupRepeaterMode' was not declared in this scope
setupRepeaterMode();
^MyMQTTClient.cpp:152: error: 'setupRadio' was not declared in this scope
setupRadio(paLevel, channel, dataRate);
^MyMQTTClient.cpp:153: error: 'BASE_RADIO_ID' was not declared in this scope
RF24::openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
^MyMQTTClient.cpp:155: error: cannot call member function 'void RF24::startListening()' without object
RF24::startListening();
My suspicion is I have a compatibility problem between library versions and/or the sketch I have downloaded. The radio stuff I can probably solve (hopefully) its the issues before that I am struggling with.
Any advice would be appreciated.
Cheers
@cowen71, from a glancing look over that post, i would expect the issue to lie within your libraries. Whether it be a version merging issue or just a general error in placements.
I will put money on that you have your Arduino folder setup incorrectly when it comes to the libraries. I'll be honest and admit that i'm not too sure why you're getting your client sketch from ntruchsess rather than directly from the MySensors github/download page.
Lets just run through it from the start on where to get your libraries placed, in theory they could be located anywhere as long as the files inside of the mysensors folder are in the correct structure. You firstly need to get the development version, I prefer to just go for the direct download off of the download Page. Once you have that downloaded you should have a .zip folder called 'Arduino-development.zip'. Once you have extracted that you need to place all of its contents (3 folders and 5 files) into your Documents\Arduino folder.
I would do all of the above with a clean folder structure for the arduino folder, save any library confusions for the software. Then we need to go back into your gateway sketch and change your pin configuration like you need to.
Come back with your findings :)
-
Cheers Samuel,
I will let you know. I am happy (actually perhaps not happy!) to admit the failures are purely down to me trying to get to grips with everything here.I also have just noticed that ruslan reported the same error somewhere above and so I will also look at the solutions that worked for him.
I let you know what happens
-
OK so as you suggested - everything redownloaded and a new folder structure created. And actually, I get exactly the same problem. Incidentally, my other sketches compile no problem. Some written by me, some downloaded (e.g. Serial_Gateway, mqtt_Gateway). The only one I have a problem with is the mqttClientGateway.
I see above that ruslan had exactly the same issue 7 months ago and then got it working. The answer that helped him was....
@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.but this link seems dead now.
I better stop for the evening before my wife files for divorce! I get back to this tomorrow!
Thanks for the support so far. -
OK so as you suggested - everything redownloaded and a new folder structure created. And actually, I get exactly the same problem. Incidentally, my other sketches compile no problem. Some written by me, some downloaded (e.g. Serial_Gateway, mqtt_Gateway). The only one I have a problem with is the mqttClientGateway.
I see above that ruslan had exactly the same issue 7 months ago and then got it working. The answer that helped him was....
@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.but this link seems dead now.
I better stop for the evening before my wife files for divorce! I get back to this tomorrow!
Thanks for the support so far.@cowen71 Could you post your sketch for either me or a software contributor to see what is going on with it please. If you're certain that the error codes are the same as before then we can use the previous post as reference, if they're different in any way, please post the error codes again with the sketch :)
-
The link mentioned by @cowen71 was put into a pull request which went into the development branch. However, the MQTTClientGateway has been reworked significantly in the development branch. The message structure is now similar to the serial gateway. I just completed a "migration" from that old version to the latest development branch version which worked perfectly, apart from RF issues I had.
Thus, I suggest to use the latest version of the development branch.
-
The link mentioned by @cowen71 was put into a pull request which went into the development branch. However, the MQTTClientGateway has been reworked significantly in the development branch. The message structure is now similar to the serial gateway. I just completed a "migration" from that old version to the latest development branch version which worked perfectly, apart from RF issues I had.
Thus, I suggest to use the latest version of the development branch.
@tomkxy, if he followed my instructions like he said he has, he should all being well be running the latest version of the development branch. I may be incorrect but i still feel there may be some sort of folder structure error going on here.
-
OK - I couldn't sleep and so I am back for a short time.
So first I have to confess, I did not read the instructions from Samuel correctly and downloaded the Stable libraries rather than the development versions. I have corrected this. With the development libraries several of my other sketches will no longer compile - but lets not worry about that now!!
Next - I could not find within the mqttClientGateway sketch within the downloaded development folder. In the case I am just having a blonde moment, could you tell me exactly where this is located please.
Final question regarding the folder structures. I have the Arduino installation in the program files where it installs automatically, and then my Sketchbook is set up as follows..
\Arduino\Hardware
\Arduino\Documentation
\Arduino\Sketch\libraries
\Arduino\Sketch\mqttGateway
\Arduino\Sketch\pondController (etc... - folders for other sketches)