LoRa Gateway adds back slashes with MQTT messages

Hi I am using LoRa Gateway and my LoRa Tx node sends message like this:
{“temp1”:77,“hum1”:55,“moist1”:50} and a separate LoRa RX node receives the same and confirms as {“temp1”:77,“hum1”:55,“moist1”:50}

But the LORAtoMQTT message adds backlashes on its own and the message becomes {\“temp1\”:77,\“hum1\”: 55,“moist”:50} etc.,

Please help me to get what message goes into Gateway and the same comes out as MQTT message.
With best regards,
ragoth@gmail.com

Hi,

Could you activate traces (set the log level to LOG_LEVEL_TRACE), and see where the backslashes are added during the message processing?
You may publish here the log output from the serial monitor.

192.168.1.63

:arrow_forward:$SYS (48 topics, 277 messages)

▼home

▼OpenMQTTGateway

LWT = online

version = version_tag

LORAtoMQTT = {“rssi”:-61,“snr”:9.75,“pferror”:-3414,“packetSize”:36,“message”:“e”{“temp2”:88,“hum2”:66,“moist2”:49}"}

How do I send the screen shot as your message space is not printing the backslashes while I copy and paste, but backslashes are there in the outputs.
Please advice how to send the screen shot images which has the backslashes…

May be because, backslash is an escape character it seems it rejects it.

Add printscreen maybe instead of copy/paste

Hi, Attached the screen shot for your views and advice please.
With Best regards

Are you sure the backslash are not added by the node itself?

Yes, I am sure, it is not added by the node because one to one communication between the nodes display perfect. Only when it comes through the gateway it is getting added.

On which type of support ?

I am using 2 TTgo Lora boards with OLED display, as node 1 and node 2. Another esp32 as openMQTTGateway. Messages from node to node is seen on TTgo LoRa’s OLED display and the Gateway out come is seen on Mobile, Mqtt Terminal.

Could you share your node program so as to take a look to it and try to reproduce?

Hello,

I think, this issue could help you:

Thank you for your reply.
I may be wrong but I assume the gateway sends it as strings with in double quotes and adds backslashes as an escape character. If it sends as JSON string everything will be fine or it can send it as a data like “snr” and “rssi” etc.,
Please think it over.
Best regards.

Hi, thank you for your time and concern. I am happy to say I solved the issue by changing the character string message into Json string message.

// Original lines beginning at Nr.66 in ZgatewayLORA.ino :
//
String packet;
packet = “”;
for (int i = 0; i < packetSize; i++) {
packet += (char)LoRa.read();
}

LORAdata.set("rssi", (int)LoRa.packetRssi());
LORAdata.set("snr", (float)LoRa.packetSnr());
LORAdata.set("pferror", (float)LoRa.packetFrequencyError());
LORAdata.set("packetSize", (int)packetSize);
LORAdata.set("message", (char*)packet.c_str());

// MODIFIED AS :
//
String json;
json = LoRa.readString();
String message = json.substring(2); // substring(2) removes junk charecters in front

LORAdata.set("rssi", (int)LoRa.packetRssi());
LORAdata.set("snr", (float)LoRa.packetSnr());
LORAdata.set("pferror", (float)LoRa.packetFrequencyError());
LORAdata.set("packetSize", (int)packetSize);
LORAdata.set("data",  jsonBuffer.parseObject(message)); 

//////////

Everything works fine for me now and thanks again for this nice project published.
With Great Regards.

1 Like