When I walk away from my desk for lunch, I always forget to update my Slack status. I could use my phone, but then I have to unlock it, open Slack, pick an emoji, etc... Too many buttons, too much work.
If only some piece of hardware existed to allow me to update my Slack status with a pre-programmed button... 🤔
The M5Stack Core2 has three touch buttons and a magnet in the back, so it will live on the side of my fridge. Each button makes a Slack API call with a pre-programmed status, with the option to "reset" my status on the last button.
booting.mp4
status.mp4
- This is literally my first time writing C-type code and will be the sloppiest thing you see today.
- Your Slack API token is basically your username and password in one. Please take that into consideration before using it here.
- Please don't commit the
arduino_secrets.h
file to source control!
You need an M5Stack Core2. I believe an M5Stack Core would work as well (I haven't tested this), but some hardware-specific functions (e.g., brightness, vibration) won't work.
If you don't want to purchase from M5Stack's website (because of the long shipping times), you can try:
Both UIFlow and PlatformIO would work for this project, and I even believe UIFlow offers more features than the Arduino library. However, Arduino is the gold-standard and is the easiest to setup from scratch.
-
Install the Arduino IDE. There are step-by-step instructions for Windows, Mac, and Linux here. Once installed, open the Arduino IDE.
-
Add support for ESP32 boards by going to
File-->Preferences-->Additional Board Manager URLs
and then paste in the URL below. If you have a URL in the box already, separate them with a comma.
https://dl.espressif.com/dl/package_esp32_index.json
-
Go to
Tools-->Board-->Boards Manager
, search foresp32
and install. -
Go to
Tools-->Manage Libraries
, search form5core2
and install (be sure to install the entry byM5Stack
). -
Go to
Tools-->Manage Libraries
, search forArduino_JSON
and install (be sure to install the entry byArduino
). -
I also had to make the following changes:
- Change
Tools-->Upload Speed
from921600
to115200
- Change
Tools-->Port
to/dev/ttyACM0
- Install the
pyserial
package on my distrubtion
The easiest way to create a Slack API token is to create a single-use app for yourself, then get an API token for that app.
-
Click here, then choose to create an app from an app manifest.
-
Sign into the workspace that you want this app to access. This will be the workspace that you want the M5Stack to access.
-
Copy/paste this YAML code into the box. This is the app manifest with the minimum permissions needed to update your user's status.
-
Click Create.
-
Click Install to Workspace.
-
Navigate to OAuth & Permissions, then copy the User OAuth Token. It will begin with
xoxp-
. This token will be needed later.
- Clone this repo.
git clone https://github.com/loganmarchione/m5stack-slack-status-updater.git
cd m5stack-slack-status-updater/M5StackSlackStatusUpdater
- Rename the
arduino_secrets_sample.h
file toarduino_secrets.h
mv arduino_secrets_sample.h arduino_secrets.h
- Update the
arduino_secrets.h
file to include your variables.
- WiFi SSID
- WiFi Password
- Slack API token
-
Update the
variables
section of the5StackSlackStatusUpdater.ino
file. This is where you will set your three Slack statuses and their corresponding emojis. -
Click
Upload
in the IDE and wait for the program to compile and upload.
- Do some printing to the serial console with more detailed info
- Maybe switch to UIFlow since the Arduino library seems to be crippled?
- Do some error handling with API call
- Add buttons that can be combinations (e.g., ButtonA+ButtonB)
- Add ability to change presence (e.g., available, away)