kvdc
March 7, 2018, 5:25pm
1
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,…
Costas
March 7, 2018, 5:57pm
2
kvdc:
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 ....);
kvdc
March 7, 2018, 7:18pm
3
Costas:
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?
kvdc
March 7, 2018, 7:58pm
5
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 …big thumbs up
Costas
March 7, 2018, 8:00pm
6
I nominate @kvdc for the job
1 Like
kvdc
March 7, 2018, 8:02pm
7
HAHA, sure, when I get a little bit more experienced
Thanks again!
Gunner
Split this topic
February 5, 2019, 11:04pm
8