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