Thank you for your help/advice. Much appreciated.
I set up the RAK7249 LoRaPacket Server = built-in LoRa server. Left the MQTT bridge alone. Set up Au915 and Concentrator 1. All good. Can see traffic on the LoRaWAN Packet Logger. Pretty cool.
LoRa Network Server Gateway overview = setup Gateway and Applications.
Installed MQTT.fx on a windows 10 laptop
In MQTT.fx topic = application/{{application_ID}}/device/{{device_EUI}}/rx
Pretty soon discovered that “application_ID” is the ID from the :“LoRa Network Server Application Overview” screen and not the ID from the “TTN application/device screen”. Big learning.
Worked perfectly. Got packets on the laptop screen. Doubly pleased and grateful for all the help.
Next issue was to set an MQTT Broker up on an Arduion Uno. I used the following sketch -
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
byte mac[] = {0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED}; // Update these with values suitable for your network.
IPAddress ip(192, 168, 1, 50); // IP address to use if DHCP failed
IPAddress server(192, 168, 1, 146); // IP address of RAK7294 built-in server
EthernetClient ethClient;
PubSubClient client(ethClient);
void setup()
{
Serial.begin(57600);
client.setServer(server, 1883);
client.setCallback(callback);
Ethernet.begin(mac, ip); // try to conigfure using IP address instead of DHCP:
delay(5000); // Allow the hardware to sort itself out
}
void loop()
{
if (!client.connected())
{
reconnect();
}
}
void reconnect()
{
while (!client.connected()) // Loop until we’re reconnected
{
Serial.print(“Attempting MQTT connection… \n”);
if (client.connect(“arduinoClient”)) // Attempt to connect
{
Serial.println(“connected”);
client.subscribe(“application/3/device/00033bbcff12a631/rx”); // Once connected,resubscribe
if (client.subscribe(“application/3/device/00033bbcff12a631/rx”)) Serial.print(“sending the subscribe succeeded”);
}
else
{
if (client.state() == -4) Serial.print(“The server didn’t respond within the keep=alive time.”);
if (client.state() == -3) Serial.print(“The network connection was broken.”);
if (client.state() == -2) Serial.print(“The network connection failed.”);
if (client.state() == -1) Serial.print(“The client is disconnected cleanly.”);
if (client.state() == 1) Serial.print(“The server doesn’t support the requested version of MQTT.”);
if (client.state() == 2) Serial.print(“The server rejected the client identifier.”);
if (client.state() == 3) Serial.print(“The server was unable to accept the connection.”);
if (client.state() == 4) Serial.print(“The username/password was rejected.”);
if (client.state() == 5) Serial.print(“The client was not authorised to connect.”);
Serial.println("\n try again in 5 seconds");
delay(5000); // Wait 5 seconds before retrying
}
}
}
void callback(char* topic, byte* payload, unsigned int length)
{
Serial.print(“Message arrived [”);
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
}
Serial.println();
}
I have put in some serial.prints to debug.
The monitor reads -
Attempting MQTT connection
connected
sending the subscribe succeeded
After that, nothing happens. The topic = “application/3/device/00033bbcff12a631/rx” on the MQTT.fx gets a great response of messages: temperature, etc, but on the Arduino, nothing.
Can you please give some ideas as to where Im going wrong.
Again, thank you for your earlier assistance. The outcome has been pretty fantastic. Regards