Skip to content
Library for - simple way to connect your device to alexa
C++ C
Branch: master
Clone or download
Latest commit 009ef83 Dec 8, 2019

SinricPro (ESP8266 / ESP32 SDK)

Version 2.2.6


VS Code & PlatformIO:

  1. Install VS Code
  2. Install PlatformIO
  3. Install SinricPro library by using Library Manager
  4. Use included platformio.ini files from examples to ensure that all dependent libraries will installed automaticly.

sinricpro library manager


  1. Open Library Manager (Tools / Manage Libraries)
  2. Search for SinricPro and click Install
  3. Repeat step 2 for all dependent libraries!
  4. Open example in ArduinoIDE (File / Examples / SinricPro / ...)

ArduinoIDE Library Manager


ArduinoJson (Version 6.12.0)
WebSocketsClient (Version 2.2.0)


PlatformIO Arduino
Switch Switch
Doorbell Doorbell
- Lock
TemperatureSensor TemperatureSensor


Include SinricPro-Library (SinricPro.h) and SinricPro-Device-Libraries (eg. SinricProSwitch.h)

#include <SinricPro.h>
#include <SinricProSwitch.h>

Define your credentials from SinricPro-Portal (

#define APP_KEY    "YOUR-APP-KEY"    // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define SWITCH_ID  "YOUR-DEVICE-ID"  // Should look like "5dc1564130xxxxxxxxxxxxxx"

Define callback routine(s)

bool onPowerState(const String &deviceId, bool &state) {
  Serial.printf("device %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
  return true; // indicate that callback handled correctly

In setup()

  // create and add a switch to SinricPro
  SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
  // set callback function
  // startup SinricPro
  SinricPro.begin(APP_KEY, APP_SECRET);

In loop()


How to add a device?

Syntax is

  DeviceType& myDevice = SinricPro[DEVICE_ID];


  SinricProSwitch& mySwitch = SinricPro["YOUR-SWITCH-ID-HERE"];

Example 2 (alternatively)

  SinricProSwitch& mySwitch = SinricPro.add<SinricProSwitch>("YOUR-SWITCH-ID-HERE");

How to retrieve a device for sending an event?

Syntax is

  DeviceType& myDevice = SinricPro[DEVICE_ID];

Example 1

  SinricProDoorbell& myDoorbell = SinricPro["YOUR-DOORBELL-ID-HERE"];

Example 2 (alternatively)



  • Switch
  • Dimmable Switch
  • Light
  • TV
  • Speaker
  • Thermostat
  • Fan (US and non US version)
  • Lock
  • Doorbell
  • Temperaturesensor
  • Motionsensor
  • Contactsensor
  • Windows Air Conditioner

Full user documentation

Please see full user documentation here

You can’t perform that action at this time.