An LCD sign to go on my door that displays what's currently happening in my calendar, called "Door Sign" because nobody who was sitting around me at the time had a better name.
Wire it up like:
Make a new project in the Spark online IDE named whatever you want, then copy in the contents of
door-sign.ino. Click the + button in the tab bar of the IDE, and add a .h and .cpp file for the LiquidCrystal library.
Then flash it to the Spark with the little lightning bolt button.
Put all the code on a Heroku thing.
Obtain a Google Client ID and Secret:
- Go to the Google Developers Console.
- Select a project, or create a new one.
- In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs, make sure the status is ON for the Calendar API.
- In the sidebar on the left, select Credentials.
- In either case, you end up on the Credentials page and can create your project's credentials from here.
- If you haven't done so already, create your OAuth 2.0 credentials by clicking Create new Client ID under the OAuth heading. Use the "Installed Application" option, with "Other" as the platform. Next, look for your application's client ID and client secret in the relevant table. You may also create and edit redirect URIs from this page.
Add your config:
heroku config:set CLIENT_ID="abc" CLIENT_SECRET="def" SPARK_ID="mysparkid" SPARK_TOKEN="mysparktoken"
Spark ID is the device ID for your core that can be found in the IDE by clicking the target symbol in the bottom left and then the arrow next to your core. Your Spark token can be found in the settings page of your Spark IDE.
Next, find your calendar IDs
- Visit Google Calendar in your web browser.
- In the calendar list on the left, click the down-arrow button next to the appropriate calendar, then select Calendar settings.
- In the Calendar Address section, locate the Calendar ID listed next to the XML, ICAL and HTML buttons.
- Copy the Calendar ID.
bin/door-sign and add the IDs and each calendar's friendly name.
Next, you need to obtain an access token (refresh token). To do so, run this command and follow the instructions:
heroku run bundle exec ruby bin/authorize
Then add a scheduler to run the update script:
heroku addons:add scheduler
Then set it up to run this command every ten minutes:
bundle exec ruby bin/door-sign
Then stick the sign on your door and be happy.