Work From Home - CPX
Recently I have begun working from home everyday so I decided to use my Circuit Playground Express for automating some of my daily tasks.
The following project will instruct how to create a simple Work From Home helper using a Circuit Playground Express Arduino board with an ESP8266 wifi board.
The functionalities are -
1) Registering work hours using the CPX light sensor.
2) Setting a status on 'Slack' for times you are available\unavailable using the proximity sensor.
3) Setting Reminders for tasks such as getting up and taking a walk (for your health).
4) Setting reminder for events\meetings and defining a 'focus mode'.
The functionalities are easily configurable and can be extended for further usage.
Downloads
Supplies
1) Circuit Playground Express - https://www.adafruit.com/product/3333
2) ESP8266 board - https://www.zeptotronics.net/product/d1-mini-esp8...
3) Battery Holder - https://www.adafruit.com/product/727
4) 3 x AAA batteries
Before you start make the following connections from the CPX to the ESP8266-
1) ESP8266: GND -> CPX: GND
2) ESP8266: VCC -> CPX: VCC
3) ESP8266: RX -> CPX: TX(A7)
4) ESP8266: TX-> CPX: RX(A6)
Create a New Device Template on Blynk.com
Start be registering to Blynk.cloud if you don't already have an account. Next, create a new template and select the ESP8266 under hardware.
Defining the Datastreams
After defining the template, go back to 'templates' and select your newly created template. The next step is defining new datastreams. Go to 'Datastreams', on the right side, click on edit, and then select 'virtual pin'. Define the virtual pins as shown in the images (make sure that every pin has a correct data type and min/max values).
Setting Up the Dashboard
In order to control some of the parameters, we will set up the Blynk dashboard. On the same template, move to 'web dahsboard'. Add the widgets described in the first image. The full configurations list is-
1) Slider - Title: Proximity Threshold, Datastream: V3, MIN: 50, MAX: 200
2) Switch- Title:Focus- Turn Tv Off, Datastream: V4, ON VALUE: 1, OFF VALUE: 0
3) Switch- Title:Focus-Tv Mute, Datastream: V5, ON VALUE: 1, OFF VALUE: 0
4) Label - Title: Available Status, Datastream: V6
5) Label - Title:Unavailable Status, Datastream: V7
Creating a New Device
On Blynk dashboard, click on 'add new device' and choose 'from template'. select your device template and create new device.
Setting Up Integromat Webhooks
Register to Integromat.com if you don't already have an account. On Integromat, create a new scenario. Create a custom webhook and copy the link as shown in the image. Once you have the link, go back to Blynk. Under Settings->Developers->Webhooks, create a new webhook as specified in the image. Make sure to check the device you have created on blynk.
Defining the Google Sheets Integration
In order to keep up with hours report, we will use Integromat's integration with Google Sheets. Create a new sheets and name it whatever you want (I called it "Hours Report"). Start the sheet in the following format-
1) Cell A1 is the selected month (can be changed by the user).
2) Cell B1 is the title for the "in" column ('day start').
3) Cell C1 is the title for the "out" column ('day end').
4) Cell D1 is a counter and should be initially set to 2.
After defining the sheet, on Integromat create a router and make the first connection to a Google sheets "Add a row" as show in the image. Make sure to add a the "DAY_START" filter on the router. Do the same for "DAY_END" and create a chain of Google sheets - "Get a Cell"->"Update a Row"->"Update a Cell". Make sure to add the correct filters and definitions for each module (see images for detailed configurations).
Defining Slack Integration
In order to add the 'Slack' integration add a new module on Integromat, select Slack->Set Status. Make sure to use the correct filtering a value passing (the value should be "SLACK_AVAILABLE:[your status]"). Repeat this step for available and unavailable statuses.
Defining Google Calendar Integration
On Integromat, create a new scenario and select the module Google Calendar-> Watch events, select watching events by created date. After that, connect this module to a new module - Http->Make a request. The url should be-https://blynk.cloud/external/api/update?token={token}&V2=1 , where {token} should be replaced with your Blynk token. Your Blynk token can be found in the Blynk dashbaord, under 'Device Info'.
Defining Timed Http Request for 'take a Walk' Mode
Create another scenario on Integromat and choose Http->Make a request, the url should be https://blynk.cloud/external/api/update?token={token}&V1=1 , where {token} should be replaced with your Blynk token. Also, for sending the alert on regular intervals, select advanced time filtering and define it how you preffer. In the attached image the alert is sent every 2 hours, on weekdays (sun-thu) from 10AM to 6PM.
Running the Program
Download the attached files and place them in a folder called 'WorkFromHome'. Open the sketch 'WorkFromHome.ino' and add you Blynk template id, device name and auth token in the required places. Additionally, add your wifi network name and password in the required places. After this is done you can load the sketch to your CPX and you're good to go!
Usage
1) Connect the CPX to the batteries and place it near light sources that can be turned on/off according to work hours.
2) Go to Integromat.com and make sure all the defined scenarios are turned on.
3) In order to adjust the proximity go to Blynk dashboard and use the slide to change the value. To check it see if it turns green/red according to your proximity to it.
4) Toggle focus mode setting and change your available/unavailable using the Blynk dashboard.
When the lights are off the CPX leds should also be off. When you turn the lights on the leds will light in green or red if you are away from you work station.
When the leds are on it means that your workday has begun, and new meeting alerts \ walking alerts will start arriving.
Additional Resources
Blynk documentation - http://docs.blynk.cc/
Blynk examples - https://examples.blynk.cc/?board=ESP8266&shield=ES..
Integromat help & tutorials - https://support.integromat.com/hc/en-u