Skip to content
ChromeCast Arduino Button
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This Arduino sketch allows you to control media playing on a ChromeCast device.

The sketch can control all the existing Google apps that support ChromeCast including YouTube, Google Music and Google Movies. Netflix is not supported since it uses a proprietary protocol for media control.

This sketch requires an Arduino Ethernet shield and a button. The sketch has been tested with an Arduino Uno and a Tactile Button switch and a Massive Arcade Button with LED.

The sketch requires this websocket library which has to be installed in the libraries directory of your Arduino IDE. The websocket library has been modified to work with ChromeCast devices. Use the Arduino IDE to upload the code onto an Arduino device.

To customize the sketch for your ChromeCast device, simply update ChromeCast device IP address in the sketch. The sketch assumes a button is on pin A0. Uncomment the loop() code if you want to use pin 2 for the button. You can also put a LED on pin 7 to get feedback when the network is initialized and the button is pressed.

To control playback, the sketch makes a websocket connection to the current app running on the ChromeCast device. These steps are done in order:

  1. Check if there is an app running on the ChromeCast device and get its app id.
  2. Get the app status to get the connection service URL.
  3. Use the connection service URL to get the websocket address.
  4. Create a websocket connection.
  5. Send RAMP PLAY/STOP messages to control media playback.
  6. Close the websocket connection.
The code toggles between the play and pause state every time the button is pressed.

Watch this video to see the sketch in action.

Other apps developed by Entertailion:

You can’t perform that action at this time.