# Thingspeak multiple fields problem

**URL:** <https://community.particle.io/t/thingspeak-multiple-fields-problem/23946>\
**Category:** Troubleshooting\
**Created:** [June 25, 2016, 1:12pm UTC](https://community.particle.io/t/thingspeak-multiple-fields-problem/23946 "2016-06-25T13:12:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwd0tcom](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dwd0tcom/32/10623_2.png) [@dwd0tcom](https://community.particle.io/u/dwd0tcom)\
**Post date:** [June 25, 2016, 1:12pm UTC](https://community.particle.io/t/thingspeak-multiple-fields-problem/23946/1 "2016-06-25T13:12:36Z")

</div>

Hello,  
I’m using a photon with 5 webhooks. Those webhooks transfer the data to Thingspeak. And now to the problem, I want to use the main JSON file for a project. But I cant send all 5 at once, so I put a delay between every dataset. But now in the JSON file it tells me “null” at some fields.

Is there a way to send 5 webhooks at the same time to Thingspeak or another way to get rid of this problem?

Here is the part of my code, where it sends the data to thingspeak:

```
Particle.publish("biergartenSensor1", String(sen1), PRIVATE);
for(int i = 1; i < 4; i++){
    digitalWrite(ledPin2, HIGH);
    delay(100);
    digitalWrite(ledPin2, LOW);
    delay(100);
}
delay(30000);

Particle.publish("biergartenSensor2", String(sen2), PRIVATE);
for(int i = 1; i < 4; i++){
    digitalWrite(ledPin2, HIGH);
    delay(100);
    digitalWrite(ledPin2, LOW);
    delay(100);
}
delay(30000);

Particle.publish("biergartenSensor3", String(sen3), PRIVATE);
for(int i = 1; i < 4; i++){
    digitalWrite(ledPin2, HIGH);
    delay(100);
    digitalWrite(ledPin2, LOW);
    delay(100);
}
delay(30000);

Particle.publish("biergartenSensor4", String(sen4), PRIVATE);
for(int i = 1; i < 4; i++){
    digitalWrite(ledPin2, HIGH);
    delay(100);
    digitalWrite(ledPin2, LOW);
    delay(100);
}
delay(30000);

Particle.publish("biergartenSensor5", String(sen5), PRIVATE);
for(int i = 1; i < 4; i++){
    digitalWrite(ledPin2, HIGH);
    delay(100);
    digitalWrite(ledPin2, LOW);
    delay(100);
}
delay(30000);

```

An here is how my JSON looks like:

 ![](https://us1.discourse-cdn.com/flex026/uploads/particle/original/2X/7/729ce1921876ad010b684d09b0ebcacbda166624.png)

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 25, 2016, 1:58pm UTC](https://community.particle.io/t/thingspeak-multiple-fields-problem/23946/2 "2016-06-25T13:58:00Z")

</div>

First, the rate limit for publishes is 1 per second (with a burst of 4 with a 4sec pause following).  
So you’d not need your `delay(30000)` and the extra 600ms inside your blink-loops.

And next, do you actually need five webhooks, can you not just use one with all the data at once, with a custom template?

You can have a data payload for your publish even like this

```cpp
char _json[256];
snprintf(_json, sizeof(_json), "{\"field1\":\"%d\",\"field2\":\"%d\",\"field3\":\"%d\",\"field4\":\"%d\",\"field5\":\"%d\"}", sen1, sen2 ,sen3, sen4, sen5);
Particle.publish("biergartenSensor", _json, PRIVATE);

```

---

<div class="post-metadata">

**Author:** ![dwd0tcom](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dwd0tcom/32/10623_2.png) [@dwd0tcom](https://community.particle.io/u/dwd0tcom)\
**Post date:** [June 25, 2016, 2:00pm UTC](https://community.particle.io/t/thingspeak-multiple-fields-problem/23946/3 "2016-06-25T14:00:16Z")

</div>

Thanks! 🙂

I got 5 sensors, which only tell me 1 or 0. The idea with just one sounds cool.  
How can I create a custom template?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 25, 2016, 2:06pm UTC](https://community.particle.io/t/thingspeak-multiple-fields-problem/23946/4 "2016-06-25T14:06:48Z")

</div>

Seen my edit above?

BTW, there is a ThingSpeak library too, maybe you can get around webhooks completely.

> [@ThingSpeak Communication Library written by the ThingSpeak development team](https://community.particle.io/t/thingspeak-communication-library-written-by-the-thingspeak-development-team/15415):
>
> This library enables a Particle Photon or Core to write or read data to or from ThingSpeak, an open data platform for the Internet of Things with MATLAB analytics and visualization. [See the 90 second getting started video](https://youtu.be/2DbYvvGuCy4) ThingSpeak offers free data storage and analysis of time-stamped numeric or alphanumeric data. Users can access ThingSpeak by visiting [http://thingspeak.com](http://thingspeak.com) and creating a ThingSpeak user account.

---

<div class="post-metadata">

**Author:** ![dwd0tcom](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dwd0tcom/32/10623_2.png) [@dwd0tcom](https://community.particle.io/u/dwd0tcom)\
**Post date:** [June 26, 2016, 4:52am UTC](https://community.particle.io/t/thingspeak-multiple-fields-problem/23946/5 "2016-06-26T04:52:18Z")

</div>

Hey,  
I used the library and everything works fine! Thank you!
