From 5e861b10ef744d7767deb5501ae2efdca11696b8 Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Fri, 26 May 2017 16:40:25 +0200 Subject: [PATCH] import --- arduino/sonoffliving/sonoffliving.example.h | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 arduino/sonoffliving/sonoffliving.example.h diff --git a/arduino/sonoffliving/sonoffliving.example.h b/arduino/sonoffliving/sonoffliving.example.h new file mode 100644 index 0000000..93d0e82 --- /dev/null +++ b/arduino/sonoffliving/sonoffliving.example.h @@ -0,0 +1,44 @@ +#define BUTTON 0 // (Don't Change for Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Socket) +#define RELAY 12 // (Don't Change for Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Socket) +#define LED 13 // (Don't Change for Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Socket) + +#define MQTT_CLIENT "sonoff_living" // mqtt client_id (Must be unique for each Sonoff) +#define MQTT_SERVER "XXX" // mqtt server +#define MQTT_PORT 1883 // mqtt port +#define MQTT_TOPIC "sonoff/living" // mqtt topic (Must be unique for each Sonoff) +#define MQTT_USER "XXX" // mqtt user +#define MQTT_PASS "XXX" // mqtt password + +#define WIFI_SSID "XXX" // wifi ssid +#define WIFI_PASS "XXX" // wifi password + +#define VERSION "\n\n---------------- Sonoff Powerpoint v1.01pOTA -----------------" + +bool rememberRelayState = true; // If 'true' remembers the state of the relay before power loss. +bool OTAupdate = false; // (Do not Change) +bool sendStatus = false; // (Do not Change) +bool requestRestart = false; // (Do not Change) + +int kUpdFreq = 1; // Update frequency in Mintes to check for mqtt connection +int kRetries = 10; // WiFi retry count. Increase if not connecting to router. +int lastRelayState; // (Do not Change) + +unsigned long TTasks; // (Do not Change) +unsigned long count = 0; // (Do not Change) + +extern "C" { + #include "user_interface.h" +} + +WiFiClient wifiClient; +PubSubClient mqttClient(wifiClient, MQTT_SERVER, MQTT_PORT); +Ticker btn_timer; + +void callback(const MQTT::Publish& pub); +void setup(); +void loop(); +void blinkLED(int pin, int duration, int n); +void button(); +void checkConnection(); +void checkStatus(); +void timedTasks();