Webhook and multiple values in Thingspeak (again) SOLVED

I’m a compleet newbee in programming and IOT but managed to send sensor values from Arduino UNO and ESP8266 to Blynk.
I now want to send those multiple values to Thingspeak but can’t find the right way to do so.

I can update my Thingspeak with my browser and
https://api.thingspeak.com/update?api_key=XXXXXXXXXXXX&field1=V1&field2=V2&field3=V3&field5=V5&field6=V6

in my sketch I have

  timer.setInterval(5000L, readSensors);  // read sensors every 5 seconds
  timer.setInterval(17000L, SendToBlynk); // upload sensor values to Blynk every 17 seconds

}

void loop() {
  Blynk.run();  
  timer.run();
  displaySensors();  //only for debugginng, comment this out when all works fine
 }

/********* Send To Blynk  *************/
void SendToBlynk(void)
{
  Blynk.virtualWrite(V1, airTemp);
  Blynk.virtualWrite(V2, airHum);
  Blynk.virtualWrite(V3, soilTemp);
  //Blynk.virtualWrite(V4, soilHum1);
  Blynk.virtualWrite(V5, light);
  Blynk.virtualWrite(V6, soilHum2);
}            

I now want to send V1-V6 to Thingspeak and used
new pin: V0
URL: https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXX&field1=V1&field2=V2&field3=V3&field5=V5&field6=V6
Method GET
Content: tried both JSON and TEXT

can someone point me in the right direction, in newbee language please, as I thought /pin[0]/,/pin[1]/, /pin[2]/… was V1, V2, V3,…

Not quite.
The syntax is that you actually use /pin[0]/ etc and you send an array of values to the webhook virtual pin.

So if webhook was V1 you would send:

Blynk.virtualWrite(V1, variable0, variable1, variable2 ....);

@Costas, thank you for the quick reply! It already makes a lot more sense to me now but stil not working.

In my sketch I have now a new timer for upload to Thingspeak every 17 seconds and the new V0 for my webhook:

  timer.setInterval(5000L, readSensors);  // read sensors every 5 seconds
  timer.setInterval(10000L, SendToBlynk); // upload sensor values to Blynk every 10 seconds
  timer.setInterval(17000L, SendToThingspeak); // upload sensor values to Thingspeak every 17 seconds

void loop() {
  Blynk.run();  
  timer.run();
 }

/********* Send To Blynk  *************/
void SendToBlynk(void)
{
  Blynk.virtualWrite(V1, airTemp);
  Blynk.virtualWrite(V2, airHum);
  Blynk.virtualWrite(V3, soilTemp);
  //Blynk.virtualWrite(V4, soilHum1);
  Blynk.virtualWrite(V5, light);
  Blynk.virtualWrite(V6, soilHum2);
} 

/********* Send To Thinkspeak  *************/
void SendToThingspeak(void)
{ 
  Blynk.virtualWrite(V0, airTemp, airHum, soilTemp, light, soilHum2);           
}

In WebHook Widget
pin: V0
URL: https://api.thingspeak.com/update?api_key=LHVYS1M00UEJ5POT&field1=**airTemp**&field2=**airHum**&field3=**soilTemp**&field5=**light**&field6=**soilHum2**
Method: GET
Content Type: again tried application/json and text/plain
Body: empty

but stil not working

When I look in my Thingspeak channel stats I see: Last entry: less than a minute ago, so it does receive something but no data shows up in my charts?

Paste this exactly as the webhook url
https://api.thingspeak.com/update?api_key=LHVYS1M00UEJ5POT&field1=/pin[0]/&field2=/pin[1]/&field3=/pin[2]/&field5=/pin[3]/&field6=/pin[4]/

2 Likes

EUREKA!
someone should write a proper tutorial with an example, because for newbees like me the docs are not that clear! and I see a lot of people struggle with the implementation of Thingspeak
The support on the community on the other hand :ok_hand: …big thumbs up :+1:

I nominate @kvdc for the job :slight_smile:

1 Like

HAHA, sure, when I get a little bit more experienced :wink:
Thanks again!

A post was split to a new topic: Number of entries increase on Thingspeak but the values aren’t being displayed on the graphs