-->
Page 1 of 1

'SinricPro' does not name a type

PostPosted: Thu Jul 16, 2020 3:45 am
by qomibusu
Hi I am new to arduino and could really use some help. I recently bought a Wemos D1 Mini and was trying to connect it with my Alexa so when I said Alexa light on the light on the board would turn on. I keep getting errors though and don't know if it is because I don't have the right libraries or something else.
Here is my code:
#include <WebSocketsServer.h>
#include <WebSocketsClient.h>
#include <WebSockets.h>

#include <ArduinoJson.h>


/*
* Simple example for how to use multiple SinricPro Switch device:
* - setup 4 switch devices
* - handle request using multiple callbacks
*
* If you encounter any issues:
* - check the readme.md at https://github.com/sinricpro/esp8266-es ... /README.md
* - ensure all dependent libraries are installed
* - see https://github.com/sinricpro/esp8266-es ... arduinoide
* - see https://github.com/sinricpro/esp8266-es ... pendencies
* - open serial monitor and check whats happening
* - check full user documentation at https://sinricpro.github.io/esp8266-esp32-sdk
* - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one
*/

// Uncomment the following line to enable serial debug output
#define ENABLE_DEBUG

#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif

#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#endif

#include <WiFi.h>


#include "SinricPro.h"
#include "SinricProSwitch.h"

#define WIFI_SSID "Fios-76N3L"
#define WIFI_PASS "add7387kick2466nor"
#define APP_KEY "9d089287-6021-4397-9837-e748a6b2f632" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "594c537e-4966-424e-9c05-672aa8b8d1d3-fa605572-4cfe-41ef-8c97-961db9da51db" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"

#define light1 "5ed118eb76b86a477f5e44ec" // Should look like "5dc1564130xxxxxxxxxxxxxx"

#define BAUD_RATE 57600// Change baudrate to your need

bool onPowerState1(const String &deviceId, bool &state) {
Serial.printf("Device 1 turned %s\r\n", state?"on":"off");
return true; // request handled properly
}

// setup function for WiFi connection
void setupWiFi() {
Serial.printf("\r\n[Wifi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);

while (WiFi.status() != WL_CONNECTED) {
Serial.printf(".");
delay(250);
}

Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str());
}

// setup function for SinricPro

// setup SinricPro
SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); });
SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
SinricPro.begin(APP_KEY, APP_SECRET);
}

// main setup function
void setup() {
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
setupWiFi();
//setupSinricPro();
}

void loop() {
SinricPro.handle();
}



and here are the errors I keep getting:


'SinricPro' does not name a type

and

Error compiling for board WeMos D1 R2 & mini.

I could really use help thanks!

Re: 'SinricPro' does not name a type

PostPosted: Fri Jul 17, 2020 1:56 am
by pangolin
A few problems here:
1) Documentation clearly states that the includes should be:
#include <SinricPro.h>
#include <SinricProSwitch.h>
and *not* using quotes as you have.

2) I suspect you are using PlatformIO (or that the code was written for PlatformIO and you are using ArduinoIDE)
PlatformIO is NOT 100% ArduinoIDE-compatible. For example, #ifdef ESP8266 is a platformio bug as it should read #ifdef ARDUINO_ARCH_ESP8266 ...They have known about this for years, I myself have raised the issue about three times until I got fed up up with their lazy attitude to compatibility.

3) There are much better / simpler / easier ways to get Alexa functionality. Google "fauxmoesp" for example