TTN to ThingSpeak using the new integration applet

Hello!

I am not able to connect TTN to Thingspeak.

I make as this:
https://www.thethingsnetwork.org/docs/applications/thingspeak/.

But I think I make a mistake… but don’t know where… could you help me?

payload exemple: 0781CBFFF1980EA100390129
Fields:
{
“field1”: false,
“field2”: 3.745,
“field3”: 49.1979,
“field4”: -0.3688,
“field5”: 2.97,
“field6”: 0.57,
“latitude”: 49.1979,
“longitude”: -0.3688
}

my decoder:

function Decoder(bytes,port){
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var alarm=(bytes[6]&0x40)?true:false;//Alarm status
value=((bytes[6]&0x3f)<<8)|bytes[7];
var batV=value/1000;//Battery,units:Volts
value=bytes[8]<<8|bytes[9];
if(bytes[8]&0x80)
{
value |=0xFFFF0000;
}
var roll=value/100;//roll,units: °
value=bytes[10]<<8|bytes[11];
if(bytes[10]&0x80)
{
value |=0xFFFF0000;
}
var pitch=value/100;//pitch,units: °
var json={
field6:roll,
//pitch:pitch,
//batV:batV,
//alarm:alarm
};
var value=bytes[0]<<16|bytes[1]<<8|bytes[2];
if(bytes[0]&0x80)
{
value |=0xFFFFFF000000;
}
var value2=bytes[3]<<16|bytes[4]<<8|bytes[5];
if(bytes[3]&0x80)
{
value2 |=0xFFFFFF000000;
}
if(value ==0x0FFFFF&&value2 ==0x0FFFFF)
{
//gps disabled (low battery)
json.gpsdisabled=1;
}
else if(value ===0&&value2 ===0)
{
//gps no position yet
json.nogpsposition=1;
}
else
{
json.latitude=value/10000;//gps latitude,units: °
json.longitude=value2/10000;//gps longitude,units: °
}

json.field1= alarm;
json.field2= batV;
json.field3= value/10000;
json.field4= value2/10000;
json.field5= pitch;
//json.field6= roll;

return json;
}

Your decoder function looks fine at first glance. Thank you for testing the integration! There was an issue in the initial implementation that has been fixed. Does the problem still exist? Are you sending regular updates to the integration right now? Is your channel being updated? If not please reach out to ThingSpeak at support “at” thingspeak dot com.

Problem still exist…

Have you entered the write api key for your channel and the channel ID into the integration? Can you share the data coming into your application and what it looks like when you put it through the test operation on the decoder? Sorry to create all this trouble, but Id really like to help you get it working if we can.

1 Like

Not very helpful probably, but just wanted to confirm that integration “TTN to ThingSpeak” works fine for my project. Thanks for creating the integration!

1 Like

sorry, not enough time this week-end… will answers as soon as possible!

Ill wait patiently kelu28. Weekends need to be doubled in size for sure.
hboictlab, thanks for the confirmation! If you can think of how we can improve the integration, please send feedback to support ‘at’ mail.thingspeak 'dot com

image
Victoire ! :slight_smile:

the Channel write API key was erased.
I do not know what happened. However, I had several times verified that I had correctly configured the integration.

1 Like

I can’t connect TTN and ThingSpeak too. My decoder function is:

function Decoder(b, port) {
var hum = b[0];
var volt = b[1];

return {
field1: hum,
field2: volt
}
}

I simulate data uplink from a device. TTN decodes it but my ThingSpeak channel does not show any data.

Are you able to update the channel using a web browser? Use the format shown on the API keys tab of your channel view.

Yes, I can.

Which TTN server are you using?

Is it mandatory to have the returned data like field1, field2 etc. or can it just be any key that you later also enter in the fields of ThingSpeak?

I am using the 8in1 LoRa weather station from SEEED with a custom payload formatter that produces following data (example):

      "frm_payload": "AQBzQQAAJ2sIABACABIAAAAAJdU=",
      "decoded_payload": {
        "barometric_pressure": 96850,
        "battery": 0,
        "humidity": 65,
        "light_intensity": 10091,
        "rain_gauge": 0,
        "temperature": 11.5,
        "uv_index": 0.8,
        "wind_direction": 18,
        "wind_speed": 1.6
      },

I have followed the ThingSpeak-manual from TheThingsStack, which seemed pretty straight forward: just add Channel ID & API Write Key.
On ThingSpeak it displays that entries arrive but the data is empty. I guess new fields are generated whenever a get request is performed.

I have tried adding a new webhook as well as a new channel already.