Data TTN to Thingspeak problem with Payload Decoder from Array

4 vues (au cours des 30 derniers jours)
Karsten Fenske
Karsten Fenske le 27 Juin 2022
Hello,
I have a question regarding decoding in TTN specifically for Thingspeak.
The code in Arduino IDE for a MKR1310 is the following:
String sensorString = String(airTemperatureReading);// + "-" + String(altitudeReading)+ "-" + String(pressureReading)+ "-" + String(sensorValueRain);
char payload[sensorString.length()+1];
sensorString.toCharArray(payload, sensorString.length() +1);
Serial.print(payload);
.
.
.
modem.beginPacket();
modem.write(payload, sizeof(payload));
Here I tested just one sensor data, to make it easier to understand whats going on with the payload function in general. But I didn´t really manage with that. In TTN the decoding is ok, so I get with the decoder -just for TTN usage- 24 from Hex 323400. However, now I have to switch the decoder to Thingspeak readable data but with the following Decoder I just get 50 in field1, but 24°C is the right temperature.
Decoder TTN:
function Decoder(bytes, port)
{
var tem = (bytes[0]<<0) | bytes[0];
return {
field1: tem
}
}
Test Byte Payload -> Complete uplink data
{
"f_port": 3,
"frm_payload": "MjQA",
"decoded_payload": {
"field1": 50
.
.
.
The complete Arduino Sketch is from here:
Thank you very much
  2 commentaires
Christopher Stapels
Christopher Stapels le 27 Juin 2022
Can you clarify what the question you ar asking is?
Karsten Fenske
Karsten Fenske le 27 Juin 2022
The question is, how to decode the payload - > an array of strings (sensor data for example temperature) sent to TTN, into readable format for Thingspeak?

Connectez-vous pour commenter.

Réponses (1)

Christopher Stapels
Christopher Stapels le 27 Juin 2022
Around 4:01 in this video, I'm explaining my payload formatter. Or you can see the instructions in this example in the doc. The doc is a bit outdated for TTN, (version 2 instead of 3) but the payload formatting is still true. The video is up to date for version 3.
  4 commentaires
Seamus
Seamus le 5 Déc 2024
Modifié(e) : Seamus le 5 Déc 2024
Hi,
I am also looking for a TTN Thingspeak payload formatter template. The link to the example document above is broken. Could you post the code here please? Any help much appreciated. Linking a DL-CTD10 - Pressure / Liquid Level, Temperature and Electrical Conductivity Sensor to thingspeak but having difficulty in getting correct format.
Christopher Stapels
Christopher Stapels le 6 Déc 2024
Thanks for pointing out the broken link. Apparently I truncated the 'l' at the end of 'html'. Its fixed now, but I have to warn you, TTN changes things pretty fast as far as I can tell, and I havent kept up on their formatting too much. If you get it working, please let us know.

Connectez-vous pour commenter.

Catégories

En savoir plus sur ThingSpeak dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by