X-Ring with Google Calendar

As application for the X-Ring RGB Strip I came up with the following idea: querying the next event in my Google Calendar tagged with #wecker and then visualize the remaining time. I have illustrated the structure of all components in the following figure:

Google Calendar

The Wemos D1 mini queries the next event by accessing my Google Calendar. This is done by executing a Google Apps Script. Google Apps Script is very powerful because you can use Google Services with ease – everything is well documented, there are so many examples and you can even debug your scripts. Directly accessing the google calendar with read-access as specific user requires authentication (currently with an OAUTH mechanism). I was not able to find a way to register my microcontroller at this OAUTH server easily. So I decided to use a Google Apps Script as proxy – it requires authentication when executing it at the first time. Then it has read-access to your google calendar. This is super simple and flexible.

The script depends on the following libraries:

Moment – https://script.google.com/macros/library/versions/d/15hgNOjKHUG4UtyZl9clqBbl23sDvWMS8pfDJOyIapZk5RBqwL3i-rlCo

QUnit – https://script.google.com/macros/library/versions/d/13agWuzcPH32W4JJvOqOEYqeNHGihS63P2V-a-Vxz-c9WPIzZYBvIhs3m

If you want to run the script you have to add them to your script.

Google Apps Script Libraries

Then you can publish the script as Webapp.

Google Apps Script Publish Webapp

 

The script contains a little testbench to do some unit-tests. You can execute them by adding ?test to the exec URL of the webapp.

You can use your favourite HTTP Client to get the result from your webapp. Please notice that there is a 302 HTTP redirect when you call your webapp. This is visualized in the following figure.

Google Apps Script Webapp Redirect to actual content

For testing purposes on your computer you can use curl for example. -L to enable the location header flag to follow redirects

Then you are redirected to the final destination which is the output of the Google Apps Script.

Responses are JSON encoded:

No event currently:

Next event:

If you want to query the Google Apps Script from Arduino make sure to use a HTTP Client that follows redirects.

E.g.: https://github.com/cvonk/esp8266-WiFiClientSecureRedirect

MQTT

I like event-driven architectures especially in the IoT-Context. You can build your own eventbus for your home. The MQTT architecture is flexible, adaptive and robust – it perfectly fits my needs. You may ask yourself why MQTT is used at all in this application, because I could just take this event and visualize it on the X-Ring. Of course – but what if I want to add another device using this event information? I would have to refactor my X-Ring Google Calendar Application. I just took this effort already to make it even less coupled and hereby flexible.

Visualization

The app queries for events every 10 minutes. When it does an update it animates a color wheel. Then all LED black. Then it lightens up N LED representing the hours until the next event. I have created two openprocessing script visualizing the colorwheel animation:

 

Result

The is a video of the result. It is not true-color.

I’m looking forward to develop more apps using the X-Ring module. I can recommend it for use with any arduino and microcontroller in general.

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

  4 comments for “X-Ring with Google Calendar

  1. Avi
    22nd May 2018 at 20:23

    Great little project. I acquired an X-ring module a few days ago and like everyone else, I couldn’t find documentation. Then I came across your blog. Many thanks for you hard work.

    But then I came across this implementation. Amazing. Although I love the pretty lights that come from RGB LEDS, I’ve never really found much to do with them. This is an original idea and beautifully implemented. Welll done!

    • No3x
      22nd May 2018 at 20:38

      Hi Avi, thanks for your feedback. Make sure to read https://no3x.de/projects/x-ring/x-ring-missing-documentation and please post your own project when finished.

      • Azuria
        6th February 2022 at 19:51

        It looks like that site is down and just gives a WordPress error link :/

        • No3x
          6th February 2022 at 20:19

          What’s not working for you? I just did some maintenance some minutes ago. Is everything fine now?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Spelling error report

The following text will be sent to our editors: