ah. sorry, last question in this topic. nodejs blynk library support Table widget yet? thks
About RTC Widget, I have to update Library? or Server?
I recently stumbled across some details on GitHub that convinced me that updating private Google Sheets should be possible with Blynk and specifically with the WebHook widget. It takes a bit of doing but doesnât have the cons associated with Zapier.
The secret is Google Scripting which allows you to create a bit of code and then publish this as a web app. Google scripting is accessed in your Google Sheet from Tools and then select Script editor.
When accessing Google Sheets (and other Google online tools) the authentication involves a HTTPS redirect from one site to another which is not normally available with ESPâs. However a âHTTPSRedirectâ library was published last year on GitHub for ESPâs, so itâs now possible. The library is at https://github.com/electronicsguy/ESP8266/tree/master/HTTPSRedirect and Sujay (@electronicsguy) has provided a sample Google script and ESP sketch to update private Google Sheets.
After some modification of the script and the sketch I now have the following:
The Webhook sends just one string with the data from three sensors and this appears in column A of the sheet. The final part of the webhook url is:
/pin[0]/%3C/pin[1]/%3E/pin[2]
(where %3C is url encoding for < and %3E is >)
Column B is simply the time of the update (from the Google script) and Column C a sequential log of each update. Columns D, E and F manipulates the data in column A to split it out into each of the 3 sensors. Google script takes care of copying down the formula as each new row is added to the sheet.
My project has updates set on a 60s timer and a button tied to the Webhook widget for manual adhoc updates.
@Dmitriy what I have noticed is that the Webhook activation from a button fails from time to time. Stopping the project, clicking the Webhook widget, exiting the widget and restarting the project gets Webhook back up and running. Google allow 1 read and 1 write per user (for up to 5 users) per second as standard so itâs not a rejection by Google. ESP is connected throughout when the Webhook stops running.
@Dmitriy please see screenshot of Google Sheet and Serial Monitor below.
Yellow entries are Webhook button working fine.
Red entries are Webhook button crashed even though the sketch code is running fine.
The last red entry is after stopping the project and restarting it, still fails.
The blue entry is âmy fixâ (stop project, go into the webhook widget, back out and restart the project).
This is VERY consistent and indicates to me that somewhere along the line the 120 character url in the widget is being lost. By going back into the widget the url becomes available again.
For logging purposes the times shown (column B) are GMT + 2 hours. My login details are blynk@paulâŚ
@Costas yeap. I see errors for your acc. Google doesnât return nothing meaningful so. WebHook widget is blocked after 10 repeated failures. To avoid spamming. So all is correct here . You need to find out why your webhook fails.
@Dmitriy is it 10 consecutive failures or 10 failures over a given period?
There certainly isnât 10 consecutive failures, it just simply stops working. Does going back into the widget reset your anti spam system and is that the reason why my fix works?
Running the Google sheets updates automatically for 10 hours last night (at 1 minute intervals) gave a 98% success rate, without Webhooks but still via Blynk. So the system is robust, will check further from my side.
Consecutive. Any correct request will reset counter.
Yes. It is supposed to work like that.
I see in log 14 failures during 25 minutes.
Do you see 3 consecutive successful transmissions right now with 19.59<17.02>17.12?
I can see the Sheet being updated in real time so the webhook button is working.
I see 3 failures.
And failure means non 200 response. Maybe this is the reason.
Just sent 3 more successfully as 23.89<20.37>23.57
I think your idea of a failure is different to Googleâs
Please check what status code google return to you on your request.
I think you are right. As per my comments yesterday in this thread it is quite technically demanding to cover the required authentication and it involves https redirects. So I think you are missing the redirect and not seeing a 200 response.
The return message from the Google script created by the guy that wrote the https redirect library is in the format of:
Successfully wrote: 16.25<18.95>23.45 into spreadsheet.
Would it help If I was to change this to:
200 Successfully wrote: 16.25<18.95>23.45 into spreadsheet.
Edit: made the changes but still being locked out with your anti spam system.
@Dmitriy for reference the webhooks data is sent to the following Google url:
https://script.google.com/macros/s/AâŚ
and if successful this does a redirect to a different Google url of:
https://script.googleusercontent.com/macros/echo?user_content_key=PâŚ
It is the second url that returns the â200 Successfully wrote âŚâ message.
Any way around this?
Iâll add 302 as valid response code.
You are a @Dmitriy
I was just thinking about 302 codes.
Can you please let me know when you make the change.
Thanks for the commit.
Does the commit go live on your server straight away or some time later when you âresetâ the server?
No .
Yes