diff --git a/ESP8266/.gitignore b/ESP8266/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/ESP8266/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/ESP8266/.vscode/extensions.json b/ESP8266/.vscode/extensions.json new file mode 100644 index 0000000..e80666b --- /dev/null +++ b/ESP8266/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/ESP8266/dependencies/README.MD b/ESP8266/dependencies/README.MD new file mode 100644 index 0000000..cee85bc --- /dev/null +++ b/ESP8266/dependencies/README.MD @@ -0,0 +1,6 @@ +Note from Bernhard Schlegel: I was not able to get it working with any of the +versions available in the platformIO package Repo (as of March 2021 0.16.0 and 0.15.0). + +Since WiFi manager is undergoing massive reworks, I decided to ship the version +I was using (e.g. offering `saveParamCallback()`) as ZIP file. This is supposedly +version `2.0.4-beta`. \ No newline at end of file diff --git a/ESP8266/dependencies/WiFiManager-2.0.4-beta.zip b/ESP8266/dependencies/WiFiManager-2.0.4-beta.zip new file mode 100644 index 0000000..462fd4e Binary files /dev/null and b/ESP8266/dependencies/WiFiManager-2.0.4-beta.zip differ diff --git a/ESP8266/dependencies/WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip b/ESP8266/dependencies/WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip new file mode 100644 index 0000000..5140961 Binary files /dev/null and b/ESP8266/dependencies/WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip differ diff --git a/ESP8266/include/README b/ESP8266/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/ESP8266/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/ESP8266/lib/README b/ESP8266/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/ESP8266/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/ESP8266/patch/strings_en.h b/ESP8266/patch/strings_en.h new file mode 100644 index 0000000..18094a3 --- /dev/null +++ b/ESP8266/patch/strings_en.h @@ -0,0 +1,421 @@ +/** + * strings_en.h + * engligh strings for + * WiFiManager, a library for the ESP8266/Arduino platform + * for configuration of WiFi credentials using a Captive Portal + * + * @author Creator tzapu + * @author tablatronix + * @version 0.0.0 + * @license MIT + */ + +#ifndef _WM_STRINGS_H_ +#define _WM_STRINGS_H_ + +#ifndef WIFI_MANAGER_OVERRIDE_STRINGS +// !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. + +const char HTTP_HEAD_START[] PROGMEM = "" +"" +"" +"" +"" +"{v}"; + +const char HTTP_SCRIPT[] PROGMEM = ""; // @todo add button states, disable on click , show ack , spinner etc + +const char HTTP_HEAD_END[] PROGMEM = "
"; // {c} = _bodyclass +// example of embedded logo, base64 encoded inline, No styling here +// const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; +const char HTTP_ROOT_MAIN[] PROGMEM = "

{t}

{v}

"; +const char * const HTTP_PORTAL_MENU[] PROGMEM = { +"

\n", // MENU_WIFI +"

\n", // MENU_WIFINOSCAN +"

\n", // MENU_INFO +"

\n",//MENU_PARAM +"

\n", // MENU_CLOSE +"

\n",// MENU_RESTART +"

\n", // MENU_EXIT +"

\n", // MENU_ERASE +"

\n",// MENU_UPDATE +"

" // MENU_SEP +}; + +// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]); +const char HTTP_PORTAL_OPTIONS[] PROGMEM = ""; +const char HTTP_ITEM_QI[] PROGMEM = ""; // rssi icons +const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage {h} = hidden showperc pref +const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP +// const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens + +const char HTTP_FORM_START[] PROGMEM = "
"; +const char HTTP_FORM_WIFI[] PROGMEM = "
"; +const char HTTP_FORM_WIFI_END[] PROGMEM = ""; +const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "

"; +const char HTTP_FORM_END[] PROGMEM = "

"; +const char HTTP_FORM_LABEL[] PROGMEM = ""; +const char HTTP_FORM_PARAM_HEAD[] PROGMEM = "

"; +const char HTTP_FORM_PARAM[] PROGMEM = "
"; + +const char HTTP_SCAN_LINK[] PROGMEM = "
"; +const char HTTP_SAVED[] PROGMEM = "
Saving Credentials
Trying to connect ESP to network.
If it fails reconnect to AP to try again
"; +const char HTTP_PARAMSAVED[] PROGMEM = "
Saved
"; +const char HTTP_END[] PROGMEM = "
"; +const char HTTP_ERASEBTN[] PROGMEM = "
"; +const char HTTP_UPDATEBTN[] PROGMEM = "
"; +const char HTTP_BACKBTN[] PROGMEM = "

"; + +const char HTTP_STATUS_ON[] PROGMEM = "
Connected to {v}
with IP {i}
"; +const char HTTP_STATUS_OFF[] PROGMEM = "
Not Connected to {v}{r}
"; // {c=class} {v=ssid} {r=status_off} +const char HTTP_STATUS_OFFPW[] PROGMEM = "
Authentication Failure"; // STATION_WRONG_PASSWORD, no eps32 +const char HTTP_STATUS_OFFNOAP[] PROGMEM = "
AP not found"; // WL_NO_SSID_AVAIL +const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Could not Connect"; // WL_CONNECT_FAILED +const char HTTP_STATUS_NONE[] PROGMEM = "
No AP set
"; +const char HTTP_BR[] PROGMEM = "
"; + +const char HTTP_STYLE[] PROGMEM = ""; + +#ifndef WM_NOHELP +const char HTTP_HELP[] PROGMEM = + "

Available Pages


" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
PageFunction
/Menu page.
/wifiShow WiFi scan results and enter WiFi configuration.(/0wifi noscan)
/wifisaveSave WiFi configuration information and configure device. Needs variables supplied.
/paramParameter page
/infoInformation page
/uOTA Update
/closeClose the captiveportal popup,configportal will remain active
/exitExit Config Portal, configportal will close
/restartReboot the device
/eraseErase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.
" + "

More information about WiFiManager at https://github.com/tzapu/WiFiManager."; +#else +const char HTTP_HELP[] PROGMEM = ""; +#endif + +const char HTTP_UPDATE[] PROGMEM = "Upload New Firmware

* May not function inside captive portal, Open in browser http://192.168.4.1"; +const char HTTP_UPDATE_FAIL[] PROGMEM = "
Update Failed!
Reboot device and try again
"; +const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update Successful.
Device Rebooting now...
"; + +#ifdef WM_JSTEST +const char HTTP_JS[] PROGMEM = +""; +#endif + +// Info html +#ifdef ESP32 + const char HTTP_INFO_esphead[] PROGMEM = "

esp32


"; + const char HTTP_INFO_chiprev[] PROGMEM = "
Chip Rev
{1}
"; + const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; + const char HTTP_INFO_aphost[] PROGMEM = "
Acccess Point Hostname
{1}
"; + const char HTTP_INFO_psrsize[] PROGMEM = "
PSRAM Size
{1} bytes
"; + const char HTTP_INFO_temp[] PROGMEM = "
Temperature
{1} C° / {2} F°
Hall
{3}
"; +#else + const char HTTP_INFO_esphead[] PROGMEM = "

esp8266


"; + const char HTTP_INFO_fchipid[] PROGMEM = "
Flash Chip ID
{1}
"; + const char HTTP_INFO_corever[] PROGMEM = "
Core Version
{1}
"; + const char HTTP_INFO_bootver[] PROGMEM = "
Boot Version
{1}
"; + const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
{1}
"; + const char HTTP_INFO_flashsize[] PROGMEM = "
Real Flash Size
{1} bytes
"; +#endif + +const char HTTP_INFO_memsmeter[] PROGMEM = "
"; +const char HTTP_INFO_memsketch[] PROGMEM = "
Memory - Sketch Size
Used / Total bytes
{1} / {2}"; +const char HTTP_INFO_freeheap[] PROGMEM = "
Memory - Free Heap
{1} bytes available
"; +const char HTTP_INFO_wifihead[] PROGMEM = "

WiFi


"; +const char HTTP_INFO_uptime[] PROGMEM = "
Uptime
{1} Mins {2} Secs
"; +const char HTTP_INFO_chipid[] PROGMEM = "
Chip ID
{1}
"; +const char HTTP_INFO_idesize[] PROGMEM = "
Flash Size
{1} bytes
"; +const char HTTP_INFO_sdkver[] PROGMEM = "
SDK Version
{1}
"; +const char HTTP_INFO_cpufreq[] PROGMEM = "
CPU Frequency
{1}MHz
"; +const char HTTP_INFO_apip[] PROGMEM = "
Access Point IP
{1}
"; +const char HTTP_INFO_apmac[] PROGMEM = "
Access Point MAC
{1}
"; +const char HTTP_INFO_apssid[] PROGMEM = "
Access Point SSID
{1}
"; +const char HTTP_INFO_apbssid[] PROGMEM = "
BSSID
{1}
"; +const char HTTP_INFO_stassid[] PROGMEM = "
Station SSID
{1}
"; +const char HTTP_INFO_staip[] PROGMEM = "
Station IP
{1}
"; +const char HTTP_INFO_stagw[] PROGMEM = "
Station Gateway
{1}
"; +const char HTTP_INFO_stasub[] PROGMEM = "
Station Subnet
{1}
"; +const char HTTP_INFO_dnss[] PROGMEM = "
DNS Server
{1}
"; +const char HTTP_INFO_host[] PROGMEM = "
Hostname
{1}
"; +const char HTTP_INFO_stamac[] PROGMEM = "
Station MAC
{1}
"; +const char HTTP_INFO_conx[] PROGMEM = "
Connected
{1}
"; +const char HTTP_INFO_autoconx[] PROGMEM = "
Autoconnect
{1}
"; + + +const char S_brand[] PROGMEM = "WiFiManager"; +const char S_debugPrefix[] PROGMEM = "*wm:"; +const char S_y[] PROGMEM = "Yes"; +const char S_n[] PROGMEM = "No"; +const char S_enable[] PROGMEM = "Enabled"; +const char S_disable[] PROGMEM = "Disabled"; +const char S_GET[] PROGMEM = "GET"; +const char S_POST[] PROGMEM = "POST"; +const char S_NA[] PROGMEM = "Unknown"; +const char S_passph[] PROGMEM = "********"; +const char S_titlewifisaved[] PROGMEM = "Credentials Saved"; +const char S_titlewifisettings[] PROGMEM = "Settings Saved"; +const char S_titlewifi[] PROGMEM = "Config ESP"; +const char S_titleinfo[] PROGMEM = "Info"; +const char S_titleparam[] PROGMEM = "Setup"; +const char S_titleparamsaved[] PROGMEM = "Setup Saved"; +const char S_titleexit[] PROGMEM = "Exit"; +const char S_titlereset[] PROGMEM = "Reset"; +const char S_titleerase[] PROGMEM = "Erase"; +const char S_titleclose[] PROGMEM = "Close"; +const char S_options[] PROGMEM = "options"; +const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again."; +const char S_staticip[] PROGMEM = "Static IP"; +const char S_staticgw[] PROGMEM = "Static Gateway"; +const char S_staticdns[] PROGMEM = "Static DNS"; +const char S_subnet[] PROGMEM = "Subnet"; +const char S_exiting[] PROGMEM = "Exiting"; +const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; +const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; +const char S_error[] PROGMEM = "An Error Occured"; +const char S_notfound[] PROGMEM = "File Not Found\n\n"; +const char S_uri[] PROGMEM = "URI: "; +const char S_method[] PROGMEM = "\nMethod: "; +const char S_args[] PROGMEM = "\nArguments: "; +const char S_parampre[] PROGMEM = "param_"; + +// debug strings +const char D_HR[] PROGMEM = "--------------------"; + +// END WIFI_MANAGER_OVERRIDE_STRINGS +#endif + +// ----------------------------------------------------------------------------------------------- +// DO NOT EDIT BELOW THIS LINE + +const uint8_t _nummenutokens = 10; +const char * const _menutokens[10] PROGMEM = { + "wifi", + "wifinoscan", + "info", + "param", + "close", + "restart", + "exit", + "erase", + "update", + "sep" +}; + +const char R_root[] PROGMEM = "/"; +const char R_wifi[] PROGMEM = "/wifi"; +const char R_wifinoscan[] PROGMEM = "/0wifi"; +const char R_wifisave[] PROGMEM = "/wifisave"; +const char R_info[] PROGMEM = "/info"; +const char R_param[] PROGMEM = "/param"; +const char R_paramsave[] PROGMEM = "/paramsave"; +const char R_restart[] PROGMEM = "/restart"; +const char R_exit[] PROGMEM = "/exit"; +const char R_close[] PROGMEM = "/close"; +const char R_erase[] PROGMEM = "/erase"; +const char R_status[] PROGMEM = "/status"; +const char R_update[] PROGMEM = "/update"; +const char R_updatedone[] PROGMEM = "/u"; + + +//Strings +const char S_ip[] PROGMEM = "ip"; +const char S_gw[] PROGMEM = "gw"; +const char S_sn[] PROGMEM = "sn"; +const char S_dns[] PROGMEM = "dns"; + +// softap ssid default prefix +#ifdef ESP8266 + const char S_ssidpre[] PROGMEM = "ESP"; +#elif defined(ESP32) + const char S_ssidpre[] PROGMEM = "ESP32"; +#else + const char S_ssidpre[] PROGMEM = "WM"; +#endif + +//Tokens +//@todo consolidate and reduce +const char T_ss[] PROGMEM = "{"; // token start sentinel +const char T_es[] PROGMEM = "}"; // token end sentinel +const char T_1[] PROGMEM = "{1}"; // @token 1 +const char T_2[] PROGMEM = "{2}"; // @token 2 +const char T_3[] PROGMEM = "{3}"; // @token 2 +const char T_v[] PROGMEM = "{v}"; // @token v +const char T_I[] PROGMEM = "{I}"; // @token I +const char T_i[] PROGMEM = "{i}"; // @token i +const char T_n[] PROGMEM = "{n}"; // @token n +const char T_p[] PROGMEM = "{p}"; // @token p +const char T_t[] PROGMEM = "{t}"; // @token t +const char T_l[] PROGMEM = "{l}"; // @token l +const char T_c[] PROGMEM = "{c}"; // @token c +const char T_e[] PROGMEM = "{e}"; // @token e +const char T_q[] PROGMEM = "{q}"; // @token q +const char T_r[] PROGMEM = "{r}"; // @token r +const char T_R[] PROGMEM = "{R}"; // @token R +const char T_h[] PROGMEM = "{h}"; // @token h + +// http +const char HTTP_HEAD_CL[] PROGMEM = "Content-Length"; +const char HTTP_HEAD_CT[] PROGMEM = "text/html"; +const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; +const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; +const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; + +const char * const WIFI_STA_STATUS[] PROGMEM +{ + "WL_IDLE_STATUS", // 0 STATION_IDLE + "WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND + "WL_SCAN_COMPLETED", // 2 + "WL_CONNECTED", // 3 STATION_GOT_IP + "WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI) + "WL_CONNECTION_LOST", // 5 + "WL_DISCONNECTED", // 6 + "WL_STATION_WRONG_PASSWORD" // 7 KLUDGE +}; + +#ifdef ESP32 +const char * const AUTH_MODE_NAMES[] PROGMEM +{ + "OPEN", + "WEP", + "WPA_PSK", + "WPA2_PSK", + "WPA_WPA2_PSK", + "WPA2_ENTERPRISE", + "MAX" +}; +#elif defined(ESP8266) +const char * const AUTH_MODE_NAMES[] PROGMEM +{ + "", + "", + "WPA_PSK", // 2 ENC_TYPE_TKIP + "", + "WPA2_PSK", // 4 ENC_TYPE_CCMP + "WEP", // 5 ENC_TYPE_WEP + "", + "OPEN", //7 ENC_TYPE_NONE + "WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO +}; +#endif + +const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" }; + + +#ifdef ESP32 +// as 2.5.2 +// typedef struct { +// char cc[3]; /**< country code string */ +// uint8_t schan; /**< start channel */ +// uint8_t nchan; /**< total channel number */ +// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ +// wifi_country_policy_t policy; /**< country policy */ +// } wifi_country_t; +const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +#elif defined(ESP8266) && !defined(WM_NOCOUNTRY) +// typedef struct { +// char cc[3]; /**< country code string */ +// uint8_t schan; /**< start channel */ +// uint8_t nchan; /**< total channel number */ +// uint8_t policy; /**< country policy */ +// } wifi_country_t; +const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO}; +#endif + + +/* +* ESP32 WiFi Events + +0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready +1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP +2 SYSTEM_EVENT_STA_START < ESP32 station start +3 SYSTEM_EVENT_STA_STOP < ESP32 station stop +4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP +5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP +6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed +7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP +8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 +9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode +10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode +11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode +12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode +13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start +14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop +15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP +16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP +17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station +18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface +19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred +20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start +21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop +22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up +23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down +24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP +25 SYSTEM_EVENT_MAX +*/ + +#endif \ No newline at end of file diff --git a/ESP8266/platformio.ini b/ESP8266/platformio.ini new file mode 100644 index 0000000..81ad9a1 --- /dev/null +++ b/ESP8266/platformio.ini @@ -0,0 +1,23 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:sonoff_th] +platform = espressif8266 +board = sonoff_th +framework = arduino +lib_deps = + paulstoffregen/OneWire@^2.3.5 + bblanchon/ArduinoJson@^6.17.2 + WiFiManager=https://github.com/tzapu/WiFiManager.git ; commit f5dd402ba2698be17e27d357b1ead5291c3d0eb1 as of 04/12/2021 worked fine, see backup next line + ;./dependencies/WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip +monitor_speed = 115200 + +[common] +upload_port = /dev/ttyUSB0 diff --git a/ESP8266/releases/bierbot_brick_101_0.1.2.bin b/ESP8266/releases/bierbot_brick_101_0.1.2.bin new file mode 100644 index 0000000..248c02b Binary files /dev/null and b/ESP8266/releases/bierbot_brick_101_0.1.2.bin differ diff --git a/ESP8266/src/helper.cpp b/ESP8266/src/helper.cpp new file mode 100644 index 0000000..e76dd69 --- /dev/null +++ b/ESP8266/src/helper.cpp @@ -0,0 +1,46 @@ +#include "helper.h" + +inline int32_t TimeDifference(uint32_t prev, uint32_t next) +{ + return ((int32_t) (next - prev)); +} + +int32_t TimePassedSince(uint32_t timestamp) +{ + // Compute the number of milliSeconds passed since timestamp given. + // Note: value can be negative if the timestamp has not yet been reached. + return TimeDifference(timestamp, millis()); +} + +bool TimeReached(uint32_t timer) +{ + // Check if a certain timeout has been reached. + const int32_t passed = TimePassedSince(timer); + return (passed >= 0); +} + +void SetNextTimeInterval(uint32_t& timer, const uint32_t step) +{ + timer += step; + const int32_t passed = TimePassedSince(timer); + if (passed < 0) { return; } // Event has not yet happened, which is fine. + if (static_cast(passed) > step) { + // No need to keep running behind, start again. + timer = millis() + step; + return; + } + // Try to get in sync again. + timer = millis() + (step - passed); +} + +int32_t TimePassedSinceUsec(uint32_t timestamp) +{ + return TimeDifference(timestamp, micros()); +} + +bool TimeReachedUsec(uint32_t timer) +{ + // Check if a certain timeout has been reached. + const int32_t passed = TimePassedSinceUsec(timer); + return (passed >= 0); +} \ No newline at end of file diff --git a/ESP8266/src/helper.h b/ESP8266/src/helper.h new file mode 100644 index 0000000..24ff671 --- /dev/null +++ b/ESP8266/src/helper.h @@ -0,0 +1,8 @@ +#include + +int32_t TimeDifference(uint32_t prev, uint32_t next); +int32_t TimePassedSince(uint32_t timestamp); +bool TimeReached(uint32_t timer); +void SetNextTimeInterval(uint32_t& timer, const uint32_t step); +int32_t TimePassedSinceUsec(uint32_t timestamp); +bool TimeReachedUsec(uint32_t timer); \ No newline at end of file diff --git a/ESP8266/src/main.cpp b/ESP8266/src/main.cpp new file mode 100644 index 0000000..1e9f460 --- /dev/null +++ b/ESP8266/src/main.cpp @@ -0,0 +1,593 @@ +#define WM_NODEBUG +#define ARDUINO_ESP8266_RELEASE_2_3_0 + +#include +#include // https://github.com/tzapu/WiFiManager +#include +#include +#include +#include +#include +#include +#include "helper.h" + +// Set web server port number to 80 +WiFiServer server(80); + +void handleRoot(); // function prototypes for HTTP handlers +void handleNotFound(); + +OneWire ds(14); // on pin 14 SONOFF TH16 + +#define EEPROM_ADDRESS_APIKEY 0 +#define GPIO_TRIGGER 0 +#define GPIO_RELAIS 12 +#define GPIO_LED 13 +#define HTTP_REQUEST_RESPONSE_BUF_LEN 255 + +String apikey; +WiFiManager wm; // global wm instance +WiFiManagerParameter custom_field_apikey; // global param ( for non blocking w params ) +HTTPClient http; //Declare an object of class HTTPClient +WiFiClientSecure https; + +uint8_t global_error = 0; +uint8_t global_warning = 0; +String global_error_text = ""; +String global_warning_text = ""; +float celsius, fahrenheit; +String chipid = ""; +uint32_t main_interval_ms = 1000; // 1s default intervall for first iteration +uint8_t global_relais_state = 0; +String global_version = "0.9.0"; + +void writeStringToEEPROM(int addrOffset, const String &strToWrite) +{ + byte len = strToWrite.length(); + Serial.print("String has length "); + Serial.println(len); + EEPROM.write(addrOffset, len); + for (int i = 0; i < len; i++) + { + // replace values in byte-array cache with modified data + // no changes made to flash, all in local byte-array cache + EEPROM.put(addrOffset + 1 + i, strToWrite[i]); + } + Serial.println("Data put to EEPROM."); + + // https://arduino.stackexchange.com/questions/25945/how-to-read-and-write-eeprom-in-esp8266 + // actually write the content of byte-array cache to + // hardware flash. flash write occurs if and only if one or more byte + // in byte-array cache has been changed, but if so, ALL 512 bytes are + // written to flash + EEPROM.commit(); + Serial.println("EEPROM committed."); +} + +String readStringFromEEPROM(int addrOffset) +{ + int newStrLen = EEPROM.read(addrOffset); + char data[newStrLen + 1]; + for (int i = 0; i < newStrLen; i++) + { + data[i] = EEPROM.read(addrOffset + 1 + i); + } + data[newStrLen] = '\0'; // the character may appear in a weird way, you should read: 'only one backslash and 0' + return String(data); +} + +String getParam(String name) +{ + //read parameter from server, for customhmtl input + String value; + if (wm.server->hasArg(name)) + { + value = wm.server->arg(name); + } + return value; +} + +void saveParamCallback() +{ + Serial.println("[CALLBACK] saveParamCallback fired"); + apikey = getParam("apikey").substring(0, 20); + Serial.println("PARAM apikey straight = " + apikey); + //String apikey = getParam("apikey"); + writeStringToEEPROM(EEPROM_ADDRESS_APIKEY, apikey); + String apikey_restored = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); + Serial.println("PARAM apikey from EEPROM = " + apikey_restored); +} + +void checkButton() +{ + // check for button press + if (digitalRead(GPIO_TRIGGER) == LOW) + { + // poor mans debounce/press-hold, code not ideal for production + delay(50); + if (digitalRead(GPIO_TRIGGER) == LOW) + { + Serial.println("Button Pressed"); + // still holding button for 3000 ms, reset settings, code not ideaa for production + delay(3000); // reset delay hold + if (digitalRead(GPIO_TRIGGER) == LOW) + { + Serial.println("Button Held"); + Serial.println("Erasing Config, restarting"); + wm.disconnect(); + wm.resetSettings(); + ESP.restart(); + } + else + { + server.stop(); // kill status server (to avoid conflicnt) + + // start portal w delay + Serial.println("Starting config portal"); + wm.setConfigPortalTimeout(120); + + if (!wm.startConfigPortal("BierBot Brick 101")) + { + Serial.println("failed to connect or hit timeout"); + delay(3000); + // ESP.restart(); + } + else + { + //if you get here you have connected to the WiFi + Serial.println("connection re-established"); + } + + server.begin(); // start status server again + } + } + } +} + +void short_flash_500ms(uint8_t count) +{ + for (uint8_t i = 0; i < count; ++i) + { + digitalWrite(GPIO_LED, 1); + delay(100); + digitalWrite(GPIO_LED, 0); + delay(400); + } +} + +void setup() +{ + Serial.println("BierBot Brick 101 starting"); + chipid = String(ESP.getFlashChipId()) + "_" + String(WiFi.macAddress()); + Serial.println("chipid: " + chipid); + short_flash_500ms(10); + + //--------------------------------------------------------------------------------------- + // GPIO + //--------------------------------------------------------------------------------------- + pinMode(GPIO_TRIGGER, INPUT); + pinMode(GPIO_RELAIS, OUTPUT); + pinMode(GPIO_LED, OUTPUT); + + //--------------------------------------------------------------------------------------- + // EEPROM + //--------------------------------------------------------------------------------------- + // commit 512 bytes of ESP8266 flash (for "EEPROM" emulation) + // this step actually loads the content (512 bytes) of flash into + // a 512-byte-array cache in RAM + EEPROM.begin(512); + + //--------------------------------------------------------------------------------------- + // WIFI + //--------------------------------------------------------------------------------------- + WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + + // put your setup code here, to run once: + Serial.begin(115200); + + Serial.println("\n Starting"); + + // guid, len 36 + terminator + // e.g. 550e8400-e29b-11d4-a716-446655440000 + // test custom html(radio) + //const char* custom_apikey_str = "

"; + //new (&custom_field_apikey) WiFiManagerParameter(custom_apikey_str); // custom html input + new (&custom_field_apikey) WiFiManagerParameter("apikey", "BierBot Bricks API Key", "aZ42ILoveBrewingB33r", 37, "placeholder=\"get your API key at bricks.bierbot.com\""); + + wm.addParameter(&custom_field_apikey); + //wm.setConfigPortalBlocking(false); + wm.setSaveConfigCallback(saveParamCallback); + + //reset settings - wipe credentials for testing + //wm.resetSettings(); + + // Automatically connect using saved credentials, + // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"), + // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect()) + // then goes into a blocking loop awaiting configuration and will return success result + + bool res; + // res = wm.autoConnect(); // auto generated AP name from chipid + // res = wm.autoConnect("AutoConnectAP"); // anonymous ap + res = wm.autoConnect("BierBot Brick 101"); // password protected ap + + if (!res) + { + Serial.println("Failed to connect"); + // ESP.restart(); + } + else + { + //if you get here you have connected to the WiFi + Serial.println("connected...yeey :)"); + } + + // eeprom for storing api key + EEPROM.begin(512); + + server.begin(); +} + +// Current time +unsigned long currentTime = millis(); +// Previous time +unsigned long previousTime = 0; +// Define timeout time in milliseconds (example: 2000ms = 2s) +const long timeoutTime = 2000; + +void addDataRow(WiFiClient client, String key, String value) +{ + client.println(""); + client.println(""); + client.println(key); + client.println(""); + client.println(""); + client.println(value); + client.println(""); + client.println(""); +} + +void checkRequest() +{ + + WiFiClient client = server.available(); // Listen for incoming clients + + if (client) + { // If a new client connects, + Serial.println("New Client."); // print a message out in the serial port + String currentLine = ""; // make a String to hold incoming data from the client + currentTime = millis(); + previousTime = currentTime; + while (client.connected() && currentTime - previousTime <= timeoutTime) + { // loop while the client's connected + currentTime = millis(); + if (client.available()) + { // if there's bytes to read from the client, + char c = client.read(); // read a byte, then + Serial.write(c); // print it out the serial monitor + if (c == '\n') + { // if the byte is a newline character + // if the current line is blank, you got two newline characters in a row. + // that's the end of the client HTTP request, so send a response: + if (currentLine.length() == 0) + { + // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) + // and a content-type so the client knows what's coming, then a blank line: + client.println("HTTP/1.1 200 OK"); + client.println("Content-type:text/html"); + client.println("Connection: close"); + client.println(); + + // Display the HTML web page + client.println(""); + client.println(""); + + client.println(""); + client.println(""); + // CSS to style the on/off buttons + // Feel free to change the background-color and font-size attributes to fit your preferences + client.println(""); + + // Web Page Heading + client.println("

BierBot Brick 101

"); + client.println(""); + String temp = String(celsius); + addDataRow(client, "Temperature", temp); + String api_key = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); + addDataRow(client, "API key", api_key); + + if (global_warning) + { + addDataRow(client, "Warning", global_warning_text); + } + if (global_error) + { + addDataRow(client, "Warning", global_error_text); + } + + client.println(""); + client.println("
"); + + // The HTTP response ends with another blank line + client.println(); + // Break out of the while loop + break; + } + else + { // if you got a newline, then clear currentLine + currentLine = ""; + } + } + else if (c != '\r') + { // if you got anything else but a carriage return character, + currentLine += c; // add it to the end of the currentLine + } + } + } + // Close the connection + client.stop(); + Serial.println("Client disconnected."); + } +} + +void readTemperature() +{ + // put your main code here, to run repeatedly: + byte i; + byte present = 0; + byte type_s; + byte data[12]; + byte addr[8]; + + if (!ds.search(addr)) + { + Serial.println("No more addresses."); + Serial.println(); + ds.reset_search(); + delay(250); + return; + } + + Serial.print("ROM ="); + for (i = 0; i < 8; i++) + { + Serial.write(' '); + Serial.print(addr[i], HEX); + } + + if (OneWire::crc8(addr, 7) != addr[7]) + { + Serial.println("CRC is not valid!"); + return; + } + Serial.println(); + + // the first ROM byte indicates which chip + switch (addr[0]) + { + case 0x10: + Serial.println(" Chip = DS18S20"); // or old DS1820 + type_s = 1; + break; + case 0x28: + Serial.println(" Chip = DS18B20"); + type_s = 0; + break; + case 0x22: + Serial.println(" Chip = DS1822"); + type_s = 0; + break; + default: + Serial.println("Device is not a DS18x20 family device."); + return; + } + + ds.reset(); + ds.select(addr); + ds.write(0x44, 1); // start conversion, with parasite power on at the end + + delay(1000); // maybe 750ms is enough, maybe not + // we might do a ds.depower() here, but the reset will take care of it. + + present = ds.reset(); + ds.select(addr); + ds.write(0xBE); // Read Scratchpad + + Serial.print(" Data = "); + Serial.print(present, HEX); + Serial.print(" "); + for (i = 0; i < 9; i++) + { // we need 9 bytes + data[i] = ds.read(); + Serial.print(data[i], HEX); + Serial.print(" "); + } + Serial.print(" CRC="); + Serial.print(OneWire::crc8(data, 8), HEX); + Serial.println(); + + // Convert the data to actual temperature + // because the result is a 16 bit signed integer, it should + // be stored to an "int16_t" type, which is always 16 bits + // even when compiled on a 32 bit processor. + int16_t raw = (data[1] << 8) | data[0]; + if (type_s) + { + raw = raw << 3; // 9 bit resolution default + if (data[7] == 0x10) + { + // "count remain" gives full 12 bit resolution + raw = (raw & 0xFFF0) + 12 - data[6]; + } + } + else + { + byte cfg = (data[4] & 0x60); + // at lower res, the low bits are undefined, so let's zero them + if (cfg == 0x00) + raw = raw & ~7; // 9 bit resolution, 93.75 ms + else if (cfg == 0x20) + raw = raw & ~3; // 10 bit res, 187.5 ms + else if (cfg == 0x40) + raw = raw & ~1; // 11 bit res, 375 ms + //// default is 12 bit resolution, 750 ms conversion time + } + celsius = (float)raw / 16.0; + fahrenheit = celsius * 1.8 + 32.0; + Serial.print(" Temperature = "); + Serial.print(celsius); + Serial.println(" Celsius."); + //Serial.print(fahrenheit); + //Serial.println(" Fahrenheit"); + + String apikey_restored = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); + Serial.println("PARAM apikey from EEPROM = " + apikey_restored); +} + +void contactBackend() +{ + if (1 == 1) + { // WiFi.status() == WL_CONNECTED) { //Check WiFi connection status + String apikey_restored = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); + String temp = String(celsius); + String relais = String(global_relais_state); + String url = "https://cloud.bierbot.com/api/iot/v1?apikey=" + apikey_restored + "&type=" + "sonoff_th16" + "&brand=" + "bierbot" + "&version=" + global_version + "&s_number_temp_0=" + temp + "&a_bool_epower_0=" + relais + "&chipid=" + chipid; // + "&temp=" + temp + "&type=" + "sonoff_th16" + "&version=" + global_version + + Serial.print("s_number_temp_0=" + temp); + Serial.println(", a_bool_epower_0=" + relais); + + WiFiClientSecure client; + client.setInsecure(); // unfortunately necessary, ESP8266 does not support SSL without hard coding certificates + client.connect(url, 443); + + http.begin(client, url); + + // String payload = "{\"s_number_temp_0\":\"" + temp + "\",\"a_bool_epower_0\":\"" + relais + "\",\"type\":\"" + "sonoff_th16" + "\",\"brand\":\"" + "bierbot" + "\",\"version\":\"" + global_version + "\",\"chipid\":\"" + chipid + "\"}"; + // Serial.println("payload " + payload); + + Serial.println("submitting POST to " + url); + int httpCode = http.GET(); // GET has issues with 301 forwards + Serial.print("httpCode: "); + Serial.println(httpCode); + + if (httpCode > 0) + { //Check the returning code + + for (int i = 0; i < http.headers(); i++) + { + Serial.println(http.header(i)); + } + + String payload = http.getString(); //Get the request response payload + Serial.print(F("received payload: ")); + Serial.println(payload); //Print the response payload + + if (payload.length() == 0) + { + Serial.println(F("payload empty, skipping.")); + Serial.println(F("setting next request to 60s.")); + main_interval_ms = 60000; + } + else if (payload.indexOf("{") == -1) + { + Serial.println("no JSON - skippping."); + Serial.println(F("setting next request to 60s.")); + main_interval_ms = 60000; + } + else + { + StaticJsonDocument doc; + + // Deserialize the JSON document + // doc should look like "{\"target_state\":0, \"next_request_ms\":10000,\"error\":1,\"error_text\":\"Your device will need an upgrade\",\"warning\":1,\"warning_text\":\"Your device will need an upgrade\"}"; + DeserializationError error = deserializeJson(doc, payload); + // Test if parsing succeeds. + if (error) + { + Serial.print(F("deserializeJson() failed: ")); + Serial.println(error.f_str()); + global_error = 1; + global_error_text = String("JSON error: ") + String(error.f_str()); + } + else + { + Serial.println("deserializeJson success"); + if (doc["error"]) + { + // an error is critical, do not proceed with logik + const char *error_text = doc["error_text"]; + global_error_text = String(error_text); + global_error = 1; + } + else + { + global_error = 0; + if (doc["warning"]) + { + // proceed with logik, if there is a warning + const char *warning_text = doc["warning_text"]; + global_warning_text = String(warning_text); + global_warning = 1; + } + else + { + global_warning = 0; + } + + // main logic here + if (doc.containsKey("next_request_ms")) + { + main_interval_ms = doc["next_request_ms"].as(); + } + else + { + // try again in 30s + main_interval_ms = 30000; + } + if (doc.containsKey("epower_0_state")) + { + global_relais_state = doc["epower_0_state"]; + } + } + } + } + } + else + { + Serial.print(F("setting next request to 60s.")); + main_interval_ms = 60000; + } + http.end(); //Close connection + } +}; + +void setRelais() +{ + digitalWrite(GPIO_RELAIS, global_relais_state); + digitalWrite(GPIO_LED, global_relais_state); +}; + +void loop() +{ + checkRequest(); + checkButton(); + + static uint32_t state_main_interval = 0; + if (TimeReached(state_main_interval)) + { + // one interval delay in case server wants to set new interval + SetNextTimeInterval(state_main_interval, main_interval_ms); + + Serial.println("##### MAIN: reading temperature"); + readTemperature(); + + Serial.println("##### MAIN: contacting backend"); + contactBackend(); + + Serial.println("##### MAIN: setting relais"); + setRelais(); + } +} diff --git a/ESP8266/test/README b/ESP8266/test/README new file mode 100644 index 0000000..b94d089 --- /dev/null +++ b/ESP8266/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e72bfdd --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..90e7386 --- /dev/null +++ b/README.MD @@ -0,0 +1,70 @@ +## BierBot Brick + + + +### Setup for easy use + +First, we need to flash the firmware. + +1. Order a Sonoff [TH16 + DS18B20 Temperature sensor](https://amzn.to/3uhLiXN). +2. In case you don't have one laying around, you'll also need: + 1. [FT232RL USB to TTL](https://amzn.to/3ujiT3w) for flashing the BierBot Brick firmware onto your TH16. + 2. [the cheapest female rainbow cables you can find on the WWW](https://amzn.to/39IG9A3) to hook the TH16 and the FT232 up. + 3. [a 4x1 pin header](https://amzn.to/3rXGrJT) to solder it onto your TH16. + 4. **INSTEAD** of the last two, you can also buy an [electronic fun kit](https://amzn.to/3fArDhE), which is most likely cheaper. +3. Hook everything up as shown in the image. + +TODO: Image / Schematic of Rainbow cable connection. + +4. Download the [NodeMCU Flasher](https://github.com/nodemcu/nodemcu-flasher). +6. Grab the (current) version from `./BierBot-Brick/ESP8266/releases`. +7. Open the NodeMCU Flasher and hit "Flash". + +Second, read [the disclaimer](https://github.com/BernhardSchlegel/BierBot-Brick/blob/master/README.md#development) and cut a extension cable into two pieces and connect as shown in the picture. **ATTENTION** :warning: check if the +labels on YOUR PCB match the colors of the cables: L = Brown, N = Blue, E / Ground symbol = Yellow / Green. + +TODO: Image of AC connection. + +Your device is now ready to be used. + +Go to [bricks.bierbot.com](https://bricks.bierbot.com/#/) > "Brewery" > "Sensors / Actors" and hit "Add device". Copy the API-Key into your clipboard. Power up your BierBot Brick. Scan for the "BierBot Brick 101" WiFi and connect. Enter the credentials to your home WiFi and paste the API-key from your clipboard. Hit "Save". + +**DONE**. The BierBot Brick should show up in your dashboard. + +### Developer Setup + +1. Install VSCode from [here](https://code.visualstudio.com/). +2. Install PlatformIO as described [here](https://platformio.org/). +3. Install driver for your Serial converter. E.g. from [here](https://ftdichip.com/drivers/vcp-drivers/). +4. connect your TTL Converter to the Sonoff TH 16. If all cables are in a row, you likely did something wrong. +5. Click the terminal Icon in the footer bar of VSCode saying "PlatformIO: new terminal" & type `pio lib install`. +6. Click the alien on the right side > "Project Tasks" > "sonoff_th" > "Build" and then "Upload". + +### Notes for devs + +To decode stacktraces use `python3 ./decoder.py -e ./firmware.elf ./trace.txt -s` from [here](https://github.com/janLo/EspArduinoExceptionDecoder). + +### Help + +If you get a bunch of WiFi Manager related compiling messages, unzip "./backup/2021_01_15_16_39_WiFiManager.zip" to ".pio/libdeps/sonoff_th" + +### TODOs + +- [ ] Reduce programm size to 50% FLASH so that OTA update works. +- [ ] migrate WiFiManager as soon there is a stable version that works. +- [ ] as soon as ESP8266 supports SSL without hardcoding fingerprints: Enable SSL. + +## Disclaimer + +:warning: **DANGER OF ELECTROCUTION** :warning: + +If your device connects to mains electricity (AC power) there is danger of electrocution if not installed properly. If you don't know how to install it, please call an electrician (***Beware:*** certain countries prohibit installation without a licensed electrician present). Remember: _**SAFETY FIRST**_. It is not worth the risk to yourself, your family and your home if you don't know exactly what you are doing. Never tinker or try to flash a device using the serial programming interface while it is connected to MAINS ELECTRICITY (AC power). + +We don't take any responsibility nor liability for using this software nor for the installation or any tips, advice, videos, etc. given by any member of this site or any related site. + +[disclaimer source](https://github.com/arendst/Tasmota/edit/development/README.md) + +## Help + +Q: My COM-Port is not recognized! +A: Install the FT232RL Virtual COM-Port Driver from [here](https://ftdichip.com/drivers/vcp-drivers/).