| Project Title | Breif description | languages | ||
|---|---|---|---|---|
Microsoft Team mute switch |
An IoT enabled switch that mutes and unmute a user on a Microsoft Teams call |
|
This project shows how to use a switch to mute and unmute a user on a teams call. It involves the development of a Python console application and an IoT embedded device. The Python app uses the Mircosoft Graph API to communicate with the user data in Azure Active Directory, while it gets the switch press and release event from the hardware via BLE, the hardware consist of an esp32 and a 16mm led switch.
This repo includes the python desktop application, the esp32 firmware source code as well as the hardware design. The purpose of this project is to provide a solution that enables user quickly mute and unmute their microphone while on a teams call, this would improve the user experience while using teams, the switch features a led that lights up and provide a good visual feedback that assures the user if they are muted in their active call or not.
The console application:
- Gets a token from microsoft identity platform in its own name (without a user)
- Waits for a call from the user
- After receiving a call from user, it answers the call, then saves the call id and participant id
- Connect to switch BLE receiver
- Start listening to switch state from the esp32 via BLE
- Send a mute or unmute command to the server via microsoft graph teams api depending on change of switch state
The esp32 firmware:
- Setup BLE, i.e. service id, characteristics id and switch input gpio
- Start advertising BLE service
- On receiving PC connection it start to broadcast switch state
IDE: vs code
- Python 3+
- MSAL: The Microsoft Authentication Library is used to authenticate the user and retrieve the user data.
- Bleak: Bleak is a GATT client software, capable of connecting to BLE devices acting as GATT servers, it is used to communicate with the esp32 module
- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see how to get an Azure AD tenant.
- Arduino sdk
- 16mm Illuminated Pushbutton - Red Latching On/Off Switch
- ESP32-S3-DevKitM-1-N8 - ESP32-S3-MINI-1 Dev Board - 8 MB
- Breadboarding wire bundle
- Half-size breadboard
- Lithium Ion Battery - 3.7v 2000mAh
- USB LiIon/LiPoly charger - v1.2
- PLA Enclosure: 100mm x 100mm x 70mm
- V2 usb cable
- Soldering iron and lead
To run this sample, you'll need:
From your shell or command line:
git clone git@github.com:cliffordolaw/msft_mute_button.gitGo to the local repo folder
cd msft_mute_buttonNB: If you don't have a developer's account open one here
-
Register the Azure AD app: Go to Microsoft identity platform for developers App registrations
-
Select New registration.
- In the Name section, enter a meaningful application name that will be displayed to users of the app, for example
teams-mute-app. - In the Supported account types section, select Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox).
- Select Register to create the application.
- Type a key description (of instance
app secret), - Select a key duration of either In 1 year, In 2 years, or Never Expires.
- When you press the Add button, the key value will be displayed, copy, and save the value in a safe location.
- You'll need this key later to configure the project in Visual Studio. This key value will not be displayed again, nor retrievable by any other means so record it as soon as it is visible from the Azure portal.

- In the list of pages for the app, select API permissions
-
Click the Add a permission button and then,
-
Ensure that the Microsoft APIs tab is selected
-
In the Commonly used Microsoft APIs section, click on Microsoft Graph
-
In the Application permissions section, ensure that the right permissions are checked: a. CallRecords.Read.All b. Calls.AccessMedia.All c. Calls.Initiate.All d. Calls.InitiateGroupCall.All e. Calls.JoinGroupCall.All f. Calls.JoinGroupCallAsGuest.All g. User.Read.All h. User.ReadWrite.All
-
Select the Add permissions button
-
At this stage permissions are assigned correctly but the client app does not allow interaction, no consent can be presented via a UI, therefore we have to give the application admin consent. Click the Grant/revoke admin consent for {tenant} button, and then select Yes when you are asked if you want to grant consent for the requested permissions for all account in the tenant. You need to be an Azure AD tenant admin to do this.
-
On the app Overview page, find the Application (client) ID and Directory (tenant) ID values and record it for later. You'll need it to configure the Visual Studio configuration file for this project.

- Open the
config_param.jsonfile - Find the string key
tenant_idreplace it with your Azure AD tenant name (tenant id). - Find the string key
client_idand replace the existing value with the application ID (clientId) copied from the Azure portal. - Find the string key
secretand replace the existing value with the secret key you saved from the Azure portal. - Find the string key
callbackUriand replace with a callback uri
-
Create a new bot on Bot framework. Alternately, you can also create your bot if you select the
Create a botbutton in the Bot Framework portal. -
Following the first link in No. 1, fill in the following input accordingly

-
On the configuration page of the
Microsoft Teamschannel
- Select the Calling tab
- Select Enable calling
- update
Webhook (for calling)with the URI where you'd like to receive incoming call notifications and other events, for example https://contoso.com/teamsapp/api/calling.
- Save all edits and publish bot
Connect the hardware components as shown in the image below. The breadboard design doesn't include the specific esp32 devkit module used in this project because of it's shape wasn't available in the design software used, so I used the closest esp module shape that was available and this is the big white object with a blue screen on the breadboard. While making your connections simply connect your esp32 S3 devkit with the remaining components while following the pins used in the breadboard design.
Use the physical connection image below for more help

See other hardware connection images for guidiance in the
- Plug the esp32-s3 Devkit to the breadboard
- Plug the resistor to the board (1k resistor)
- Connect four wires to the switch terminals. You can use a Crimp terminal connector, but in this project I soldered the wires to the termianls.
- Connect the +ve/Anode wire (solid orange wire) from the switch led to one terminal of the resistor
- Connect the other terminal of the resitor to the 3v3 pin on the esp32-S3
- Connect one Termianl (stripe green wire) of the button the the GND rail of the breadboard
- insert the following pins on a single row on the bread board - -ve/Cathode wire (Stripe orange wire) from the switch led - The second terminal of the switch button (solid green wire) - Pin 1 from the esp32-s3
- Connect the 5v and G pins from the esp32-s3 to the red (+) and blue (-) lines on the breadboard respectively
- Connect the Load + and - pins from the charging module to the same red (+) and blue (-) lines on the breadboard respectively
- verify that all connections have been made correctly, see close up images of each wiring in the
for more certainty
- Connect the Battery connector to the Batt terminal on the charging module
- Plug the charging module to a 5v usb power supply to charge the system, leave the battery for a few minutes to get properly charged NB: If the application fails to find the BLE name of the esp32-s3 try powering the esp32-s3 directly, the battery may not yet be charged well enough
- Download and install vs code
- Download and install arduino IDE
- Install arduino and c/c++ extension in vs code
- Open the esp32_arduino_firmware project in vscode
- Install the esp32-s3 board in vs code:
- Open command pallette
cmd shift p- EnterArduino Board Manager- GotoAdditional links- Enter this link:https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Select desired board:
- Open command pallette
shift cmd p- Enterchange board type- SelectEsp32-S3 Dev module - Connect esp32-s3 devkit board:
- command pallette
- Enter
select serial port - Connect the cable to the "uart-usb" port and not "usb-otg" port, although both can be used to load the module but only "uart-usb" can be used for getting console debug messages
- Install the Button library by Michael Adams
- Open command pallette
shift cmd p- EnterArduino library manager- Search forButtonand install `Button by Michael Adams - Open the main.ino file and run the "Arduino: Upload" command at the top right corner of the
main.inowindow NB: ensure the hardware is powered up
-
Log on to your teams account
-
Start a call with the teams bot you created, it should be present in your tenant
-
First, you'll need to a virtual environment as follows:
virtualenv venv
-
Activate the virtual environment For Max:
source ./venv/bin/activateFor Windows
./venv/Scripts/activate
-
Install the dependencies using pip
pip install -r requirements.txt
NOTE: A common error while running the application would be "BleakError("Bluetooth device is turned off")" all you have to do here is simply give the application permission to use the PC's Bluetooth, on mac this would be a pop up box. Also do not forget to fill up the "config_param.json" file appropriately
If the callbackUri was setup then simply place a call to the bot from inside microsoft teams applcation
-
Run the pyton desktop application without any parameter
python app.py
-
The application will return a list of all the users in your tenant, first select your account index, then select the index of the user you want to call, in this sample I called both my microsoft developer account and my other individual account.

-
After answering the call on your two devices just press the button and see the system in action - The mute button retrieves the participant id - And mutes bot the bot and the first user from your selection in #2 above, although there is a limitation with the microsoft at the moment, the bot can only mute this user but cannot unmute.

For more information, check out these recommended resources









