You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1018 B
50 lines
1018 B
#define SERIAL_SPEED 115200
|
|
|
|
// OTA
|
|
#define OTA_PASSWORD "XXX"
|
|
// Ce nom est réutillisé par la suite pour le RemoteDebug + MQTT
|
|
#define OTA_CLIENT "sonoff_living"
|
|
|
|
// DebugRemote
|
|
#define REMDEB_CLIENT OTA_CLIENT
|
|
RemoteDebug Debug;
|
|
|
|
// WIFI
|
|
#define WIFI_SSID "XXX"
|
|
#define WIFI_PASSWORD "XXX"
|
|
|
|
WiFiClient espClient;
|
|
|
|
#define BUTTON_PIN 0
|
|
#define RELAY_PIN 12
|
|
#define LED_PIN 13
|
|
|
|
// MQTT
|
|
#define MQTT_SERVER "XXX"
|
|
#define MQTT_PORT 1883
|
|
#define MQTT_USER "XXX"
|
|
#define MQTT_PASS "XXX"
|
|
|
|
#define MQTT_CLIENT OTA_CLIENT
|
|
#define MQTT_COMMAND MQTT_CLIENT"/switch"
|
|
#define MQTT_STATE MQTT_CLIENT"/status"
|
|
|
|
char message_buff[100];
|
|
PubSubClient client(espClient);
|
|
|
|
// Bouton
|
|
Ticker btn_timer;
|
|
unsigned long count = 0;
|
|
|
|
bool relayState;
|
|
|
|
void setup();
|
|
void loop();
|
|
void blinkLED(int pin, int duration, int n);
|
|
void button();
|
|
void setupOTA();
|
|
void setupWifi();
|
|
void testConnectMQTT();
|
|
void callbackMQTT(char* topic, byte* payload, unsigned int length);
|
|
void setupSonOff();
|
|
void mqttSendState();
|