Posts: 14
Threads: 3
Joined: Feb 2021
Reputation:
0
Please let me know any solution
Posts: 6,371
Threads: 827
Joined: Oct 2020
Reputation:
157
do you use by sinric.com ?
Posts: 3
Threads: 0
Joined: May 2021
Reputation:
0
(09-10-2021, 12:06 AM)admin Wrote: do you use by sinric.com ? Sinric will stop soon
only sinric pro
can you provide solution to use sinric pro?
Posts: 3
Threads: 0
Joined: May 2021
Reputation:
0
(09-10-2021, 12:06 AM)admin Wrote: do you use by sinric.com ?
I have followed the instructions to install alexa without third party. But it did not work due to discovery error
Can I go back to senric
I tried sinric, it is not working anymore. Do I need to restore the original firmware before flashing the one in this thread (alexa without 3rd party)
Can you provide the original firmware please?
Posts: 6,371
Threads: 827
Joined: Oct 2020
Reputation:
157
you can see this video, work without sinric: https://youtu.be/_w_jyZHOEEQ
Posts: 4
Threads: 1
Joined: Nov 2020
Reputation:
0
This works fine for me. Thanks
Code: #ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#define ESPALEXA_MAXDEVICES 32
#include <Espalexa.h>
#define R2 2
// prototypes
boolean connectWifi();
//callback functions
void F1LightChanged(uint8_t brightness);
void F2LightChanged(uint8_t brightness);
void F3LightChanged(uint8_t brightness);
void F4LightChanged(uint8_t brightness);
void F5LightChanged(uint8_t brightness);
void F6LightChanged(uint8_t brightness);
void F7LightChanged(uint8_t brightness);
void F8LightChanged(uint8_t brightness);
void F9LightChanged(uint8_t brightness);
void F10LightChanged(uint8_t brightness);
void F11LightChanged(uint8_t brightness);
void F12LightChanged(uint8_t brightness);
void F13LightChanged(uint8_t brightness);
void F14LightChanged(uint8_t brightness);
void F15LightChanged(uint8_t brightness);
void F16LightChanged(uint8_t brightness);
void F17LightChanged(uint8_t brightness);
void F18LightChanged(uint8_t brightness);
void F19LightChanged(uint8_t brightness);
void F20LightChanged(uint8_t brightness);
void F21LightChanged(uint8_t brightness);
void F22LightChanged(uint8_t brightness);
void F23LightChanged(uint8_t brightness);
void F24LightChanged(uint8_t brightness);
void F25LightChanged(uint8_t brightness);
void F26LightChanged(uint8_t brightness);
void F27LightChanged(uint8_t brightness);
void F28LightChanged(uint8_t brightness);
void F29LightChanged(uint8_t brightness);
void F30LightChanged(uint8_t brightness);
void F31LightChanged(uint8_t brightness);
void F32LightChanged(uint8_t brightness);
// Change this!!
// WiFi Credentials
const char* ssid = "1111";
const char* password = "2222";
// device names
String Device_1_Name = "luce 1";
String Device_2_Name = "luce 2";
String Device_3_Name = "luce 3";
String Device_4_Name = "luce 4";
String Device_5_Name = "luce 5";
String Device_6_Name = "luce 6";
String Device_7_Name = "luce 7";
String Device_8_Name = "luce 8";
String Device_9_Name = "luce 9";
String Device_10_Name ="luce 10";
String Device_11_Name ="luce 11";
String Device_12_Name ="luce 12";
String Device_13_Name ="luce 13";
String Device_14_Name ="luce 14";
String Device_15_Name ="luce 15";
String Device_16_Name ="luce 16";
String Device_17_Name ="luce 17";
String Device_18_Name ="luce 18";
String Device_19_Name ="luce 19";
String Device_20_Name ="luce 20";
String Device_21_Name ="luce 21";
String Device_22_Name ="luce 22";
String Device_23_Name ="luce 23";
String Device_24_Name ="luce 24";
String Device_25_Name ="luce 25";
String Device_26_Name ="luce 26";
String Device_27_Name ="luce 27";
String Device_28_Name ="luce 28";
String Device_29_Name ="luce 29";
String Device_30_Name ="luce 30";
String Device_31_Name ="luce 31";
String Device_32_Name ="luce 32";
unsigned long Millis = 0;
unsigned long PreviousMillis = 0;
boolean Initialized = false;
boolean wifiConnected = false;
Espalexa espalexa;
void setup()
{
Serial.begin(115200);
pinMode(R2, OUTPUT);
pinMode(R2, LOW);
PreviousMillis = millis();
// Initialise wifi connection
wifiConnected = connectWifi();
if (wifiConnected)
{
// Define your devices here.
espalexa.addDevice(Device_1_Name,F1LightChanged);
espalexa.addDevice(Device_2_Name,F2LightChanged);
espalexa.addDevice(Device_3_Name,F3LightChanged);
espalexa.addDevice(Device_4_Name,F4LightChanged);
espalexa.addDevice(Device_5_Name,F5LightChanged);
espalexa.addDevice(Device_6_Name,F6LightChanged);
espalexa.addDevice(Device_7_Name,F7LightChanged);
espalexa.addDevice(Device_8_Name,F8LightChanged);
espalexa.addDevice(Device_9_Name,F9LightChanged);
espalexa.addDevice(Device_10_Name,F10LightChanged);
espalexa.addDevice(Device_11_Name,F11LightChanged);
espalexa.addDevice(Device_12_Name,F12LightChanged);
espalexa.addDevice(Device_13_Name,F13LightChanged);
espalexa.addDevice(Device_14_Name,F14LightChanged);
espalexa.addDevice(Device_15_Name,F15LightChanged);
espalexa.addDevice(Device_16_Name,F16LightChanged);
espalexa.addDevice(Device_17_Name,F17LightChanged);
espalexa.addDevice(Device_18_Name,F18LightChanged);
espalexa.addDevice(Device_19_Name,F19LightChanged);
espalexa.addDevice(Device_20_Name,F20LightChanged);
espalexa.addDevice(Device_21_Name,F21LightChanged);
espalexa.addDevice(Device_22_Name,F22LightChanged);
espalexa.addDevice(Device_23_Name,F23LightChanged);
espalexa.addDevice(Device_24_Name,F24LightChanged);
espalexa.addDevice(Device_25_Name,F25LightChanged);
espalexa.addDevice(Device_26_Name,F26LightChanged);
espalexa.addDevice(Device_27_Name,F27LightChanged);
espalexa.addDevice(Device_28_Name,F28LightChanged);
espalexa.addDevice(Device_29_Name,F29LightChanged);
espalexa.addDevice(Device_30_Name,F30LightChanged);
espalexa.addDevice(Device_31_Name,F31LightChanged);
espalexa.addDevice(Device_32_Name,F32LightChanged);
espalexa.begin();
}
else
{
while (1)
{
Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
delay(5000);
}
}
}
void loop()
{
espalexa.loop();
delay(1);
}
//our callback functions
void F1LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,1,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,1,0");
digitalWrite(R2, LOW);
}
}
void F2LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,2,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,2,0");
digitalWrite(R2, LOW);
}
}
void F3LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,3,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,3,0");
digitalWrite(R2, LOW);
}
}
void F4LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,4,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,4,0");
digitalWrite(R2, LOW);
}
}
void F5LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,5,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,5,0");
digitalWrite(R2, LOW);
}
}
void F6LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,6,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,6,0");
digitalWrite(R2, LOW);
}
}
void F7LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,7,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,7,0");
digitalWrite(R2, LOW);
}
}
void F8LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,8,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,8,0");
digitalWrite(R2, LOW);
}
}
void F9LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,9,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,9,0");
digitalWrite(R2, LOW);
}
}
void F10LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,10,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,10,0");
digitalWrite(R2, LOW);
}
}
void F11LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,11,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,11,0");
digitalWrite(R2, LOW);
}
}
void F12LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,12,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,12,0");
digitalWrite(R2, LOW);
}
}
void F13LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,13,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,13,0");
digitalWrite(R2, LOW);
}
}
void F14LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,14,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,14,0");
digitalWrite(R2, LOW);
}
}
void F15LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,15,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,15,0");
digitalWrite(R2, LOW);
}
}
void F16LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,16,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,16,0");
digitalWrite(R2, LOW);
}
}
void F17LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,17,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,17,0");
digitalWrite(R2, LOW);
}
}
void F18LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,18,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,18,0");
digitalWrite(R2, LOW);
}
}
void F19LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,19,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,19,0");
digitalWrite(R2, LOW);
}
}
void F20LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,20,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,20,0");
digitalWrite(R2, LOW);
}
}
void F21LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,21,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,21,0");
digitalWrite(R2, LOW);
}
}
void F22LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,22,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,22,0");
digitalWrite(R2, LOW);
}
}
void F23LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,23,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,23,0");
digitalWrite(R2, LOW);
}
}
void F24LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,24,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,24,0");
digitalWrite(R2, LOW);
}
}
void F25LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,25,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,25,0");
digitalWrite(R2, LOW);
}
}
void F26LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,26,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,26,0");
digitalWrite(R2, LOW);
}
}
void F27LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,27,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,27,0");
digitalWrite(R2, LOW);
}
}
void F28LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,28,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,28,0");
digitalWrite(R2, LOW);
}
}
void F29LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,29,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,29,0");
digitalWrite(R2, LOW);
}
}
void F30LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,30,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,30,0");
digitalWrite(R2, LOW);
}
}
void F31LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,31,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,31,0");
digitalWrite(R2, LOW);
}
}
void F32LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,32,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,32,0");
digitalWrite(R2, LOW);
}
}
// connect to wifi – returns true if successful or false if not
boolean connectWifi()
{
boolean state = true;
int i = 0;
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");
// Wait for connection
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
// Serial.print(".");
if (i > 20) {
state = false; break;
}
i++;
}
Serial.println("");
if (state) {
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
pinMode(R2, HIGH);
}
else {
Serial.println("Connection failed.");
pinMode(R2, LOW);
}
return state;
}
Posts: 10
Threads: 0
Joined: Oct 2021
Reputation:
0
Hello, i updated the kc 868 h32b with the last firmware and i changed the code of the ESP8266 for 32 relay, as you showed in your video, but the Board crash when i use Alexa Routines, and i can’t turn on or off the lights with the buttons, and i need to reboot all.
If i turn on/off lights with alexa one at a time, it works
In the attached video, i asked to Alexa to turn on all lights, and the board crash, i can’t turn on or off the lights with the buttons.
Then i asked to turn on and off lights one at a time, and it works.
In the end i asked to turn off all lights, and the board turned off only 2-3 light, and not all of them.
Posts: 6,371
Threads: 827
Joined: Oct 2020
Reputation:
157
Can you try the above arduino code? now we suggest use raspberry pi running Node-Red for alexa or google home. because sinric.com not free now.
Posts: 10
Threads: 0
Joined: Oct 2021
Reputation:
0
(10-04-2021, 12:04 AM)admin Wrote: Can you try the above arduino code? now we suggest use raspberry pi running Node-Red for alexa or google home. because sinric.com not free now.
Code: #ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#define ESPALEXA_MAXDEVICES 32
#include <Espalexa.h>
#define R2 2
// prototypes
boolean connectWifi();
//callback functions
void F1LightChanged(uint8_t brightness);
void F2LightChanged(uint8_t brightness);
void F3LightChanged(uint8_t brightness);
void F4LightChanged(uint8_t brightness);
void F5LightChanged(uint8_t brightness);
void F6LightChanged(uint8_t brightness);
void F7LightChanged(uint8_t brightness);
void F8LightChanged(uint8_t brightness);
void F9LightChanged(uint8_t brightness);
void F10LightChanged(uint8_t brightness);
void F11LightChanged(uint8_t brightness);
void F12LightChanged(uint8_t brightness);
void F13LightChanged(uint8_t brightness);
void F14LightChanged(uint8_t brightness);
void F15LightChanged(uint8_t brightness);
void F16LightChanged(uint8_t brightness);
void F17LightChanged(uint8_t brightness);
void F18LightChanged(uint8_t brightness);
void F19LightChanged(uint8_t brightness);
void F20LightChanged(uint8_t brightness);
void F21LightChanged(uint8_t brightness);
void F22LightChanged(uint8_t brightness);
void F23LightChanged(uint8_t brightness);
void F24LightChanged(uint8_t brightness);
void F25LightChanged(uint8_t brightness);
void F26LightChanged(uint8_t brightness);
void F27LightChanged(uint8_t brightness);
void F28LightChanged(uint8_t brightness);
void F29LightChanged(uint8_t brightness);
void F30LightChanged(uint8_t brightness);
void F31LightChanged(uint8_t brightness);
void F32LightChanged(uint8_t brightness);
// Change this!!
// WiFi Credentials
const char* ssid = "----SSID----";
const char* password = "----PASSWORD----";
// device names
String Device_1_Name = "luce salotto 1";
String Device_2_Name = "luce salotto 2";
String Device_3_Name = "luce cucina";
String Device_4_Name = "luce antibagno giorno";
String Device_5_Name = "luce bagno giorno";
String Device_6_Name = "luce corridoio";
String Device_7_Name = "luce camera";
String Device_8_Name = "luce studio";
String Device_9_Name = "luce bagno notte";
String Device_10_Name ="luce balcone";
String Device_11_Name ="luce portico";
String Device_12_Name ="luce giardino";
String Device_13_Name ="luce scala";
String Device_14_Name ="luce sottoscala";
String Device_15_Name ="luce cantina";
String Device_16_Name ="luce garage";
String Device_17_Name ="rele 17";
String Device_18_Name ="rele 18";
String Device_19_Name ="rele 19";
String Device_20_Name ="monitor";
String Device_21_Name ="rele 21";
String Device_22_Name ="rele 22";
String Device_23_Name ="rele 23";
String Device_24_Name ="rele 24";
String Device_25_Name ="rele 25";
String Device_26_Name ="rele 26";
String Device_27_Name ="rele 27";
String Device_28_Name ="rele 28";
String Device_29_Name ="rele 29";
String Device_30_Name ="rele 30";
String Device_31_Name ="rele 31";
String Device_32_Name ="rele 32";
//unsigned long Millis = 0;
//unsigned long PreviousMillis = 0;
//boolean Initialized = false;
boolean wifiConnected = false;
Espalexa espalexa;
void setup()
{
Serial.begin(115200);
pinMode(R2, OUTPUT);
pinMode(R2, LOW);
//PreviousMillis = millis();
// Initialise wifi connection
wifiConnected = connectWifi();
if (wifiConnected)
{
// Define your devices here.
espalexa.addDevice(Device_1_Name,F1LightChanged);
espalexa.addDevice(Device_2_Name,F2LightChanged);
espalexa.addDevice(Device_3_Name,F3LightChanged);
espalexa.addDevice(Device_4_Name,F4LightChanged);
espalexa.addDevice(Device_5_Name,F5LightChanged);
espalexa.addDevice(Device_6_Name,F6LightChanged);
espalexa.addDevice(Device_7_Name,F7LightChanged);
espalexa.addDevice(Device_8_Name,F8LightChanged);
espalexa.addDevice(Device_9_Name,F9LightChanged);
espalexa.addDevice(Device_10_Name,F10LightChanged);
espalexa.addDevice(Device_11_Name,F11LightChanged);
espalexa.addDevice(Device_12_Name,F12LightChanged);
espalexa.addDevice(Device_13_Name,F13LightChanged);
espalexa.addDevice(Device_14_Name,F14LightChanged);
espalexa.addDevice(Device_15_Name,F15LightChanged);
espalexa.addDevice(Device_16_Name,F16LightChanged);
espalexa.addDevice(Device_17_Name,F17LightChanged);
espalexa.addDevice(Device_18_Name,F18LightChanged);
espalexa.addDevice(Device_19_Name,F19LightChanged);
espalexa.addDevice(Device_20_Name,F20LightChanged);
espalexa.addDevice(Device_21_Name,F21LightChanged);
espalexa.addDevice(Device_22_Name,F22LightChanged);
espalexa.addDevice(Device_23_Name,F23LightChanged);
espalexa.addDevice(Device_24_Name,F24LightChanged);
espalexa.addDevice(Device_25_Name,F25LightChanged);
espalexa.addDevice(Device_26_Name,F26LightChanged);
espalexa.addDevice(Device_27_Name,F27LightChanged);
espalexa.addDevice(Device_28_Name,F28LightChanged);
espalexa.addDevice(Device_29_Name,F29LightChanged);
espalexa.addDevice(Device_30_Name,F30LightChanged);
espalexa.addDevice(Device_31_Name,F31LightChanged);
espalexa.addDevice(Device_32_Name,F32LightChanged);
espalexa.begin();
}
else
{
while (1)
{
Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
delay(2500);
}
}
}
void loop()
{
espalexa.loop();
delay(1);
}
//our callback functions
void F1LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,1,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,1,0");
digitalWrite(R2, LOW);
}
}
void F2LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,2,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,2,0");
digitalWrite(R2, LOW);
}
}
void F3LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,3,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,3,0");
digitalWrite(R2, LOW);
}
}
void F4LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,4,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,4,0");
digitalWrite(R2, LOW);
}
}
void F5LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,5,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,5,0");
digitalWrite(R2, LOW);
}
}
void F6LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,6,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,6,0");
digitalWrite(R2, LOW);
}
}
void F7LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,7,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,7,0");
digitalWrite(R2, LOW);
}
}
void F8LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,8,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,8,0");
digitalWrite(R2, LOW);
}
}
void F9LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,9,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,9,0");
digitalWrite(R2, LOW);
}
}
void F10LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,10,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,10,0");
digitalWrite(R2, LOW);
}
}
void F11LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,11,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,11,0");
digitalWrite(R2, LOW);
}
}
void F12LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,12,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,12,0");
digitalWrite(R2, LOW);
}
}
void F13LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,13,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,13,0");
digitalWrite(R2, LOW);
}
}
void F14LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,14,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,14,0");
digitalWrite(R2, LOW);
}
}
void F15LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,15,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,15,0");
digitalWrite(R2, LOW);
}
}
void F16LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,16,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,16,0");
digitalWrite(R2, LOW);
}
}
void F17LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,17,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,17,0");
digitalWrite(R2, LOW);
}
}
void F18LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,18,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,18,0");
digitalWrite(R2, LOW);
}
}
void F19LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,19,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,19,0");
digitalWrite(R2, LOW);
}
}
void F20LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,20,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,20,0");
digitalWrite(R2, LOW);
}
}
void F21LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,21,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,21,0");
digitalWrite(R2, LOW);
}
}
void F22LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,22,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,22,0");
digitalWrite(R2, LOW);
}
}
void F23LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,23,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,23,0");
digitalWrite(R2, LOW);
}
}
void F24LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,24,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,24,0");
digitalWrite(R2, LOW);
}
}
void F25LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,25,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,25,0");
digitalWrite(R2, LOW);
}
}
void F26LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,26,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,26,0");
digitalWrite(R2, LOW);
}
}
void F27LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,27,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,27,0");
digitalWrite(R2, LOW);
}
}
void F28LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,28,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,28,0");
digitalWrite(R2, LOW);
}
}
void F29LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,29,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,29,0");
digitalWrite(R2, LOW);
}
}
void F30LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,30,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,30,0");
digitalWrite(R2, LOW);
}
}
void F31LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,31,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,31,0");
digitalWrite(R2, LOW);
}
}
void F32LightChanged(uint8_t brightness)
{
//Control the device
if (brightness)
{
if (brightness == 255)
{
Serial.println("RELAY-SET-255,32,1");
digitalWrite(R2, HIGH);
}
//Serial.print("ON, brightness ");
//Serial.println(brightness);
}
else
{
Serial.println("RELAY-SET-255,32,0");
digitalWrite(R2, LOW);
}
}
// connect to wifi – returns true if successful or false if not
boolean connectWifi()
{
boolean state = true;
int i = 0;
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
//Serial.println("");
//Serial.println("Connecting to WiFi");
// Wait for connection
//Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
// Serial.print(".");
if (i > 20) {
state = false; break;
}
i++;
}
//Serial.println("");
if (state) {
//Serial.print("Connected to ");
Serial.println(ssid);
//Serial.print("IP address: ");
Serial.println(WiFi.localIP());
pinMode(R2, HIGH);
}
else {
//Serial.println("Connection failed.");
pinMode(R2, LOW);
}
return state;
}
Posts: 10
Threads: 0
Joined: Oct 2021
Reputation:
0
(10-04-2021, 12:04 AM)admin Wrote: Can you try the above arduino code? now we suggest use raspberry pi running Node-Red for alexa or google home. because sinric.com not free now.
Do you have any news about my problem with Alexa Routines?
thanks
0615721063Dth
|