Files
ESPGadget/ESPGadget.ino
Florian Overkamp 1d6201eb25 Adding to repo
2019-03-30 08:39:24 +01:00

71 lines
3.1 KiB
C++

/*
* ESP-SecureGadget by Florian Overkamp
* An ESP8266 based IoT/remote controlled gadget
* Design is modular so it can be used for things like Sonoff's but also for custom projects like Dex' Moon lamp
*
* Note that file ordering is important.
*/
// Done:
// Enable MQTT over SSL as per https://github.com/debsahu/ESP_MQTT_Secure/tree/master/ESP8266_MQTT_SSL/Arduino/ESP8266_PubSubClient_SSL
// Cooperative multitasking: Use timers always. Avoid delays where they can be avoided.
// Restructure mqtt topics a bit (report back with unique names for multiple fx lights, for instance)
// Implement versioning so that new firmware can be done OTA
// Todo:
// Split the wifi and mqtt code in order to support http interface
// Stay on the lookout for watchdog crashes, see also https://www.sigmdel.ca/michel/program/esp8266/arduino/watchdogs_en.html#ESP8266_WDT_RECOV
// Keeps crashing after a few days. Dunno why. https://www.pieterverhees.nl/sparklesagarbage/esp8266/130-difference-between-esp-reset-and-esp-restart
// More on this subject https://github.com/esp8266/Arduino/issues/1017
// Implement more visual effects
// Implement speed controls for the visual effects
// Implement OTA https://www.bakke.online/index.php/2017/06/02/self-updating-ota-firmware-for-esp8266/
// Refactoring sources: https://www.arduinolibraries.info/architectures/esp8266
// Refactor String usage to minimize heap pollution. https://cpp4arduino.com/2018/11/21/eight-tips-to-use-the-string-class-efficiently.html
#define DEVICEPREFIX "Gadget" // Should be no longer than 8(?) chars or the MQTT clientId will become too long
const int FW_VERSION = 12;
// Version history:
// v12: Refactored inbound commands to hook in to the modules (module_message function), completed assimilation of (never-published) Moon_Connected sketch
// v11: Simplified scheduler, back to cooperative looping
// v10: First 'production' run. MQTT over TLS, but no OTA support.
/*
* Compile time settings
*/
/************************* WiFi Access Point *********************************/
#define WLAN_SSID "MY_SSID"
#define WLAN_PASS "MY_WIFIPASSWD"
/*********************** Select active modules *******************************/
#define ENABLE_MQTT
//#define ENABLE_SONOFF
#define ENABLE_MOON
#ifdef ENABLE_MQTT
/*************************** MQTT settings ***********************************/
#define MQTT_SERVER "MY_MQTT_SERVER"
#define MQTT_SERVERPORT 8883 // 8883 for MQTTS
#define MQTT_USERNAME "MY_MQTT_USER"
#define MQTT_PASSWORD "MY_MQTT_PASSWD"
#define MQTT_PREFIX "iot/" // MQTT publish/subscribe will be prefixed by this (mind the trailing slash)
#endif
#ifdef ENABLE_SONOFF
/*************************** MQTT settings ***********************************/
#define SONOFF_BUTTON 0
#define SONOFF_RELAY 12
#define SONOFF_LED 13
#endif
#ifdef ENABLE_MOON
/*********************** NeoPixel Moon settings ******************************/
#define MOON_PIXEL 4 // Which GPIO pin is the NeoPixel connected to
#define MOON_PIXEL_LEDS 7 // Amount of leds in the string
#endif