Hi,
I’m trying to send some data (an array and an integer) to PushingBox so I can plot it in a Google Spreadsheet. I have done this without using Blynk with the following code:
I just found out about the webhook widget on Blynk and I would prefer to use that instead of the previously used code. My only problem is converting this code to the right format. This is what I converted it to:
You started the thread with GET so stick with it, no reason to switch to PUT.
You don’t need the % in the URL.
If it’s still failing after these changes ensure char1 and int1 are displayed correctly in Serial Monitor at the point you are sending them to the webhook.
Also paste your code extract that covers the array variables.
No the virtual pins are part of the Blynk library.
What does Serial Monitor show if you change the code to this:
int i = 0;
while (i < 5)
{
if (strcmp(tags[i], lastTag) == 0)
{
terminal.print(owners[i]);
//Blynk.virtualWrite(V0, owners[i], freeSpots);
//Blynk.run();
Serial.println(owners[i]);
Serial.println(freeSpots);
}
i++;
}
I don’t use Pushingbox but sending that virtualWrite() does send an email to my test pushingbox email address of “Congratulation you just run your first scenario”.
For reference it looks like text/plain and application/json both work for Content Type in the webhook widget.
Out of interest, other than emailing pictures to yourself what else does pushing box do?
How are the two parameters actually used?
Changing the url doesn’t fix the problem. I’m using Pushingbox together with a Google Script to send both variables to a Google Spreadsheet together with the time of sending.
Edit: is there any input in the ‘Body’ section of the app required?
Nothing required in the body and GET.
The url I provided is certainly sending the details to pushingbox.
Not sure how you are doing the Google stuff but I did post some details of how to send directly from Blynk to Google Sheets but it was quite some time ago.
The problem lies with sending the data to Pushingbox, on the dashboard, I can see that no data is being sent to it. Also was that post you mentioned a post from you or a reply to a question?
This is the sketch that shows the pushingbox dashboard has updated and confirmed with an email.
URL syntax is shown in the sketch and I am using a Blynk button to trigger the webhook call.
/*************************************************************
Pushingbox.ino Webhook widget V0, GET no body json / txt
Url http://api.pushingbox.com/pushingbox?devid=[deviceID]&char1=/pin/
*************************************************************/
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[33] = "xxx";
char ssid[] = "xxx";
char pass[] = "xxx";
char server[] = "blynk-cloud.com";
char tags[7][5] = {"6196", "6753", "5655", "69EC", "9FFC"};
char owners[7][5] = {"per1", "per2", "per3", "per4", "per5"};
int freeSpots = 5;
char lastTag[5] = "69EC";
BlynkTimer timer;
BLYNK_WRITE(V0) // V0 Pushingbox webhook widget
{
String theResponse = param.asStr(); // nothing returned, same as a browser
Serial.println(theResponse);
}
void sendtoPushingbox()
{
int i = 0;
while (i < 5)
{
if (strcmp(tags[i], lastTag) == 0)
{
// line below sends to value display
Blynk.virtualWrite(V2, String(owners[i]) + String("&int1=") + String(freeSpots));
Serial.print(owners[i]);
Serial.print(" ");
Serial.println(freeSpots);
// line below sends to webhook widget
Blynk.virtualWrite(V0, String(owners[i]) + String("&int1=") + String(freeSpots));
}
i++;
}
}
// V1 not used
// V2 is a value display widget
BLYNK_WRITE(V3) // button to call webhook on V0
{
if(param.asInt() == 0)
{
sendtoPushingbox();
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, server);
}
void loop()
{
Blynk.run();
timer.run();
}
@costas Your code works perfectly well, thanks. Perhaps mine doesn’t work because I’m not using the Blynk timer in it? Is it usefull for you if I include my full code in my post?