From bce5f882b053e29589aa917e488c6cb3f6ede7ed Mon Sep 17 00:00:00 2001 From: Leith Cullen <909007+ZL1LAC@users.noreply.github.com> Date: Wed, 22 May 2024 12:25:53 +1200 Subject: [PATCH 01/52] Update duco-install-rpi.sh Fix script finishing. ./duco-install-rpi.sh: 59: [: missing ] --- Tools/duco-install-rpi.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/duco-install-rpi.sh b/Tools/duco-install-rpi.sh index 55c81548..3763cbf5 100755 --- a/Tools/duco-install-rpi.sh +++ b/Tools/duco-install-rpi.sh @@ -19,7 +19,7 @@ if [ ! -d ~/duino-coin/ ];then fi cd ~/duino-coin -echo "Installing python packages" +echo "Installing Python packages" python3 -m pip install -r requirements.txt # Install pip dependencies #Check if the app exists @@ -32,7 +32,7 @@ fi mkdir -p ~/.local/share/applications echo "[Desktop Entry] Name=Duino Coin PC Miner -Comment=Duino Coin miner for the raspberry pi +Comment=Duino Coin miner for the Raspberry Pi Exec=python3 /home/$u/duino-coin/PC_Miner.py Icon=/home/$u/duino-coin/Resources/PCMiner.png Terminal=true @@ -56,7 +56,7 @@ Type=Application Categories=Utility; StartupNotify=true" > ~/.local/share/applications/duino-coin-avr.desktop cd ~/ -if [ -f ~/duco-install-rpi.sh]; then +if [ -f ~/duco-install-rpi.sh ]; then rm duco-install-rpi.sh fi -echo "Installed" \ No newline at end of file +echo "Installed" From d64225c4247a6b0e132aa77fe6790a162a818a23 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:04:11 +0200 Subject: [PATCH 02/52] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae14846c..5be131a4 100644 --- a/README.md +++ b/README.md @@ -184,11 +184,12 @@ Please note the DUCO/day column has been removed since version 4.0 changed the r ## Community-made softwares -### Please note that these softwares are not developed by us and we do not give any guarantees that use of them will not result in an account getting banned. Treat them as a curiosity. +### Please note that these softwares are not developed by us and we do not give any guarantees that use of them will not result in an account getting banned if they get changed in the future. - ### Other miners known to work with Duino-Coin: - * [Dockerized Duino-Coin Miner](https://github.com/simeononsecurity/docker-duino-coin) - A Dockerized version of the Duino-Coin Miner - * :point_right: [**RP2040-HAT-MINING-C**](https://github.com/Wiznet/RP2040-HAT-MINING-C) - **WIZnet RP2040** mining stack + ### Miners and tools built by the Duino-Coin community: + * [Duinogotchi](https://github.com/OSRdesign/duinogotchi) - Duino-Coin virtual pet project by OSRdesign + * [Dockerized Duino-Coin Miner](https://github.com/simeononsecurity/docker-duino-coin) - A Dockerized version of the Duino-Coin Miner by simeononsecurity + * :point_right: [**RP2040-HAT-MINING-C**](https://github.com/Wiznet/RP2040-HAT-MINING-C) - **WIZnet RP2040 mining stack** * [DuinoCoinEthernetMiner](https://github.com/Pumafron/DuinoCoinEthernetMiner) - Arduino Ethernet shield Miner by Pumafron * [STM8 DUCO Miner](https://github.com/BBS215/STM8_DUCO_miner) - STM8S firmware for mining DUCO by BBS215 * [DuinoCoinbyLabVIEW](https://github.com/ericddm/DuinoCoinbyLabVIEW) - miner for LabVIEW family by ericddm From dfd5cac29ffe6d46b5c65e58a8b2df572bbf8384 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:05:05 +0200 Subject: [PATCH 03/52] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5be131a4..564579de 100644 --- a/README.md +++ b/README.md @@ -186,8 +186,7 @@ Please note the DUCO/day column has been removed since version 4.0 changed the r ### Please note that these softwares are not developed by us and we do not give any guarantees that use of them will not result in an account getting banned if they get changed in the future. - ### Miners and tools built by the Duino-Coin community: - * [Duinogotchi](https://github.com/OSRdesign/duinogotchi) - Duino-Coin virtual pet project by OSRdesign + ### Miners made by the Duino-Coin community: * [Dockerized Duino-Coin Miner](https://github.com/simeononsecurity/docker-duino-coin) - A Dockerized version of the Duino-Coin Miner by simeononsecurity * :point_right: [**RP2040-HAT-MINING-C**](https://github.com/Wiznet/RP2040-HAT-MINING-C) - **WIZnet RP2040 mining stack** * [DuinoCoinEthernetMiner](https://github.com/Pumafron/DuinoCoinEthernetMiner) - Arduino Ethernet shield Miner by Pumafron @@ -214,6 +213,7 @@ Please note the DUCO/day column has been removed since version 4.0 changed the r * [Teensy 4.1 code for Arduino IDE](https://github.com/revoxhere/duino-coin/blob/master/Unofficial%20miners/Teensy_code/Teensy_code.ino) by joaquinbvw ### Other tools: + * [**Duinogotchi**](https://github.com/OSRdesign/duinogotchi) - Duino-Coin virtual pet project by OSRdesign * [Duino Miner](https://github.com/g7ltt/Duino-Miner) - Arduino Nano based DUCO miner files and documentation by g7ltt * [DUINO Mining Rig](https://repalmakershop.com/pages/duino-mining-rig) - 3D files, PCB designs and instructions for creating your own Duino rig by ReP_AL * [DuinoCoin-balance-Home-Assistant](https://github.com/NL647/DuinoCoin-balance-Home-Assistant) - addon for home assistant displaying your balance by NL647 From 8a5b02d1042ae576af4ceaa6a9888aa5d4d0e29e Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:54:14 +0200 Subject: [PATCH 04/52] Added a WDT watchdog for ESP8266s --- ESP_Code/ESP_Code.ino | 47 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 64ba34d1..08b849a3 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -3,7 +3,7 @@ ( _ \( )( )(_ _)( \( )( _ )___ / __)( _ )(_ _)( \( ) )(_) ))(__)( _)(_ ) ( )(_)((___)( (__ )(_)( _)(_ ) ( (____/(______)(____)(_)\_)(_____) \___)(_____)(____)(_)\_) - Official code for all ESP8266/32 boards version 4.1 + Official code for all ESP8266/32 boards version 4.2 Main .ino file The Duino-Coin Team & Community 2019-2024 © MIT Licensed @@ -34,10 +34,10 @@ #include #else #include - #include #include #include #include + #include #endif #include @@ -76,6 +76,31 @@ WebServer server(80); #endif +#if defined(ESP8266) + // WDT Loop + // See lwdtcb() and lwdtFeed() below + Ticker lwdTimer; + + unsigned long lwdCurrentMillis = 0; + unsigned long lwdTimeOutMillis = LWD_TIMEOUT; + + void RestartESP(String msg) { + Serial.println(msg); + Serial.println("Restarting ESP..."); + ESP.reset(); + } + + void ICACHE_RAM_ATTR lwdtcb(void) { + if ((millis() - lwdCurrentMillis > LWD_TIMEOUT) || (lwdTimeOutMillis - lwdCurrentMillis != LWD_TIMEOUT)) + RestartESP("Loop WDT Failed!"); + } + + void lwdtFeed(void) { + lwdCurrentMillis = millis(); + lwdTimeOutMillis = lwdCurrentMillis + LWD_TIMEOUT; + } +#endif + namespace { MiningConfig *configuration = new MiningConfig( DUCO_USER, @@ -373,7 +398,7 @@ void setup() { delay(500); #if defined(SERIAL_PRINTING) - Serial.begin(500000); + Serial.begin(SERIAL_BAUDRATE); Serial.println("\n\nDuino-Coin " + String(configuration->MINER_VER)); #endif pinMode(LED_BUILTIN, OUTPUT); @@ -443,6 +468,15 @@ void setup() { server.begin(); #endif + #if defined(ESP8266) + // Start the WDT watchdog + lwdtFeed(); + lwdTimer.attach_ms(LWD_TIMEOUT, lwdtcb); + #else + // Fastest clock mode for 32s + setCpuFrequencyMhz(240); + #endif + job[0]->blink(BLINK_SETUP_COMPLETE); #if CORE == 2 && defined(ESP32) @@ -452,16 +486,19 @@ void setup() { } void loopOneCore() { - job[0]->mine(); - #if defined(ESP8266) // Fastest clock mode for 8266s system_update_cpu_freq(160); + os_update_cpu_frequency(160); + // Feed the watchdog + lwdtFeed(); #else // Fastest clock mode for 32s setCpuFrequencyMhz(240); #endif + job[0]->mine(); + VerifyWifi(); ArduinoOTA.handle(); #if defined(WEB_DASHBOARD) From 5ef45518e7b483d2e9abc1daa2e5f1ce81412116 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:56:39 +0200 Subject: [PATCH 05/52] Added WDT and baudrate setting --- ESP_Code/Settings.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index f58e8d20..99795c91 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -28,6 +28,12 @@ extern const char PASSWORD[] = "PASSW0RD"; // Comment out the line below if you wish to disable Serial printing #define SERIAL_PRINTING +// Edit the line below if you wish to change the serial speed (low values may reduce performance but are less prone to interference) +#define SERIAL_BAUDRATE 500000 + +// ESP8266 WDT loop watchdog. Do not edit this value, but if you must - do not set it too low or it will falsely trigger during mining! +#define LWD_TIMEOUT 30000 + // -------------------------------------------------------------- // // ---------------------- IoT examples -------------------------- // @@ -62,7 +68,7 @@ extern const char PASSWORD[] = "PASSW0RD"; #define BLINK_SETUP_COMPLETE 2 #define BLINK_CLIENT_CONNECT 5 -#define SOFTWARE_VERSION "4.1" +#define SOFTWARE_VERSION "4.2" extern unsigned int hashrate = 0; extern unsigned int difficulty = 0; extern unsigned long share_count = 0; From 1fd1389d82ca1caef7e1b1d72af0fde00d4c85b1 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sun, 14 Jul 2024 23:53:13 +0200 Subject: [PATCH 06/52] System events handling --- ESP_Code/MiningJob.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index 9d488c7e..c3e70831 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -90,6 +90,11 @@ class MiningJob { return false; } + void handleSystemEvents(void) { + ArduinoOTA.handle(); + yield(); + } + void mine() { connectToNode(); askForJob(); @@ -105,11 +110,9 @@ class MiningJob { DSHA1 ctx = *dsha1; ctx.write((const unsigned char *)counter.c_str(), counter.strlen()).finalize(hashArray); - #if CORE == 1 - yield(); - #elif defined(ESP8266) - ESP.wdtFeed(); - #endif + if (max_micros_elapsed(micros(), 500000)) { + handleSystemEvents(); + } if (memcmp(getExpectedHash(), hashArray, 20) == 0) { unsigned long elapsed_time = micros() - start_time; From 6dd6f9321dbb2e1e24edd4e494473370db68b726 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:57:55 +0200 Subject: [PATCH 07/52] SSD1306 support --- ESP_Code/ESP_Code.ino | 145 ++++++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 62 deletions(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 08b849a3..6248bdea 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -59,6 +59,10 @@ #include "Dashboard.h" #endif +#if defined(DISPLAY_SSD1306) + #include "DisplayHal.h" +#endif + // Auto adjust physical core count // (ESP32-S2/C3 have 1 core, ESP32 has 2 cores, ESP8266 has 1 core) #if defined(ESP8266) @@ -136,6 +140,7 @@ namespace { WiFiClientSecure client; client.setInsecure(); HTTPClient http; + http.setReuse(false); if (http.begin(client, URL)) { int httpCode = http.GET(); @@ -175,52 +180,50 @@ namespace { } #ifdef USE_LAN - void WiFiEvent(WiFiEvent_t event) - { - switch (event) { - case ARDUINO_EVENT_ETH_START: - #if defined(SERIAL_PRINTING) - Serial.println("ETH Started"); - #endif - // The hostname must be set after the interface is started, but needs - // to be set before DHCP, so set it from the event handler thread. - ETH.setHostname("esp32-ethernet"); - break; - case ARDUINO_EVENT_ETH_CONNECTED: - #if defined(SERIAL_PRINTING) - Serial.println("ETH Connected"); - #endif - break; - case ARDUINO_EVENT_ETH_GOT_IP: - #if defined(SERIAL_PRINTING) - Serial.println("ETH Got IP"); - #endif - eth_connected = true; - break; - - case ARDUINO_EVENT_ETH_DISCONNECTED: - #if defined(SERIAL_PRINTING) - Serial.println("ETH Disconnected"); - #endif - eth_connected = false; - break; - case ARDUINO_EVENT_ETH_STOP: - #if defined(SERIAL_PRINTING) - Serial.println("ETH Stopped"); - #endif - eth_connected = false; - break; - default: - break; - } - } + void WiFiEvent(WiFiEvent_t event) { + switch (event) { + case ARDUINO_EVENT_ETH_START: + #if defined(SERIAL_PRINTING) + Serial.println("ETH Started"); + #endif + // The hostname must be set after the interface is started, but needs + // to be set before DHCP, so set it from the event handler thread. + ETH.setHostname("esp32-ethernet"); + break; + case ARDUINO_EVENT_ETH_CONNECTED: + #if defined(SERIAL_PRINTING) + Serial.println("ETH Connected"); + #endif + break; + case ARDUINO_EVENT_ETH_GOT_IP: + #if defined(SERIAL_PRINTING) + Serial.println("ETH Got IP"); + #endif + eth_connected = true; + break; + case ARDUINO_EVENT_ETH_DISCONNECTED: + #if defined(SERIAL_PRINTING) + Serial.println("ETH Disconnected"); + #endif + eth_connected = false; + break; + case ARDUINO_EVENT_ETH_STOP: + #if defined(SERIAL_PRINTING) + Serial.println("ETH Stopped"); + #endif + eth_connected = false; + break; + default: + break; + } + } #endif void SetupWifi() { #ifdef USE_LAN #if defined(SERIAL_PRINTING) - Serial.println("Connecting to Ethernet..."); + Serial.println("Connecting to Ethernet..."); #endif WiFi.onEvent(WiFiEvent); // Will call WiFiEvent() from another thread. ETH.begin(); @@ -234,16 +237,17 @@ namespace { } #if defined(SERIAL_PRINTING) - Serial.println("\n\nSuccessfully connected to Ethernet"); - Serial.println("Local IP address: " + ETH.localIP().toString()); - Serial.println("Rig name: " + String(RIG_IDENTIFIER)); - Serial.println(); + Serial.println("\n\nSuccessfully connected to Ethernet"); + Serial.println("Local IP address: " + ETH.localIP().toString()); + Serial.println("Rig name: " + String(RIG_IDENTIFIER)); + Serial.println(); #endif #else #if defined(SERIAL_PRINTING) - Serial.println("Connecting to: " + String(SSID)); + Serial.println("Connecting to: " + String(SSID)); #endif + WiFi.mode(WIFI_STA); // Setup ESP in client mode #if defined(ESP8266) WiFi.setSleepMode(WIFI_NONE_SLEEP); @@ -251,12 +255,15 @@ namespace { WiFi.setSleep(false); #endif WiFi.begin(SSID, PASSWORD); - + + #if defined(SERIAL_PRINTING) + Serial.println("Connecting..."); + #endif int wait_passes = 0; while (WiFi.waitForConnectResult() != WL_CONNECTED) { delay(500); #if defined(SERIAL_PRINTING) - Serial.print("."); + Serial.print("."); #endif if (++wait_passes >= 10) { WiFi.begin(SSID, PASSWORD); @@ -265,10 +272,10 @@ namespace { } #if defined(SERIAL_PRINTING) - Serial.println("\n\nSuccessfully connected to WiFi"); - Serial.println("Local IP address: " + WiFi.localIP().toString()); - Serial.println("Rig name: " + String(RIG_IDENTIFIER)); - Serial.println(); + Serial.println("\n\nSuccessfully connected to WiFi"); + Serial.println("Local IP address: " + WiFi.localIP().toString()); + Serial.println("Rig name: " + String(RIG_IDENTIFIER)); + Serial.println(); #endif #endif @@ -326,12 +333,6 @@ namespace { #endif } - void handleSystemEvents(void) { - VerifyWifi(); - ArduinoOTA.handle(); - yield(); - } - #if defined(WEB_DASHBOARD) void dashboard() { #if defined(SERIAL_PRINTING) @@ -398,11 +399,15 @@ void setup() { delay(500); #if defined(SERIAL_PRINTING) - Serial.begin(SERIAL_BAUDRATE); - Serial.println("\n\nDuino-Coin " + String(configuration->MINER_VER)); + Serial.begin(SERIAL_BAUDRATE); + Serial.println("\n\nDuino-Coin " + String(configuration->MINER_VER)); #endif pinMode(LED_BUILTIN, OUTPUT); + #if defined(DISPLAY_SSD1306) + screen_setup(); + #endif + assert(CORE == 1 || CORE == 2); WALLET_ID = String(random(0, 2811)); // Needed for miner grouping in the wallet job[0] = new MiningJob(0, configuration); @@ -472,9 +477,6 @@ void setup() { // Start the WDT watchdog lwdtFeed(); lwdTimer.attach_ms(LWD_TIMEOUT, lwdtcb); - #else - // Fastest clock mode for 32s - setCpuFrequencyMhz(240); #endif job[0]->blink(BLINK_SETUP_COMPLETE); @@ -499,6 +501,25 @@ void loopOneCore() { job[0]->mine(); + #if defined(DISPLAY_SSD1306) + float hashrate_float = hashrate / 1000.0; + float accept_rate = (accepted_share_count / share_count) * 100.0; + Serial.println(accepted_share_count / share_count); + Serial.println(accept_rate); + + long millisecs = millis(); + int uptime_secs = int((millisecs / 1000) % 60); + int uptime_mins = int((millisecs / (1000 * 60)) % 60); + int uptime_hours = int((millisecs / (1000 * 60 * 60)) % 24); + String uptime = String(uptime_hours) + "h" + String(uptime_mins) + "m" + String(uptime_secs) + "s"; + + float sharerate = share_count / (millisecs / 1000.0); + + display_mining_results(String(hashrate_float, 1), String(accepted_share_count), String(share_count), String(uptime), + String(node_id), String(difficulty / 100), String(sharerate, 1), + String(ping), String(accept_rate, 1)); + #endif + VerifyWifi(); ArduinoOTA.handle(); #if defined(WEB_DASHBOARD) From 4b14091ab098be52d3aa5abd91946e9a7be63dd0 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:58:17 +0200 Subject: [PATCH 08/52] SSD1306 support --- ESP_Code/DisplayHal.h | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 ESP_Code/DisplayHal.h diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h new file mode 100644 index 00000000..f425edf7 --- /dev/null +++ b/ESP_Code/DisplayHal.h @@ -0,0 +1,87 @@ +// Abstraction layer for handling various types of screens +// See Settings.h for enabling the screen of your choice +#ifndef DISPLAY_HAL_H +#define DISPLAY_HAL_H + +// Abstraction layer: custom fonts, images, etc. +#if defined(DISPLAY_SSD1306) + static const unsigned char image_check_contour_bits[] U8X8_PROGMEM = {0x00,0x04,0x00,0x0a,0x04,0x11,0x8a,0x08,0x51,0x04,0x22,0x02,0x04,0x01,0x88,0x00,0x50,0x00,0x20,0x00}; + static const unsigned char image_network_1_bar_bits[] U8X8_PROGMEM = {0x00,0x70,0x00,0x50,0x00,0x50,0x00,0x50,0x00,0x57,0x00,0x55,0x00,0x55,0x00,0x55,0x70,0x55,0x50,0x55,0x50,0x55,0x50,0x55,0x57,0x55,0x57,0x55,0x77,0x77,0x00,0x00}; + static const unsigned char image_network_2_bars_bits[] U8X8_PROGMEM = {0x00,0x70,0x00,0x50,0x00,0x50,0x00,0x50,0x00,0x57,0x00,0x55,0x00,0x55,0x00,0x55,0x70,0x55,0x70,0x55,0x70,0x55,0x70,0x55,0x77,0x55,0x77,0x55,0x77,0x77,0x00,0x00}; + static const unsigned char image_network_3_bars_bits[] U8X8_PROGMEM = {0x00,0x70,0x00,0x50,0x00,0x50,0x00,0x50,0x00,0x57,0x00,0x57,0x00,0x57,0x00,0x57,0x70,0x57,0x70,0x57,0x70,0x57,0x70,0x57,0x77,0x57,0x77,0x57,0x77,0x77,0x00,0x00}; + static const unsigned char image_network_4_bars_bits[] U8X8_PROGMEM = {0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x77,0x00,0x77,0x00,0x77,0x00,0x77,0x70,0x77,0x70,0x77,0x70,0x77,0x70,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x00,0x00}; + static const unsigned char image_duco_logo_bits[] U8X8_PROGMEM = {0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0xff,0x00,0xc0,0x01,0x9f,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x9f,0x01,0xc0,0x01,0xff,0x00,0x7f,0x00}; +#endif + +#if defined(DISPLAY_SSD1306) + void screen_setup() { + // Ran during setup() + // Abstraction layer: screen initialization + + #if defined(DISPLAY_SSD1306) + u8g2.begin(); + u8g2.clearBuffer(); + u8g2.setFontMode(1); + u8g2.setBitmapMode(1); + u8g2.sendBuffer(); + #endif + } + + + void display_mining_results(String hashrate, String accepted_shares, String total_shares, String uptime, String node, + String difficulty, String sharerate, String ping, String accept_rate) { + // Ran after each found share + // Abstraction layer: displaying mining results + Serial.println("Displaying mining results"); + + #if defined(DISPLAY_SSD1306) + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_profont10_tr); + u8g2.drawStr(67, 26, "kH"); + u8g2.setFont(u8g2_font_profont29_tr); + u8g2.drawStr(2, 36, hashrate.c_str()); + + u8g2.setFont(u8g2_font_haxrcorp4089_tr); + u8g2.drawStr(52, 12, node.c_str()); + + u8g2.setFont(u8g2_font_t0_11_tr); + u8g2.drawStr(17, 47, (accepted_shares + "/" + total_shares).c_str()); + u8g2.setFont(u8g2_font_5x7_tr); + u8g2.drawStr(88, 47, ("(" + accept_rate + "%)").c_str()); + + u8g2.setFont(u8g2_font_profont12_tr); + u8g2.drawStr(20, 12, (ping + "ms").c_str()); + u8g2.drawStr(69, 36, "s"); + + u8g2.setFont(u8g2_font_6x13_tr); + u8g2.drawStr(78, 61, uptime.c_str()); + + u8g2.drawStr(85, 38, sharerate.c_str()); + u8g2.drawStr(85, 27, difficulty.c_str()); + u8g2.drawLine(67, 28, 75, 28); + + u8g2.drawXBMP(2, 38, 13, 10, image_check_contour_bits); + + if (WiFi.RSSI() > -40) { + u8g2.drawXBMP(1, 0, 15, 16, image_network_4_bars_bits); + } else if (WiFi.RSSI() > -60) { + u8g2.drawXBMP(1, 0, 15, 16, image_network_3_bars_bits); + } else if (WiFi.RSSI() > -75) { + u8g2.drawXBMP(1, 0, 15, 16, image_network_2_bars_bits); + } else { + u8g2.drawXBMP(1, 0, 15, 16, image_network_1_bar_bits); + } + + u8g2.setFont(u8g2_font_4x6_tr); + u8g2.drawStr(14, 61, String(WiFi.localIP().toString()).c_str()); + u8g2.drawStr(14, 55, ("Duino-Coin " + String(SOFTWARE_VERSION)).c_str()); + u8g2.drawXBMP(2, 11, 9, 50, image_duco_logo_bits); + u8g2.drawStr(111, 27, "diff"); + u8g2.drawStr(107, 38, "shr/s"); + + u8g2.sendBuffer(); + #endif + } +#endif + +#endif From 4e0e4ead090872fa0a6f8acf61a3a4ebe8147329 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:58:36 +0200 Subject: [PATCH 09/52] Update MiningJob.h --- ESP_Code/MiningJob.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index c3e70831..9e4a247b 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -122,7 +122,7 @@ class MiningJob { #if defined(LED_BLINKING) digitalWrite(LED_BUILTIN, HIGH); - #endif + #endif submit(counter, hashrate, elapsed_time_s); break; @@ -234,8 +234,14 @@ class MiningJob { SEP_TOKEN + "DUCOID" + String(chipID) + SEP_TOKEN + String(WALLET_ID) + END_TOKEN); - + + unsigned long ping_start = millis(); waitForClientData(); + ping = millis() - ping_start; + + if (client_buffer == "GOOD") { + accepted_share_count++; + } #if defined(SERIAL_PRINTING) Serial.println("Core [" + String(core) + "] - " + From 5587e975a350a9874e9b43160e73a6d1bc0b4be4 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:59:33 +0200 Subject: [PATCH 10/52] SSD1306 support --- ESP_Code/Settings.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index 99795c91..f51a375f 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -34,6 +34,14 @@ extern const char PASSWORD[] = "PASSW0RD"; // ESP8266 WDT loop watchdog. Do not edit this value, but if you must - do not set it too low or it will falsely trigger during mining! #define LWD_TIMEOUT 30000 +// Uncomment to enable a SSD1306 OLED screen on the I2C bus to display mining info in real time +// Default connections (can be overriden with Wire.begin(SDA, SCL)): +// GND - GND +// VCC - 5V or 3.3V depending on display +// SCL - GPIO21 (ESP32) or GPIO5 (ESP8266) or GPIO35 (ESP32-S2) +// SDA - GPIO22 (ESP32) or GPIO4 (ESP8266) or GPIO33 (ESP32-S2) +// #define DISPLAY_SSD1306 + // -------------------------------------------------------------- // // ---------------------- IoT examples -------------------------- // @@ -72,8 +80,10 @@ extern const char PASSWORD[] = "PASSW0RD"; extern unsigned int hashrate = 0; extern unsigned int difficulty = 0; extern unsigned long share_count = 0; +extern unsigned long accepted_share_count = 0; extern String node_id = ""; extern String WALLET_ID = ""; +extern unsigned int ping = 0; #if defined(USE_INTERNAL_SENSOR) #include "driver/temp_sensor.h" @@ -101,4 +111,11 @@ extern String WALLET_ID = ""; DHT extern dht(DHTPIN, DHTTYPE); #endif +#if defined(DISPLAY_SSD1306) + #include + #include + // Display definition from the U8G2 library. Edit if you use a different display + U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); +#endif + #endif // End of SETTINGS_H From f73dae98316d6addde8539ec407f4d022420211b Mon Sep 17 00:00:00 2001 From: Matvey <66329687+mavotronik@users.noreply.github.com> Date: Tue, 23 Jul 2024 22:40:00 +0300 Subject: [PATCH 11/52] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 564579de..b09939b4 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,8 @@ Please note the DUCO/day column has been removed since version 4.0 changed the r * [DuCoWallet](https://github.com/viktor02/DuCoWallet) GUI Wallet by viktor02 * [Duco-widget-ios](https://github.com/naphob/duco-widget-ios) - a Duino-Coin iOS widget by Naphob * [Duino Lookup](https://axorax.github.io/duino-lookup/) by axorax + * [Duino Miner Hassio Add-on](https://github.com/mavotronik/hassio-addons/tree/main/duino_miner_hassio_addon) by mavotronik + * [Home Assistant sensors package](https://github.com/mavotronik/Duinocoin_homeassistant) by mavotronik You may also view a similar list on the [website](https://duinocoin.com/apps). From daed9d03cf54762fc379a50bbdafb961cd2ea16f Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:02:11 +0200 Subject: [PATCH 12/52] ESP32 speed improvement and 16x2 LCD support --- ESP_Code/ESP_Code.ino | 150 ++++++++++++++++++++++++++++++++---------- 1 file changed, 116 insertions(+), 34 deletions(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 6248bdea..fdc7373e 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -59,7 +59,7 @@ #include "Dashboard.h" #endif -#if defined(DISPLAY_SSD1306) +#if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) #include "DisplayHal.h" #endif @@ -78,7 +78,25 @@ #if defined(WEB_DASHBOARD) WebServer server(80); -#endif +#endif + +void RestartESP(String msg) { + #if defined(SERIAL_PRINTING) + Serial.println(msg); + Serial.println("Restarting ESP..."); + #endif + + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + display_info("Restarting ESP..."); + #endif + + #if defined(ESP8266) + ESP.reset(); + #else + ESP.restart(); + abort(); + #endif +} #if defined(ESP8266) // WDT Loop @@ -88,12 +106,6 @@ unsigned long lwdCurrentMillis = 0; unsigned long lwdTimeOutMillis = LWD_TIMEOUT; - void RestartESP(String msg) { - Serial.println(msg); - Serial.println("Restarting ESP..."); - ESP.reset(); - } - void ICACHE_RAM_ATTR lwdtcb(void) { if ((millis() - lwdCurrentMillis > LWD_TIMEOUT) || (lwdTimeOutMillis - lwdCurrentMillis != LWD_TIMEOUT)) RestartESP("Loop WDT Failed!"); @@ -133,6 +145,10 @@ namespace { #if defined(SERIAL_PRINTING) Serial.println("Poolpicker selected the best mining node: " + node_id); #endif + + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + display_info(node_id); + #endif } String httpGetString(String URL) { @@ -151,6 +167,9 @@ namespace { #if defined(SERIAL_PRINTING) Serial.printf("Error fetching node from poolpicker: %s\n", http.errorToString(httpCode).c_str()); #endif + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + display_info(http.errorToString(httpCode)); + #endif http.end(); } @@ -172,8 +191,8 @@ namespace { // Increase wait time till a maximum of 32 seconds // (addresses: Limit connection requests on failure in ESP boards #1041) waitTime *= 2; - if (waitTime > 32) - waitTime = 32; + if (waitTime > 32) + RestartESP("Node fetch unavailable"); } UpdateHostPort(input); @@ -255,10 +274,15 @@ namespace { WiFi.setSleep(false); #endif WiFi.begin(SSID, PASSWORD); + + // Set normal DNS servers + IPAddress primaryDNS(8, 8, 8, 8); + IPAddress secondaryDNS(1, 1, 1, 1); + + if (!WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), primaryDNS, secondaryDNS)) { + Serial.println("Failed to configure DNS"); + } - #if defined(SERIAL_PRINTING) - Serial.println("Connecting..."); - #endif int wait_passes = 0; while (WiFi.waitForConnectResult() != WL_CONNECTED) { delay(500); @@ -280,7 +304,10 @@ namespace { #endif - SelectNode(); + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + display_info("Waiting for node..."); + #endif + SelectNode(); } void SetupOTA() { @@ -345,7 +372,7 @@ namespace { s.replace("@@IP_ADDR@@", WiFi.localIP().toString()); #endif - s.replace("@@HASHRATE@@", String(hashrate / 1000)); + s.replace("@@HASHRATE@@", String((hashrate+hashrate_core_two) / 1000)); s.replace("@@DIFF@@", String(difficulty / 100)); s.replace("@@SHARES@@", String(share_count)); s.replace("@@NODE@@", String(node_id)); @@ -379,6 +406,23 @@ void task1_func(void *) { VOID LOOP() { job[0]->mine(); + + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + float hashrate_float = (hashrate+hashrate_core_two) / 1000.0; + float accept_rate = (accepted_share_count / 0.01 / share_count); + + long millisecs = millis(); + int uptime_secs = int((millisecs / 1000) % 60); + int uptime_mins = int((millisecs / (1000 * 60)) % 60); + int uptime_hours = int((millisecs / (1000 * 60 * 60)) % 24); + String uptime = String(uptime_hours) + "h" + String(uptime_mins) + "m" + String(uptime_secs) + "s"; + + float sharerate = share_count / (millisecs / 1000.0); + + display_mining_results(String(hashrate_float, 1), String(accepted_share_count), String(share_count), String(uptime), + String(node_id), String(difficulty / 100), String(sharerate, 1), + String(ping), String(accept_rate, 1)); + #endif } #endif } @@ -391,6 +435,23 @@ void task2_func(void *) { VOID LOOP() { job[1]->mine(); + + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + float hashrate_float = (hashrate+hashrate_core_two) / 1000.0; + float accept_rate = (accepted_share_count / 0.01 / share_count); + + long millisecs = millis(); + int uptime_secs = int((millisecs / 1000) % 60); + int uptime_mins = int((millisecs / (1000 * 60)) % 60); + int uptime_hours = int((millisecs / (1000 * 60 * 60)) % 24); + String uptime = String(uptime_hours) + "h" + String(uptime_mins) + "m" + String(uptime_secs) + "s"; + + float sharerate = share_count / (millisecs / 1000.0); + + display_mining_results(String(hashrate_float, 1), String(accepted_share_count), String(share_count), String(uptime), + String(node_id), String(difficulty / 100), String(sharerate, 1), + String(ping), String(accept_rate, 1)); + #endif } #endif } @@ -404,8 +465,10 @@ void setup() { #endif pinMode(LED_BUILTIN, OUTPUT); - #if defined(DISPLAY_SSD1306) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) screen_setup(); + display_info("Welcome back!"); + delay(500); #endif assert(CORE == 1 || CORE == 2); @@ -449,6 +512,9 @@ void setup() { #endif #endif + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + display_info("Waiting for WiFi..."); + #endif SetupWifi(); SetupOTA(); @@ -479,15 +545,6 @@ void setup() { lwdTimer.attach_ms(LWD_TIMEOUT, lwdtcb); #endif - job[0]->blink(BLINK_SETUP_COMPLETE); - - #if CORE == 2 && defined(ESP32) - task1.start(task1_func); - task2.start(task2_func); - #endif -} - -void loopOneCore() { #if defined(ESP8266) // Fastest clock mode for 8266s system_update_cpu_freq(160); @@ -498,14 +555,39 @@ void loopOneCore() { // Fastest clock mode for 32s setCpuFrequencyMhz(240); #endif - + + job[0]->blink(BLINK_SETUP_COMPLETE); + + #if defined(ESP32) && CORE == 2 + mutexClientData = xSemaphoreCreateMutex(); + mutexConnectToServer = xSemaphoreCreateMutex(); + + xTaskCreatePinnedToCore(system_events_func, "system_events_func", 10000, NULL, 1, NULL, 0); + xTaskCreatePinnedToCore(task1_func, "task1_func", 10000, NULL, 1, NULL, 0); + xTaskCreatePinnedToCore(task2_func, "task2_func", 10000, NULL, 2, NULL, 1); + #endif +} + +void system_events_func(void* parameter) { + while (true) { + #if defined(WEB_DASHBOARD) + server.handleClient(); + #endif + ArduinoOTA.handle(); + delay(10); + } +} + +void single_core_loop() { job[0]->mine(); - #if defined(DISPLAY_SSD1306) - float hashrate_float = hashrate / 1000.0; - float accept_rate = (accepted_share_count / share_count) * 100.0; - Serial.println(accepted_share_count / share_count); - Serial.println(accept_rate); + #if defined(ESP8266) + lwdtFeed(); + #endif + + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + float hashrate_float = (hashrate+hashrate_core_two) / 1000.0; + float accept_rate = (accepted_share_count / 0.01 / share_count); long millisecs = millis(); int uptime_secs = int((millisecs / 1000) % 60); @@ -528,7 +610,7 @@ void loopOneCore() { } void loop() { - #if CORE == 1 - loopOneCore(); - #endif + #if defined(ESP8266) || defined(CONFIG_FREERTOS_UNICORE) + single_core_loop(); + #endif } From ce9dad189c24a072d51ff265bb81239e0386324d Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:04:09 +0200 Subject: [PATCH 13/52] 16x2 LCD support --- ESP_Code/DisplayHal.h | 94 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 5 deletions(-) diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index f425edf7..5990d3ed 100644 --- a/ESP_Code/DisplayHal.h +++ b/ESP_Code/DisplayHal.h @@ -11,9 +11,16 @@ static const unsigned char image_network_3_bars_bits[] U8X8_PROGMEM = {0x00,0x70,0x00,0x50,0x00,0x50,0x00,0x50,0x00,0x57,0x00,0x57,0x00,0x57,0x00,0x57,0x70,0x57,0x70,0x57,0x70,0x57,0x70,0x57,0x77,0x57,0x77,0x57,0x77,0x77,0x00,0x00}; static const unsigned char image_network_4_bars_bits[] U8X8_PROGMEM = {0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x77,0x00,0x77,0x00,0x77,0x00,0x77,0x70,0x77,0x70,0x77,0x70,0x77,0x70,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x00,0x00}; static const unsigned char image_duco_logo_bits[] U8X8_PROGMEM = {0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0xff,0x00,0xc0,0x01,0x9f,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x9f,0x01,0xc0,0x01,0xff,0x00,0x7f,0x00}; + static const unsigned char image_duco_logo_big_bits[] U8X8_PROGMEM = {0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x01,0x00,0x00,0xfc,0xff,0xff,0x0f,0x00,0x00,0xfc,0xff,0xff,0x3f,0x00,0x00,0xfc,0xff,0xff,0x7f,0x00,0x00,0xfc,0xff,0xff,0xff,0x00,0x00,0xfc,0xff,0xff,0xff,0x01,0x00,0xfc,0xff,0xff,0xff,0x03,0x00,0xf8,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xfe,0x0f,0x00,0xfc,0xff,0x03,0xf8,0x0f,0x00,0xfc,0xff,0x0f,0xf0,0x1f,0x00,0xfc,0xff,0x1f,0xe0,0x1f,0x00,0xfc,0xff,0x3f,0xe0,0x3f,0x00,0xfc,0xff,0x7f,0xc0,0x3f,0x00,0xfc,0xff,0xff,0xc0,0x7f,0x00,0xf8,0xff,0xff,0x80,0x7f,0x00,0x00,0x00,0xfe,0x80,0x7f,0x00,0x00,0x00,0xfc,0x81,0x7f,0x00,0x00,0x00,0xfc,0x01,0x7f,0x00,0x00,0x00,0xfc,0x01,0xff,0x00,0x00,0x00,0xfc,0x01,0xff,0x00,0x00,0x00,0xfc,0x01,0xff,0x00,0x00,0x00,0xfc,0x01,0xff,0x00,0x00,0x00,0xfc,0x01,0xff,0x00,0x00,0x00,0xfc,0x81,0x7f,0x00,0x00,0x00,0xfe,0x81,0x7f,0x00,0x00,0x80,0xff,0x80,0x7f,0x00,0xfc,0xff,0xff,0xc0,0x7f,0x00,0xfc,0xff,0xff,0xc0,0x7f,0x00,0xfc,0xff,0x7f,0xe0,0x3f,0x00,0xfc,0xff,0x3f,0xf0,0x3f,0x00,0xfc,0xff,0x1f,0xf8,0x1f,0x00,0xfc,0xff,0x0f,0xfc,0x1f,0x00,0xf8,0xff,0x01,0xfe,0x0f,0x00,0x00,0x00,0xc0,0xff,0x0f,0x00,0xfc,0xff,0xff,0xff,0x07,0x00,0xfc,0xff,0xff,0xff,0x03,0x00,0xfc,0xff,0xff,0xff,0x01,0x00,0xfc,0xff,0xff,0xff,0x00,0x00,0xfc,0xff,0xff,0x7f,0x00,0x00,0xfc,0xff,0xff,0x1f,0x00,0x00,0xfc,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; #endif -#if defined(DISPLAY_SSD1306) +#if defined(DISPLAY_16X2) + static byte duco_logo[] = {0x1E, 0x01, 0x1D, 0x05, 0x1D, 0x01, 0x1E, 0x00}; + static byte check_mark[] = {0x00, 0x00, 0x00, 0x01, 0x02,0x14, 0x08, 0x00}; + static byte kh[] = {0x08, 0x0A, 0x0C, 0x0A, 0x00, 0x0A, 0x0E, 0x0A}; +#endif + +#if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) void screen_setup() { // Ran during setup() // Abstraction layer: screen initialization @@ -25,6 +32,54 @@ u8g2.setBitmapMode(1); u8g2.sendBuffer(); #endif + + #if defined(DISPLAY_16X2) + lcd.begin(16, 2); + lcd.createChar(0, duco_logo); + lcd.createChar(1, check_mark); + lcd.createChar(2, kh); + lcd.home(); + lcd.clear(); + #endif + } + + + void display_info(String message) { + // Abstraction layer: info screens (setups) + + #if defined(DISPLAY_SSD1306) + u8g2.clearBuffer(); + u8g2.drawXBMP(-1, 3, 41, 45, image_duco_logo_big_bits); + u8g2.setFont(u8g2_font_t0_16b_tr); + #if defined(ESP8266) + u8g2.drawStr(42, 27, "ESP8266"); + #elif defined(CONFIG_FREERTOS_UNICORE) + u8g2.drawStr(42, 27, "ESP32S2/C3"); + #else + u8g2.drawStr(42, 27, "ESP32"); + #endif + u8g2.setFont(u8g2_font_t0_13b_tr); + u8g2.drawStr(41, 14, "Duino-Coin"); + u8g2.setFont(u8g2_font_6x10_tr); + u8g2.drawStr(98, 36, "MINER"); + u8g2.setFont(u8g2_font_6x13_tr); + u8g2.drawStr(1, 60, message.c_str()); + u8g2.setFont(u8g2_font_5x8_tr); + u8g2.drawStr(42, 46, "www.duinocoin.com"); + u8g2.setFont(u8g2_font_4x6_tr); + u8g2.drawStr(116, 14, String(SOFTWARE_VERSION).c_str()); + u8g2.sendBuffer(); + #endif + + #if defined(DISPLAY_16X2) + lcd.clear(); + lcd.setCursor(0, 0); + lcd.write(0); + lcd.print(" Duino-Coin "); + lcd.print(SOFTWARE_VERSION); + lcd.setCursor(0, 1); + lcd.print(message); + #endif } @@ -38,8 +93,13 @@ u8g2.clearBuffer(); u8g2.setFont(u8g2_font_profont10_tr); u8g2.drawStr(67, 26, "kH"); - u8g2.setFont(u8g2_font_profont29_tr); - u8g2.drawStr(2, 36, hashrate.c_str()); + if (hashrate.toFloat() < 100.0) { + u8g2.setFont(u8g2_font_profont29_tr); + u8g2.drawStr(2, 36, hashrate.c_str()); + } else { + u8g2.setFont(u8g2_font_profont22_tr); + u8g2.drawStr(3, 35, hashrate.c_str()); + } u8g2.setFont(u8g2_font_haxrcorp4089_tr); u8g2.drawStr(52, 12, node.c_str()); @@ -54,14 +114,14 @@ u8g2.drawStr(69, 36, "s"); u8g2.setFont(u8g2_font_6x13_tr); - u8g2.drawStr(78, 61, uptime.c_str()); + u8g2.drawStr(125-u8g2.getStrWidth(uptime.c_str()), 61, uptime.c_str()); u8g2.drawStr(85, 38, sharerate.c_str()); u8g2.drawStr(85, 27, difficulty.c_str()); u8g2.drawLine(67, 28, 75, 28); u8g2.drawXBMP(2, 38, 13, 10, image_check_contour_bits); - + if (WiFi.RSSI() > -40) { u8g2.drawXBMP(1, 0, 15, 16, image_network_4_bars_bits); } else if (WiFi.RSSI() > -60) { @@ -81,6 +141,30 @@ u8g2.sendBuffer(); #endif + + #if defined(DISPLAY_16X2) + lcd.clear(); + lcd.setCursor(0,0); + lcd.print(hashrate); + lcd.setCursor(4,0); + lcd.write(2); // kh + + lcd.setCursor(7, 0); + lcd.print(difficulty); + lcd.print(" diff"); + + lcd.setCursor(0, 1); + lcd.write(1); // checkmark + lcd.print(accepted_shares); + + lcd.setCursor(6, 1); + lcd.print(ping); + lcd.print("ms"); + + lcd.setCursor(12, 1); + lcd.print(sharerate); + lcd.print("s"); + #endif } #endif From 66cbffadd1b0ea0e9c6ac8dfd67c459cbd2881c3 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:06:30 +0200 Subject: [PATCH 14/52] 16x2 LCD support --- ESP_Code/Settings.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index f51a375f..bd202aac 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -35,13 +35,17 @@ extern const char PASSWORD[] = "PASSW0RD"; #define LWD_TIMEOUT 30000 // Uncomment to enable a SSD1306 OLED screen on the I2C bus to display mining info in real time -// Default connections (can be overriden with Wire.begin(SDA, SCL)): +// Default connections (can be overriden by using a different u8g2 initializer, see line 122): // GND - GND // VCC - 5V or 3.3V depending on display -// SCL - GPIO21 (ESP32) or GPIO5 (ESP8266) or GPIO35 (ESP32-S2) -// SDA - GPIO22 (ESP32) or GPIO4 (ESP8266) or GPIO33 (ESP32-S2) +// SCL - GPIO22 (ESP32) or GPIO5 (D2 on ESP8266) or GPIO35 (ESP32-S2) +// SDA - GPIO21 (ESP32) or GPIO4 (D1 on ESP8266) or GPIO33 (ESP32-S2) // #define DISPLAY_SSD1306 +// Uncomment to enable a 16x2 LCD screen on a direct bus to display mining info in real time +// See line 132 for connections and initializer +// #define DISPLAY_16X2 + // -------------------------------------------------------------- // // ---------------------- IoT examples -------------------------- // @@ -112,10 +116,22 @@ extern unsigned int ping = 0; #endif #if defined(DISPLAY_SSD1306) + // Install "u8g2" if you get an error #include #include // Display definition from the U8G2 library. Edit if you use a different display + // For software I2C, use ..._F_SW_I2C and define the pins in the initializer U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); #endif +#if defined(DISPLAY_16X2) + #include "Wire.h" + // Install "Adafruit_LiquidCrystal" if you get an error + #include "Adafruit_LiquidCrystal.h" + + // initialize the library with the numbers of the interface pins + // RS E D4 D5 D6 D7 + Adafruit_LiquidCrystal lcd(1, 2, 3, 4, 5, 6); +#endif + #endif // End of SETTINGS_H From b25b4b663a4057530e69bd9fc0d57eb8e5c0d594 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:06:53 +0200 Subject: [PATCH 15/52] Stability improvements --- ESP_Code/MiningJob.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index 9e4a247b..fab9470d 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -93,6 +93,7 @@ class MiningJob { void handleSystemEvents(void) { ArduinoOTA.handle(); yield(); + delay(10); // Required vTaskDelay by ESP-IDF } void mine() { @@ -109,22 +110,30 @@ class MiningJob { for (Counter<10> counter; counter < difficulty; ++counter) { DSHA1 ctx = *dsha1; ctx.write((const unsigned char *)counter.c_str(), counter.strlen()).finalize(hashArray); - - if (max_micros_elapsed(micros(), 500000)) { - handleSystemEvents(); - } + + #ifndef CONFIG_FREERTOS_UNICORE + if (max_micros_elapsed(micros(), 500000)) { + handleSystemEvents(); + } + #endif if (memcmp(getExpectedHash(), hashArray, 20) == 0) { unsigned long elapsed_time = micros() - start_time; float elapsed_time_s = elapsed_time * .000001f; - hashrate = counter / elapsed_time_s; share_count++; #if defined(LED_BLINKING) digitalWrite(LED_BUILTIN, HIGH); #endif - submit(counter, hashrate, elapsed_time_s); + if (String(core) == "0") { + hashrate = counter / elapsed_time_s; + submit(counter, hashrate, elapsed_time_s); + } else { + hashrate_core_two = counter / elapsed_time_s; + submit(counter, hashrate_core_two, elapsed_time_s); + } + break; } } @@ -210,6 +219,12 @@ class MiningJob { blink(BLINK_CLIENT_CONNECT); + /* client.print("MOTD" + END_TOKEN); + waitForClientData(); + #if defined(SERIAL_PRINTING) + Serial.println("Core [" + String(core) + "] - MOTD: " + + client_buffer); + #endif */ } void waitForClientData() { From 3dcc24538882587bcd526486a2e42a78e468ce7b Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:16:14 +0200 Subject: [PATCH 16/52] Missing def --- ESP_Code/Settings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index bd202aac..b8e183fe 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -82,6 +82,7 @@ extern const char PASSWORD[] = "PASSW0RD"; #define SOFTWARE_VERSION "4.2" extern unsigned int hashrate = 0; +extern unsigned int hashrate_core_two = 0; extern unsigned int difficulty = 0; extern unsigned long share_count = 0; extern unsigned long accepted_share_count = 0; From cbd1b5b8a4b722ff70d19072c2f26b6272fdf4c1 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:24:26 +0200 Subject: [PATCH 17/52] Update benchmarks --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 564579de..e4a607e2 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,8 @@ Captured at normal multiplier (no weekend boost) | Device | Hashrate | Threads | DUCO/day | |-----------------------|---------------------|---------|----------| | Arduino | 343 H/s | 1 | 12 | -| ESP32 | 84 kH/s (2x42 kH/s) | 2 | 10 | -| ESP32-S2/C3 | 82 kH/s | 1 | 8 | +| ESP32 | 115 kH/s | 2 | 10 | +| ESP32-S2/C3 | 85-95 kH/s | 1 | 8 | | ESP8266 | 66 kH/s | 1 | 6 | | Raspberry Pi 4 (LOW) | 1 MH/s (no fasthash)| 4 | 6-7 | | Raspberry Pi 4 (MED) | 5.4 MH/s (fasthash) | 4 | 7-8 | From 9892be81f2ed87b588df05d3fbb9fa8c0728256f Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:13:57 +0200 Subject: [PATCH 18/52] ESP32 stability improvement --- ESP_Code/MiningJob.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index fab9470d..74186932 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -93,6 +93,7 @@ class MiningJob { void handleSystemEvents(void) { ArduinoOTA.handle(); yield(); + vTaskDelay(10); delay(10); // Required vTaskDelay by ESP-IDF } From 47529e2daeacea537714d7afa3d73fb3d56f7e1d Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:33:24 +0200 Subject: [PATCH 19/52] Update ESP32 hashrate --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b0b83ddc..6646f694 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,8 @@ Captured at normal multiplier (no weekend boost) | Device | Hashrate | Threads | DUCO/day | |-----------------------|---------------------|---------|----------| | Arduino | 343 H/s | 1 | 12 | -| ESP32 | 115 kH/s | 2 | 10 | -| ESP32-S2/C3 | 85-95 kH/s | 1 | 8 | +| ESP32 | 170-180 kH/s | 2 | 10 | +| ESP32-S2/C3 | 85-96 kH/s | 1 | 8 | | ESP8266 | 66 kH/s | 1 | 6 | | Raspberry Pi 4 (LOW) | 1 MH/s (no fasthash)| 4 | 6-7 | | Raspberry Pi 4 (MED) | 5.4 MH/s (fasthash) | 4 | 7-8 | From 342c043ecf05baada0133f4c81c489d98986bd65 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:25:52 +0200 Subject: [PATCH 20/52] Boot screen and improvements --- ESP_Code/DisplayHal.h | 126 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 2 deletions(-) diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index 5990d3ed..a8fdf72a 100644 --- a/ESP_Code/DisplayHal.h +++ b/ESP_Code/DisplayHal.h @@ -20,6 +20,41 @@ static byte kh[] = {0x08, 0x0A, 0x0C, 0x0A, 0x00, 0x0A, 0x0E, 0x0A}; #endif + #if defined(DISPLAY_SSD1306) + void drawStrMultiline(const char *msg, int xloc, int yloc) { + //https://github.com/olikraus/u8g2/discussions/1479 + int dspwidth = u8g2.getDisplayWidth(); + int strwidth = 0; + char glyph[2]; glyph[1] = 0; + + for (const char *ptr = msg, *lastblank = NULL; *ptr; ++ptr) { + while (xloc == 0 && *msg == ' ') + if (ptr == msg++) ++ptr; + + glyph[0] = *ptr; + strwidth += u8g2.getStrWidth(glyph); + if (*ptr == ' ') lastblank = ptr; + else ++strwidth; + + if (xloc + strwidth > dspwidth) { + int starting_xloc = xloc; + while (msg < (lastblank ? lastblank : ptr)) { + glyph[0] = *msg++; + xloc += u8g2.drawStr(xloc, yloc, glyph); + } + + strwidth -= xloc - starting_xloc; + yloc += u8g2.getMaxCharHeight(); + xloc = 0; lastblank = NULL; + } + } + while (*msg) { + glyph[0] = *msg++; + xloc += u8g2.drawStr(xloc, yloc, glyph); + } + } +#endif + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) void screen_setup() { // Ran during setup() @@ -44,6 +79,91 @@ } + void display_boot() { + // Abstraction layer: compilation time, features, etc. + + #if defined(DISPLAY_16X2) + lcd.clear(); + #if defined(ESP8266) + lcd.print("ESP8266 "); + #elif defined(CONFIG_FREERTOS_UNICORE) + lcd.print("ESP32S2/C3 "); + #else + lcd.print("ESP32 "); + #endif + #if defined(ESP8266) + lcd.print(String(ESP.getCpuFreqMHz()).c_str()); + #else + lcd.print(String(getCpuFrequencyMhz()).c_str()); + #endif + lcd.print(" MHz"); + + lcd.setCursor(0, 1); + lcd.print(__DATE__); + #endif + + #if defined(DISPLAY_SSD1306) + u8g2.clearBuffer(); + + u8g2.setFont(u8g2_font_profont15_tr); + u8g2.setCursor(2, 13); + #if defined(ESP8266) + u8g2.print("ESP8266 "); + #elif defined(CONFIG_FREERTOS_UNICORE) + u8g2.print("ESP32S2/C3 "); + #else + u8g2.print("ESP32 "); + #endif + + #if defined(ESP8266) + u8g2.print(String(ESP.getCpuFreqMHz()).c_str()); + #else + u8g2.print(String(getCpuFrequencyMhz()).c_str()); + #endif + u8g2.print(" MHz"); + + u8g2.setFont(u8g2_font_profont10_tr); + u8g2.drawLine(1, 27, 126, 27); + u8g2.setCursor(2, 24); + u8g2.print("Compiled "); + u8g2.print(__DATE__); + + + u8g2.drawStr(2, 37, "Features:"); + u8g2.setCursor(2, 46); + String features_str = "OTA "; + #if defined(USE_LAN) + features_str += "LAN "; + #endif + #if defined(LED_BLINKING) + features_str += "Blink "; + #endif + #if defined(SERIAL_PRINTING) + features_str += "Serial "; + #endif + #if defined(WEB_DASHBOARD) + features_str += "Webserver "; + #endif + #if defined(DISPLAY_16X2) + features_str += "LCD16X2 "; + #endif + #if defined(DISPLAY_SSD1306) + features_str += "SSD1306 "; + #endif + #if defined(USE_INTERNAL_SENSOR) + features_str += "Int. sensor "; + #endif + #if defined(USE_DS18B20) + features_str += "DS18B20 "; + #endif + #if defined(USE_DHT) + features_str += "DHT "; + #endif + drawStrMultiline(features_str.c_str(), 2, 46); + u8g2.sendBuffer(); + #endif + } + void display_info(String message) { // Abstraction layer: info screens (setups) @@ -157,11 +277,13 @@ lcd.write(1); // checkmark lcd.print(accepted_shares); - lcd.setCursor(6, 1); + lcd.print(" "); + //lcd.setCursor(6, 1); lcd.print(ping); lcd.print("ms"); - lcd.setCursor(12, 1); + lcd.print(" "); + //lcd.setCursor(12, 1); lcd.print(sharerate); lcd.print("s"); #endif From 4e33fcd1b13429d5d834488bc7e74ad66bb59447 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:27:03 +0200 Subject: [PATCH 21/52] Brownout detector switch --- ESP_Code/Settings.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index b8e183fe..bb42f02e 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -34,8 +34,15 @@ extern const char PASSWORD[] = "PASSW0RD"; // ESP8266 WDT loop watchdog. Do not edit this value, but if you must - do not set it too low or it will falsely trigger during mining! #define LWD_TIMEOUT 30000 +// Uncomment to disable ESP32 brownout detector if you're suffering from faulty insufficient power detection +// #define DISABLE_BROWNOUT + +// -------------------------------------------------------------- // + +// ------------------------ Displays ---------------------------- // + // Uncomment to enable a SSD1306 OLED screen on the I2C bus to display mining info in real time -// Default connections (can be overriden by using a different u8g2 initializer, see line 122): +// Default connections (can be overriden by using a different u8g2 initializer, see line 132): // GND - GND // VCC - 5V or 3.3V depending on display // SCL - GPIO22 (ESP32) or GPIO5 (D2 on ESP8266) or GPIO35 (ESP32-S2) @@ -43,7 +50,7 @@ extern const char PASSWORD[] = "PASSW0RD"; // #define DISPLAY_SSD1306 // Uncomment to enable a 16x2 LCD screen on a direct bus to display mining info in real time -// See line 132 for connections and initializer +// See line 142 for connections and initializer // #define DISPLAY_16X2 // -------------------------------------------------------------- // From 08d3a7d809aa8945dddfc9b90c022ab3d615f83f Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:27:22 +0200 Subject: [PATCH 22/52] More ESP32 improvements --- ESP_Code/MiningJob.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index 74186932..33c8a0b1 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -91,16 +91,18 @@ class MiningJob { } void handleSystemEvents(void) { - ArduinoOTA.handle(); - yield(); - vTaskDelay(10); + #if defined(ESP32) && CORE == 2 + esp_task_wdt_reset(); + #endif delay(10); // Required vTaskDelay by ESP-IDF + yield(); + ArduinoOTA.handle(); } void mine() { connectToNode(); askForJob(); - + dsha1->reset().write((const unsigned char *)getLastBlockHash().c_str(), getLastBlockHash().length()); int start_time = micros(); @@ -113,7 +115,7 @@ class MiningJob { ctx.write((const unsigned char *)counter.c_str(), counter.strlen()).finalize(hashArray); #ifndef CONFIG_FREERTOS_UNICORE - if (max_micros_elapsed(micros(), 500000)) { + if (max_micros_elapsed(micros(), 100000)) { // 10ms handleSystemEvents(); } #endif @@ -209,7 +211,10 @@ class MiningJob { Serial.println("Core [" + String(core) + "] - Connecting to a Duino-Coin node..."); #endif while (!client.connect(config->host.c_str(), config->port)) { - if (millis()-stopWatch>100000) ESP.restart(); + if (max_micros_elapsed(micros(), 100000)) { + handleSystemEvents(); + } + if (millis()-stopWatch>100000) ESP.restart(); } waitForClientData(); From d7355460e956be907962c5efca04657174d3031d Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:27:58 +0200 Subject: [PATCH 23/52] Boot screen, watchdog & more improvements --- ESP_Code/ESP_Code.ino | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index fdc7373e..b5db4c5e 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -63,6 +63,11 @@ #include "DisplayHal.h" #endif +#if defined(DISABLE_BROWNOUT) + #include "soc/soc.h" + #include "soc/rtc_cntl_reg.h" +#endif + // Auto adjust physical core count // (ESP32-S2/C3 have 1 core, ESP32 has 2 cores, ESP8266 has 1 core) #if defined(ESP8266) @@ -74,6 +79,11 @@ #define CORE 2 // Install TridentTD_EasyFreeRTOS32 if you get an error #include + + void Task1Code( void * parameter ); + void Task2Code( void * parameter ); + TaskHandle_t Task1; + TaskHandle_t Task2; #endif #if defined(WEB_DASHBOARD) @@ -115,6 +125,10 @@ void RestartESP(String msg) { lwdCurrentMillis = millis(); lwdTimeOutMillis = lwdCurrentMillis + LWD_TIMEOUT; } +#else + void lwdtFeed(void) { + Serial.println("lwdtFeed()"); + } #endif namespace { @@ -155,6 +169,7 @@ namespace { String payload = ""; WiFiClientSecure client; client.setInsecure(); + client.setTimeout(8000); HTTPClient http; http.setReuse(false); @@ -457,7 +472,9 @@ void task2_func(void *) { } void setup() { - delay(500); + #if defined(DISABLE_BROWNOUT) + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); + #endif #if defined(SERIAL_PRINTING) Serial.begin(SERIAL_BAUDRATE); @@ -467,8 +484,8 @@ void setup() { #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) screen_setup(); - display_info("Welcome back!"); - delay(500); + display_boot(); + delay(2500); #endif assert(CORE == 1 || CORE == 2); @@ -563,27 +580,25 @@ void setup() { mutexConnectToServer = xSemaphoreCreateMutex(); xTaskCreatePinnedToCore(system_events_func, "system_events_func", 10000, NULL, 1, NULL, 0); - xTaskCreatePinnedToCore(task1_func, "task1_func", 10000, NULL, 1, NULL, 0); - xTaskCreatePinnedToCore(task2_func, "task2_func", 10000, NULL, 2, NULL, 1); + xTaskCreatePinnedToCore(task1_func, "task1_func", 10000, NULL, 1, &Task1, 0); + xTaskCreatePinnedToCore(task2_func, "task2_func", 10000, NULL, 1, &Task2, 1); #endif } void system_events_func(void* parameter) { while (true) { + delay(10); #if defined(WEB_DASHBOARD) server.handleClient(); #endif ArduinoOTA.handle(); - delay(10); } } void single_core_loop() { job[0]->mine(); - #if defined(ESP8266) - lwdtFeed(); - #endif + lwdtFeed(); #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) float hashrate_float = (hashrate+hashrate_core_two) / 1000.0; @@ -613,4 +628,5 @@ void loop() { #if defined(ESP8266) || defined(CONFIG_FREERTOS_UNICORE) single_core_loop(); #endif + delay(10); } From f82705ac269066313a6209e02e2ead4430ff8d9d Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Thu, 25 Jul 2024 20:11:28 +0200 Subject: [PATCH 24/52] Separate 32 and 8266 system timeouts --- ESP_Code/MiningJob.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index 33c8a0b1..9d66f34e 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -115,7 +115,12 @@ class MiningJob { ctx.write((const unsigned char *)counter.c_str(), counter.strlen()).finalize(hashArray); #ifndef CONFIG_FREERTOS_UNICORE - if (max_micros_elapsed(micros(), 100000)) { // 10ms + #if defined(ESP32) + #define SYSTEM_TIMEOUT 100000 // 10ms for esp32 looks like the lowest value without false watchdog triggers + #else + #define SYSTEM_TIMEOUT 500000 // 50ms for 8266 for same reason as above + #endif + if (max_micros_elapsed(micros(), SYSTEM_TIMEOUT)) { handleSystemEvents(); } #endif From 31c2da529b74a24a0936d90981fd6b59cc1561ac Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Thu, 25 Jul 2024 23:05:45 +0200 Subject: [PATCH 25/52] 16x2 LCD updates --- ESP_Code/DisplayHal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index a8fdf72a..c65891ad 100644 --- a/ESP_Code/DisplayHal.h +++ b/ESP_Code/DisplayHal.h @@ -18,6 +18,7 @@ static byte duco_logo[] = {0x1E, 0x01, 0x1D, 0x05, 0x1D, 0x01, 0x1E, 0x00}; static byte check_mark[] = {0x00, 0x00, 0x00, 0x01, 0x02,0x14, 0x08, 0x00}; static byte kh[] = {0x08, 0x0A, 0x0C, 0x0A, 0x00, 0x0A, 0x0E, 0x0A}; + static byte msec[] = {0x0A, 0x15, 0x11, 0x06, 0x08, 0x04, 0x02, 0x0C}; #endif #if defined(DISPLAY_SSD1306) @@ -73,6 +74,7 @@ lcd.createChar(0, duco_logo); lcd.createChar(1, check_mark); lcd.createChar(2, kh); + lcd.createChar(3, msec); lcd.home(); lcd.clear(); #endif @@ -87,7 +89,7 @@ #if defined(ESP8266) lcd.print("ESP8266 "); #elif defined(CONFIG_FREERTOS_UNICORE) - lcd.print("ESP32S2/C3 "); + lcd.print("ESP32S2 "); #else lcd.print("ESP32 "); #endif @@ -277,13 +279,11 @@ lcd.write(1); // checkmark lcd.print(accepted_shares); - lcd.print(" "); - //lcd.setCursor(6, 1); + lcd.setCursor(7, 1); lcd.print(ping); - lcd.print("ms"); + lcd.write(3); // ms - lcd.print(" "); - //lcd.setCursor(12, 1); + lcd.setCursor(12, 1); lcd.print(sharerate); lcd.print("s"); #endif From 02be56e424c1a9c20a7c7e23c8f88b683116f980 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:40:31 +0200 Subject: [PATCH 26/52] HSU07M support and cleanups --- ESP_Code/Settings.h | 47 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index bb42f02e..be5f9936 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -14,17 +14,19 @@ extern const char RIG_IDENTIFIER[] = "None"; extern const char SSID[] = "SSID"; // Change the part in brackets to your WiFi password extern const char PASSWORD[] = "PASSW0RD"; +// -------------------------------------------------------------- // +// -------------------- Advanced options ------------------------ // // Uncomment if you want to host the dashboard page (available on ESPs IP address) // #define WEB_DASHBOARD +// Comment out the line below if you wish to disable LED blinking +#define LED_BLINKING + // Uncomment if you want to use LAN8720. WLAN-credentials will be ignored using LAN // Select correct Board in ArduinoIDE!!! Really! // #define USE_LAN -// Comment out the line below if you wish to disable LED blinking -#define LED_BLINKING - // Comment out the line below if you wish to disable Serial printing #define SERIAL_PRINTING @@ -36,13 +38,12 @@ extern const char PASSWORD[] = "PASSW0RD"; // Uncomment to disable ESP32 brownout detector if you're suffering from faulty insufficient power detection // #define DISABLE_BROWNOUT - // -------------------------------------------------------------- // // ------------------------ Displays ---------------------------- // // Uncomment to enable a SSD1306 OLED screen on the I2C bus to display mining info in real time -// Default connections (can be overriden by using a different u8g2 initializer, see line 132): +// Default connections (can be overriden by using a different u8g2 initializer, see line 140): // GND - GND // VCC - 5V or 3.3V depending on display // SCL - GPIO22 (ESP32) or GPIO5 (D2 on ESP8266) or GPIO35 (ESP32-S2) @@ -50,9 +51,8 @@ extern const char PASSWORD[] = "PASSW0RD"; // #define DISPLAY_SSD1306 // Uncomment to enable a 16x2 LCD screen on a direct bus to display mining info in real time -// See line 142 for connections and initializer -// #define DISPLAY_16X2 - +// See line 150 for connections and initializer +// define DISPLAY_16X2 // -------------------------------------------------------------- // // ---------------------- IoT examples -------------------------- // @@ -69,10 +69,18 @@ extern const char PASSWORD[] = "PASSW0RD"; // #define USE_DS18B20 // Uncomment the line below if you wish to use a DHT11/22 temperature and humidity sensor (Duino IoT example) -// NOTE: Untested as of right now +// NOTE: Mining performance should stay the same // #define USE_DHT + +// Uncomment the line below if you wish to use a HSU07M sensor (Duino IoT Example) +// NOTE: Untested as of right now +// #define USE_HSU07M // -------------------------------------------------------------- // +// ---------------- Variables and definitions ------------------- // +// You generally do not need to edit stuff below this line +// unless you're know what you're doing. + #if defined(ESP8266) // ESP8266 #define LED_BUILTIN 2 @@ -142,4 +150,25 @@ extern unsigned int ping = 0; Adafruit_LiquidCrystal lcd(1, 2, 3, 4, 5, 6); #endif +#if defined(USE_HSU07M) + #include "Wire.h" + #define HSU07M_ADDRESS 0x4B // Change this if your sensor has a different address + + float read_hsu07m() { + Wire.beginTransmission(HSU07M_ADDRESS); + Wire.write(0x00); + Wire.endTransmission(); + delay(100); + Wire.requestFrom(HSU07M_ADDRESS, 2); + if(Wire.available() >= 2) { + byte tempMSB = Wire.read(); + byte tempLSB = Wire.read(); + int tempRaw = (tempMSB << 8) | tempLSB; + float tempC = (tempRaw / 16.0) - 40.0; + return tempC; + } + return -1.0; + } +#endif + #endif // End of SETTINGS_H From bc67c7a7f93e40fa5ac053ac8da9c94872f7a056 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:40:50 +0200 Subject: [PATCH 27/52] HSU07M support --- ESP_Code/MiningJob.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index 9d66f34e..2386afcf 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -339,6 +339,18 @@ class MiningJob { SEP_TOKEN + "Temp:" + String(temp) + "*C" + IOT_TOKEN + "Hum:" + String(hum) + "%" + END_TOKEN); + #elif defined(USE_HSU07M) + float temp = read_hsu07m(); + #if defined(SERIAL_PRINTING) + Serial.println("HSU reading: " + String(temp) + "°C"); + #endif + + client.print("JOB," + + String(config->DUCO_USER) + + SEP_TOKEN + config->START_DIFF + + SEP_TOKEN + String(config->MINER_KEY) + + SEP_TOKEN + "Temp:" + String(temp) + "*C" + + END_TOKEN); #elif defined(USE_INTERNAL_SENSOR) float temp = 0; temp_sensor_read_celsius(&temp); From 420280427e228ffb81ef5cc4412fe15e13cc9206 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:41:07 +0200 Subject: [PATCH 28/52] HSU07M support --- ESP_Code/DisplayHal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index c65891ad..dfde2490 100644 --- a/ESP_Code/DisplayHal.h +++ b/ESP_Code/DisplayHal.h @@ -161,6 +161,9 @@ #if defined(USE_DHT) features_str += "DHT "; #endif + #if defined(USE_HSU07M) + features_str += "HSU07M "; + #endif drawStrMultiline(features_str.c_str(), 2, 46); u8g2.sendBuffer(); #endif From 92472525ba31f5ce0d5a7e891cd98eba354b9751 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:41:49 +0200 Subject: [PATCH 29/52] Brownout clause and HSU07M support --- ESP_Code/ESP_Code.ino | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index b5db4c5e..6d249437 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -63,7 +63,7 @@ #include "DisplayHal.h" #endif -#if defined(DISABLE_BROWNOUT) +#if !defined(ESP8266) && defined(DISABLE_BROWNOUT) #include "soc/soc.h" #include "soc/rtc_cntl_reg.h" #endif @@ -472,7 +472,7 @@ void task2_func(void *) { } void setup() { - #if defined(DISABLE_BROWNOUT) + #if !defined(ESP8266) && defined(DISABLE_BROWNOUT) WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); #endif @@ -514,6 +514,13 @@ void setup() { #endif #endif + #if defined(USE_HSU07M) + #if defined(SERIAL_PRINTING) + Serial.println("Initializing HSU07M sensor (Duino IoT)"); + Serial.println("Test reading: " + String(read_hsu07m()) + "°C"); + #endif + #endif + #if defined(USE_INTERNAL_SENSOR) #if defined(SERIAL_PRINTING) Serial.println("Initializing internal ESP32 temperature sensor (Duino IoT)"); From c545d20f6aadeb89eb18d4cd45787a2b250e2d62 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:56:23 +0200 Subject: [PATCH 30/52] Do not display title errors without debug --- PC_Miner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PC_Miner.py b/PC_Miner.py index c7557fc1..d9ab104d 100644 --- a/PC_Miner.py +++ b/PC_Miner.py @@ -198,7 +198,7 @@ def title(title: str): print('\33]0;' + title + '\a', end='') sys.stdout.flush() except Exception as e: - print(e) + debug_output("Error setting title: " +str(e)) def check_updates(): From 44b856fabd0a3669e26c33f35f8121a6c2647043 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:56:36 +0200 Subject: [PATCH 31/52] Do not display title errors without debug --- AVR_Miner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AVR_Miner.py b/AVR_Miner.py index 8309d694..a88e75a4 100644 --- a/AVR_Miner.py +++ b/AVR_Miner.py @@ -601,7 +601,7 @@ def title(title: str): print('\33]0;' + title + '\a', end='') sys.stdout.flush() except Exception as e: - print(e) + debug_output("Error setting title: " +str(e)) def handler(signal_received, frame): From d6d4840c7542eb5dc330e240c1647ef8a9a9ce83 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:01:42 +0200 Subject: [PATCH 32/52] Adjusted mining key string --- Resources/PC_Miner_langs.json | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Resources/PC_Miner_langs.json b/Resources/PC_Miner_langs.json index da89d32e..63e225f1 100644 --- a/Resources/PC_Miner_langs.json +++ b/Resources/PC_Miner_langs.json @@ -92,7 +92,7 @@ "connecting_node": " Retrieved mining node: ", "new_version": "A new version is available, do you want to update the miner (Y/n) ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!", "running_on_rpi": "The miner seems to be running on a Raspberry Pi.", @@ -203,7 +203,7 @@ "connecting_node": " mining node yang dipakai: ", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -294,7 +294,7 @@ "total_mining_time": "\n\t\t‖ 총 채굴 기간: ", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -385,7 +385,7 @@ "total_mining_time": "\n\t\t‖ تمام وقت کارکرد: ", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -476,7 +476,7 @@ "total_mining_time": "\n\t\t‖ Celková doba prevádzky: ", "new_version": "K dispozícii je nová verzia, chcete aktualizovať miner [A/n] ? ", "updating": "Miner je zastaraný. Aktualizujem....", - "ask_mining_key": "Zadajte svoj ťažobný kľúč (povinné iba vtedy, ak ste túto možnosť aktivovali vo webovej peňaženke - preskočíte stlačením Enter): ", + "ask_mining_key": "Zadajte svoj ťažobný kľúč: ", "mining_key_required": "Na ťažbu na tomto účte je potrebný ťažobný kľúč", "invalid_mining_key": "Zadaný ťažobný kľúč je neplatný!" }, @@ -550,7 +550,7 @@ "recommended": "raccomandato", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -647,7 +647,7 @@ "connecting_node": " Wybrano najszybszy serwer: ", "new_version": "Znalezino nową wersję, chcesz zaktualizować koparkę? [Y/n] ? ", "updating": "Koparka jest nieaktualna, aktualizacja w trakcie....", - "ask_mining_key": "Wprowadź swoje hasło do kopania (mining key) (tylko jeżeli ustawiłeś je w portfelu internetowym - w przeciwnym razie wciśnij enter aby pominąć): ", + "ask_mining_key": "Wprowadź swoje hasło do kopania (mining key): ", "mining_key_required": "Hasło do kopania jest wymagane do kopania na tym koncie", "invalid_mining_key": "Podane hasło do kopania jest nieprawidłowe!", "incorrect_username": "Podana nazwa użytkownika nie istnieje!", @@ -727,7 +727,7 @@ "mining_not_exist_warning": " Asegurate de haber ingresado el nombre de usuario correcto. Revisa el archivo de configuraciones. Reintentando en 10s", "new_version": "Hay una nueva version del minero, Quieres actualizarlo? [Y/n] ? ", "updating": "El minero esta desactualizado. Actualizando....", - "ask_mining_key": "Ingresa tu llave de minado (Solo es necesario si lo activaste en la web-wallet - presiona enter para saltar): ", + "ask_mining_key": "Ingresa tu llave de minado: ", "mining_key_required": "Una llave de minado es necesaria para minar con esta cuenta", "invalid_mining_key": "La llave de minado ingresada no es válida!" }, @@ -820,7 +820,7 @@ "connecting_node": " Node de minage récupéré : ", "new_version": "Une nouvelle version est disponible, voulez vous faire la mise à jour [Y/n] ? ", "updating": "Le mineur est obsolète. Mise a jour...", - "ask_mining_key": "Entrez votre clé de minage (mining key) - (Cela est seulement nécessaire si vous avez activé cette option dans le webwallet) : ", + "ask_mining_key": "Entrez votre clé de minage: ", "mining_key_required": "Une clé de minage (mining key) est nécessaire pour miner sur ce compte", "invalid_mining_key": "La clé de minage fournie est invalide !" }, @@ -890,7 +890,7 @@ "mining_not_exist_warning": " Убедитесь в том, что вы правильно ввели имя пользователя. Пожалуйста, проверьте ваш файл настроек. Пробуем еще раз через 10с", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -986,7 +986,7 @@ "connecting_node": " Отриманий вузол майнінгу: ", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -1083,7 +1083,7 @@ "connection_search": "Suche nach der schnellsten Verbindung zu dem Server", "new_version": "Eine neue Version ist verfügbar, möchtest du den Miner updaten [Y/n] ?", "updating": "Der Miner ist nicht aktuell. Aktualisierung....", - "ask_mining_key": "Mining-Key eingeben (nur notwendig, wenn du diese Option in deinem Webwallet aktiviert hast - drücke Enter zum überspringen): ", + "ask_mining_key": "Mining-Key eingeben: ", "mining_key_required": "Es wird ein Mining-Key benötigt, um an diesem Account zu minen", "invalid_mining_key": "Der eingegebene Mining-Key ist ungültig!", "running_on_rpi": "Der Schürfklient scheint auf einem Raspberry Pi zu laufen.", @@ -1163,7 +1163,7 @@ "mining_not_exist_warning": " 确保您正确输入了用户名。请检查您的配置文件。 将在10秒内重试", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -1234,7 +1234,7 @@ "mining_not_exist_warning": " 請確認您正確輸入了帳號名稱。請檢查您的設定檔。將在10秒後重試。", "new_version": "線上有新版本可更新,您想更新挖礦程式嗎? [Y/n] ? ", "updating": "挖礦軟體過舊。正在更新中.....", - "ask_mining_key": "請輸入您的挖礦密碼 (只有在您的網絡錢包中啟用此選項時才需要設定 - 按 Enter 鍵跳過): ", + "ask_mining_key": "請輸入您的挖礦密碼: ", "mining_key_required": "此帳號挖礦需要挖礦密碼", "invalid_mining_key": "您提供的挖礦密碼無效!" }, @@ -1306,7 +1306,7 @@ "connection_search": "Sunuculara bağlanmak için en hızlı bağlantı aranıyor", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -1396,7 +1396,7 @@ "total_mining_time": "\n\t\t‖ Tempo de atividade total do minerador: ", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -1462,7 +1462,7 @@ "load_config_error_warning": "/Miner_config.cfg). Ipprova neħħih u erġa 'ibda l-iskavatur. Agħlaq f'10 sekondi", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -1553,7 +1553,7 @@ "total_mining_time": "\n\t\t‖ เวลาที่ตัวขุดทำงานทั้งหมด: ", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -1649,7 +1649,7 @@ "connecting_node": " पुनर्प्राप्त खनन नोड: ", "new_version": "A new version is available, you want to update miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!" }, @@ -1745,7 +1745,7 @@ "connecting_node": " Získaný těžební uzel: ", "new_version": "Je dostupná nová verze. Chceš aktualizovat těžební program [Y/n] ? ", "updating": "Těžební program je zastaralý. Aktualizuji....", - "ask_mining_key": "Zadej svůj těžební klíč (požadováno v případech, kdy tato možnost byla nastavena ve webové peněžence - stiskni enter pro přeskočení): ", + "ask_mining_key": "Zadej svůj těžební klíč: ", "mining_key_required": "Těžební klíč je nutný pro těžbu na tomto účtu", "invalid_mining_key": "Zadaný těžební klíč je neplatný!", "running_on_rpi": "Vypadá to, že tento těžební program jede na Raspberry Pi.", @@ -1856,7 +1856,7 @@ "connecting_node": " 取得したマイニングノード: ", "new_version": "新しいバージョンが利用可能です、マイナーをアップデートしますか(Y/n) ? ", "updating": "マイナーが古くなっています。アップデート中....", - "ask_mining_key": "マイニングキーを入力してください(webwalletでこのオプションを有効にした場合のみ必要です - Enterを押すとスキップします): ", + "ask_mining_key": "マイニングキーを入力してください: ", "mining_key_required": "このアカウントでマイニングを行うには、マイニングキーが必要です", "invalid_mining_key": "入力されたマイニングキーは無効です!", "running_on_rpi": "マイナーはRaspberry Piで動作しているようです。", @@ -1961,7 +1961,7 @@ "connecting_node": " Haettu louhintanode: ", "new_version": "Uusi versio on saatavilla, haluatko päivittää louhijan (Y/n) ? ", "updating": "Louhija on vanhentunut. Päivitetään....", - "ask_mining_key": "Syötä louhintatunnuksesi (vain tarpeen, jos aktivoit tämän vaihtoehdon web-lompakossa - paina enter ohittaaksesi): ", + "ask_mining_key": "Syötä louhintatunnuksesi: ", "mining_key_required": "Louhintatunnus vaaditaan tälle tilille louhimiseen", "invalid_mining_key": "Antamasi louhintatunnus on virheellinen!", "running_on_rpi": "Louhija näyttää toimivan Raspberry Pi:llä.", From 9ea9efd5355dbe179b282dd5b3d14be51aa87969 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:05:36 +0200 Subject: [PATCH 33/52] Only check for mining key if enabled --- PC_Miner.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/PC_Miner.py b/PC_Miner.py index d9ab104d..048bbf24 100644 --- a/PC_Miner.py +++ b/PC_Miner.py @@ -712,6 +712,15 @@ def get_string(string_name): return string_name +def has_mining_key(username): + response = requests.get( + "https://server.duinocoin.com/mining_key" + + "?u=" + user_settings["username"] + timeout=10 + ).json() + return response["has_key"] + + def check_mining_key(user_settings): if user_settings["mining_key"] != "None": key = '&k=' + urllib.parse.quote(b64.b64decode(user_settings["mining_key"]).decode('utf-8')) @@ -948,10 +957,11 @@ def load_cfg(): if not correct_username: print(get_string("incorrect_username")) - mining_key = input(Style.RESET_ALL + get_string("ask_mining_key") + Style.BRIGHT) - if not mining_key: - mining_key = "None" - else: + mining_key = "None" + if has_mining_key(username): + mining_key = input(Style.RESET_ALL + + get_string("ask_mining_key") + + Style.BRIGHT) mining_key = b64.b64encode(mining_key.encode("utf-8")).decode('utf-8') algorithm = "DUCO-S1" From 83af4a23090448d840ac3495e28b42fccbe45727 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:05:50 +0200 Subject: [PATCH 34/52] Only check for mining key if enabled --- AVR_Miner.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/AVR_Miner.py b/AVR_Miner.py index a88e75a4..a434e623 100644 --- a/AVR_Miner.py +++ b/AVR_Miner.py @@ -266,6 +266,16 @@ def check_updates(): print(e) sys.exit() + +def has_mining_key(username): + response = requests.get( + "https://server.duinocoin.com/mining_key" + + "?u=" + user_settings["username"] + timeout=10 + ).json() + return response["has_key"] + + def check_mining_key(user_settings): user_settings = user_settings["AVR Miner"] @@ -653,13 +663,8 @@ def load_config(): if not correct_username: print(get_string("incorrect_username")) - response = requests.get( - "https://server.duinocoin.com/mining_key" - + "?u=" + username, timeout=10 - ).json() - mining_key = "None" - if response["has_key"]: + if has_mining_key(username): mining_key = input(Style.RESET_ALL + Fore.YELLOW + get_string("ask_mining_key") + Fore.RESET + Style.BRIGHT) From 7df09fc0313de6dfe8ea37cd2b78e4bf88af5f6a Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:08:53 +0200 Subject: [PATCH 35/52] Adjusted mining key string --- Resources/AVR_Miner_langs.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Resources/AVR_Miner_langs.json b/Resources/AVR_Miner_langs.json index 6b9103a1..c7fd5c43 100644 --- a/Resources/AVR_Miner_langs.json +++ b/Resources/AVR_Miner_langs.json @@ -83,7 +83,7 @@ "connecting_node": " Retrieved mining node: ", "new_version": "A new version is available, do you want to update the miner [Y/n] ? ", "updating": "The miner is outdated. Updating....", - "ask_mining_key": "Enter your mining key (only required if you activated this option in the webwallet - press enter to skip): ", + "ask_mining_key": "Enter your mining key: ", "mining_key_required": "Mining key is required to mine on this account", "invalid_mining_key": "The mining key you provided is invalid!", "incorrect_username": "The username you provided doesn't exist!", @@ -267,7 +267,7 @@ "connecting_node": " Získaný těžební uzel: ", "new_version": "Je dostupná nová verze programu. Chceš ho hned teď aktualizovat [Y/n] ? ", "updating": "Těžící program je zastaralý. Instaluji aktualizaci....", - "ask_mining_key": "Zadej svůj těžební klíč (jen pokud sis ho dříve nastavil ve webové peněžence - stiskni enter k přeskočení): ", + "ask_mining_key": "Zadej svůj těžební klíč: ", "mining_key_required": "Těžební klíč je nutný pro těžbu na tomto účtě", "invalid_mining_key": "Zadaný těžební klíč není správný", "incorrect_username": "Zadané uživatelské jméno neexistuje", @@ -443,7 +443,7 @@ "total_mining_time": "\n\t\t‖ Koparka działa przez: ", "new_version": "Znalezino nową wersję, chcesz zaktualizować koparkę? [Y/n] ? ", "updating": "Koparka jest nieaktualna, aktualizacja w trakcie....", - "ask_mining_key": "Wprowadź swoje hasło do kopania (mining key) (tylko jeżeli ustawiłeś je w portfelu internetowym - w przeciwnym razie wciśnij enter aby pominąć): ", + "ask_mining_key": "Wprowadź swoje hasło do kopania (mining key): ", "mining_key_required": "Hasło do kopania jest wymagane do kopania na tym koncie", "invalid_mining_key": "Podane hasło do kopania jest nieprawidłowe!", "incorrect_username": "Podana nazwa użytkownika nie istnieje!", @@ -672,7 +672,7 @@ "connecting_node": " Abgerufener Mining Knoten: ", "new_version": "Eine neue Version ist verfügbar. Möchtest du den Miner aktualisieren [Y/n]? ", "updating": "Der Miner ist veraltet. Aktualisiere....", - "ask_mining_key": "Gib deinen Miningschlüssel an (nur nötig, wenn du diese Option im Webwallet aktiviert hast - Drück die Eingabetaste um zu überspringen): ", + "ask_mining_key": "Gib deinen Miningschlüssel an: ", "mining_key_required": "Ein Miningschlüssel ist erforderlich um auf diesem Konto zu schürfen", "invalid_mining_key": "Der angegebene Miningschlüssel ist inkorrekt!", "incorrect_username": "Der angegebene Nutzername existiert nicht!", @@ -1428,7 +1428,7 @@ "connecting_node": " 取得したマイニングノード: ", "new_version": "新しいバージョンが利用可能です、マイナーをアップデートしますか[Y/n]? ", "updating": "マイナーが古くなっています。アップデート中....", - "ask_mining_key": "マイニングキーを入力してください(ウェブウォレットでこのオプションを有効にした場合のみ必要です - Enterを押すとスキップします): ", + "ask_mining_key": "マイニングキーを入力してください: ", "mining_key_required": "このアカウントでマイニングを行うには、マイニングキーが必要です", "invalid_mining_key": "入力されたマイニングキーは無効です!", "incorrect_username": "入力されたユーザーネームは存在しません!", @@ -1522,7 +1522,7 @@ "connecting_node": " Haettu louhintanode: ", "new_version": "Uusi versio on saatavilla, haluatko päivittää louhijan [Y/n] ? ", "updating": "Louhija on vanhentunut. Päivitetään....", - "ask_mining_key": "Anna louhintatunnus (vain tarvittaessa, jos olet aktivoinut tämän vaihtoehdon verkkolompakossa - paina Enter ohittaaksesi): ", + "ask_mining_key": "Anna louhintatunnus: ", "mining_key_required": "Louhintatunnus vaaditaan tälle tilille louhimiseen", "invalid_mining_key": "Annettu louhintatunnus on virheellinen!", "incorrect_username": "Annettu käyttäjätunnus ei ole olemassa!", From ef1ed86279271a168048348c67855df60547ec40 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:09:10 +0200 Subject: [PATCH 36/52] Typo --- PC_Miner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PC_Miner.py b/PC_Miner.py index 048bbf24..f2fffb39 100644 --- a/PC_Miner.py +++ b/PC_Miner.py @@ -715,7 +715,7 @@ def get_string(string_name): def has_mining_key(username): response = requests.get( "https://server.duinocoin.com/mining_key" - + "?u=" + user_settings["username"] + + "?u=" + username, timeout=10 ).json() return response["has_key"] From 0aa3f5b96025d4d03b58cfdb85a65e47e60979ea Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:09:19 +0200 Subject: [PATCH 37/52] Typo --- AVR_Miner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AVR_Miner.py b/AVR_Miner.py index a434e623..fab66ab4 100644 --- a/AVR_Miner.py +++ b/AVR_Miner.py @@ -270,7 +270,7 @@ def check_updates(): def has_mining_key(username): response = requests.get( "https://server.duinocoin.com/mining_key" - + "?u=" + user_settings["username"] + + "?u=" + username, timeout=10 ).json() return response["has_key"] From 4d1648be4bd15431cf74a05a2782d1f27204dde9 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:09:03 +0200 Subject: [PATCH 38/52] Captive portal and Blushybox support --- ESP_Code/ESP_Code.ino | 146 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 129 insertions(+), 17 deletions(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 6d249437..3c41636f 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -90,6 +90,48 @@ WebServer server(80); #endif +#if defined(CAPTIVE_PORTAL) + #include // This needs to be first, or it all crashes and burns... + #include + #include + char duco_username[40]; + char duco_password[40]; + char duco_rigid[24]; + WiFiManager wifiManager; + Preferences preferences; + WiFiManagerParameter custom_duco_username("duco_usr", "Duino-Coin username", duco_username, 40); + WiFiManagerParameter custom_duco_password("duco_pwd", "Duino-Coin mining key (if enabled in the wallet)", duco_password, 40); + WiFiManagerParameter custom_duco_rigid("duco_rig", "Custom miner identifier (optional)", duco_rigid, 24); + + void saveConfigCallback() { + preferences.begin("duino_config", false); + preferences.putString("duco_username", custom_duco_username.getValue()); + preferences.putString("duco_password", custom_duco_password.getValue()); + preferences.putString("duco_rigid", custom_duco_rigid.getValue()); + preferences.end(); + RestartESP("Settings saved"); + } + + void reset_settings() { + wifiManager.resetSettings(); + RestartESP("Manual settings reset"); + } + + void saveParamCallback(){ + Serial.println("[CALLBACK] saveParamCallback fired"); + Serial.println("PARAM customfieldid = " + getParam("customfieldid")); + } + + String getParam(String name){ + //read parameter from server, for customhmtl input + String value; + if(wifiManager.server->hasArg(name)) { + value = wifiManager.server->arg(name); + } + return value; + } +#endif + void RestartESP(String msg) { #if defined(SERIAL_PRINTING) Serial.println(msg); @@ -167,16 +209,15 @@ namespace { String httpGetString(String URL) { String payload = ""; - WiFiClientSecure client; - client.setInsecure(); - client.setTimeout(8000); + WiFiClientSecure *client = new WiFiClientSecure; + client->setInsecure(); + client->setTimeout(10000); HTTPClient http; - http.setReuse(false); - if (http.begin(client, URL)) { + if (http.begin(*client, URL)) { int httpCode = http.GET(); - if (httpCode == HTTP_CODE_OK) + if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) payload = http.getString(); else #if defined(SERIAL_PRINTING) @@ -188,6 +229,7 @@ namespace { http.end(); } + delete client; return payload; } @@ -289,14 +331,6 @@ namespace { WiFi.setSleep(false); #endif WiFi.begin(SSID, PASSWORD); - - // Set normal DNS servers - IPAddress primaryDNS(8, 8, 8, 8); - IPAddress secondaryDNS(1, 1, 1, 1); - - if (!WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), primaryDNS, secondaryDNS)) { - Serial.println("Failed to configure DNS"); - } int wait_passes = 0; while (WiFi.waitForConnectResult() != WL_CONNECTED) { @@ -314,6 +348,7 @@ namespace { Serial.println("\n\nSuccessfully connected to WiFi"); Serial.println("Local IP address: " + WiFi.localIP().toString()); Serial.println("Rig name: " + String(RIG_IDENTIFIER)); + Serial.println("DNS: " + WiFi.dnsIP().toString()); Serial.println(); #endif @@ -482,6 +517,25 @@ void setup() { #endif pinMode(LED_BUILTIN, OUTPUT); + #if defined(BLUSHYBOX) + analogWrite(LED_BUILTIN, 255); + for (int i = 255; i > 0; i--) { + analogWrite(LED_BUILTIN, i); + delay(1); + } + pinMode(GAUGE_PIN, OUTPUT); + + // Gauge up and down effect on startup + for (int i = GAUGE_MIN; i < GAUGE_MAX; i++) { + analogWrite(GAUGE_PIN, i); + delay(10); + } + for (int i = GAUGE_MAX; i > GAUGE_MIN; i--) { + analogWrite(GAUGE_PIN, i); + delay(10); + } + #endif + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) screen_setup(); display_boot(); @@ -536,10 +590,68 @@ void setup() { #endif #endif - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) - display_info("Waiting for WiFi..."); + #if defined(CAPTIVE_PORTAL) + preferences.begin("duino_config", false); + strcpy(duco_username, preferences.getString("duco_username", "").c_str()); + strcpy(duco_password, preferences.getString("duco_password", "").c_str()); + strcpy(duco_rigid, preferences.getString("duco_rigid", "").c_str()); + preferences.end(); + DUCO_USER = duco_username; + RIG_IDENTIFIER = duco_rigid; + MINER_KEY = duco_password; + + String captivePortalHTML = R"( + Duino BlushyBox + + )"; + + wifiManager.setCustomHeadElement(captivePortalHTML.c_str()); + + wifiManager.setSaveConfigCallback(saveConfigCallback); + wifiManager.addParameter(&custom_duco_username); + wifiManager.addParameter(&custom_duco_password); + wifiManager.addParameter(&custom_duco_rigid); + + //blinker.attach_ms(200, changeState); + wifiManager.autoConnect("Duino-Coin"); + //blinker.detach(); + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + display_info("Waiting for node..."); + #endif + SelectNode(); + #else + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + display_info("Waiting for WiFi..."); + #endif + SetupWifi(); #endif - SetupWifi(); SetupOTA(); #if defined(WEB_DASHBOARD) From ff3c8fe609a4dc6ba63d82d0f4cf48da9704a83e Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:09:42 +0200 Subject: [PATCH 39/52] Blushybox support --- ESP_Code/MiningJob.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/ESP_Code/MiningJob.h b/ESP_Code/MiningJob.h index 2386afcf..7384735c 100644 --- a/ESP_Code/MiningJob.h +++ b/ESP_Code/MiningJob.h @@ -109,7 +109,7 @@ class MiningJob { max_micros_elapsed(start_time, 0); #if defined(LED_BLINKING) digitalWrite(LED_BUILTIN, LOW); - #endif + #endif for (Counter<10> counter; counter < difficulty; ++counter) { DSHA1 ctx = *dsha1; ctx.write((const unsigned char *)counter.c_str(), counter.strlen()).finalize(hashArray); @@ -131,7 +131,11 @@ class MiningJob { share_count++; #if defined(LED_BLINKING) - digitalWrite(LED_BUILTIN, HIGH); + #if defined(BLUSHYBOX) + analogWrite(LED_BUILTIN, 200); + #else + digitalWrite(LED_BUILTIN, HIGH); + #endif #endif if (String(core) == "0") { @@ -141,6 +145,10 @@ class MiningJob { hashrate_core_two = counter / elapsed_time_s; submit(counter, hashrate_core_two, elapsed_time_s); } + + #if defined(BLUSHYBOX) + gauge_set(hashrate + hashrate_core_two); + #endif break; } @@ -158,11 +166,19 @@ class MiningJob { String chipID = ""; #if defined(ESP8266) - String MINER_BANNER = "Official ESP8266 Miner"; + #if defined(BLUSHYBOX) + String MINER_BANNER = "Official BlushyBox Miner (ESP8266)"; + #else + String MINER_BANNER = "Official ESP8266 Miner"; + #endif #elif defined(CONFIG_FREERTOS_UNICORE) String MINER_BANNER = "Official ESP32-S2 Miner"; #else - String MINER_BANNER = "Official ESP32 Miner"; + #if defined(BLUSHYBOX) + String MINER_BANNER = "Official BlushyBox Miner (ESP32)"; + #else + String MINER_BANNER = "Official ESP32 Miner"; + #endif #endif uint8_t *hexStringToUint8Array(const String &hexString, uint8_t *uint8Array, const uint32_t arrayLength) { From e2562d741af59d40dfd15a150f23dc8d38667823 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:13:09 +0200 Subject: [PATCH 40/52] Captive portal and Blushybox support --- ESP_Code/Settings.h | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index be5f9936..6ae81dff 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -17,7 +17,7 @@ extern const char PASSWORD[] = "PASSW0RD"; // -------------------------------------------------------------- // // -------------------- Advanced options ------------------------ // -// Uncomment if you want to host the dashboard page (available on ESPs IP address) +// Uncomment if you want to host the dashboard page (available on ESPs IP address and mDNS) // #define WEB_DASHBOARD // Comment out the line below if you wish to disable LED blinking @@ -38,6 +38,10 @@ extern const char PASSWORD[] = "PASSW0RD"; // Uncomment to disable ESP32 brownout detector if you're suffering from faulty insufficient power detection // #define DISABLE_BROWNOUT + +// Uncomment to enable WiFiManager captive portal in AP mode +// The board will create its own network you connect to and change the settings +// #define CAPTIVE_PORTAL // -------------------------------------------------------------- // // ------------------------ Displays ---------------------------- // @@ -52,7 +56,10 @@ extern const char PASSWORD[] = "PASSW0RD"; // Uncomment to enable a 16x2 LCD screen on a direct bus to display mining info in real time // See line 150 for connections and initializer -// define DISPLAY_16X2 +// #define DISPLAY_16X2 + +// Uncomment if your device is a Duino BlushyBox device +// #define BLUSHYBOX // -------------------------------------------------------------- // // ---------------------- IoT examples -------------------------- // @@ -171,4 +178,36 @@ extern unsigned int ping = 0; } #endif +#if defined(BLUSHYBOX) + #define GAUGE_PIN 5 + #define GAUGE_MAX 190 + #define GAUGE_MIN 0 + #if defined(ESP8266) + #define GAUGE_MAX_HR 80000 + #else + #define GAUGE_MAX_HR 200000 + #endif + extern float hashrate_old = 0.0; + + void gauge_set(float hashrate) { + float old = hashrate_old; + float new_val = hashrate; + + if (hashrate_old == 0) { + float delta = (new_val - old) / 50; + for (int x=0; x < 50; x++) { + analogWrite(5, map(old + x*delta, 0, GAUGE_MAX_HR, GAUGE_MIN, GAUGE_MAX) + random(0, 10)); + delay(20); + } + } else { + float delta = (new_val - old) / 10; + for (int x=0; x < 10; x++) { + analogWrite(5, map(old + x*delta, 0, GAUGE_MAX_HR, GAUGE_MIN, GAUGE_MAX) + random(0, 10)); + delay(10); + } + } + hashrate_old = hashrate; + } +#endif + #endif // End of SETTINGS_H From 54f7318ac96b7c598e9b00c02d2fef148ba85a73 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:15:26 +0200 Subject: [PATCH 41/52] Fix char length assignment for captive portal --- ESP_Code/Settings.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index 6ae81dff..753013b7 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -4,12 +4,12 @@ // ---------------------- General settings ---------------------- // // Change the part in brackets to your Duino-Coin username -extern const char DUCO_USER[] = "my_cool_username"; +extern char *DUCO_USER = "my_cool_username"; // Change the part in brackets to your mining key (if you have set it in the wallet) -extern const char MINER_KEY[] = "mySecretPass"; +extern char *MINER_KEY = "mySecretPass"; // Change the part in brackets if you want to set a custom miner name // Use Auto to autogenerate, None for no custom identifier -extern const char RIG_IDENTIFIER[] = "None"; +extern char *RIG_IDENTIFIER = "None"; // Change the part in brackets to your WiFi name extern const char SSID[] = "SSID"; // Change the part in brackets to your WiFi password From e485a56d41af48cf0278b8a28ec1449ed43bf9e0 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 3 Aug 2024 15:04:48 +0200 Subject: [PATCH 42/52] Fixed settings not being saved and added a reset button --- ESP_Code/ESP_Code.ino | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 3c41636f..17b68dd9 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -113,6 +113,8 @@ } void reset_settings() { + server.send(200, "text/html", "Settings have been erased. Please redo the configuration by connecting to the WiFi network that will be created"); + delay(500); wifiManager.resetSettings(); RestartESP("Manual settings reset"); } @@ -438,6 +440,12 @@ namespace { s.replace("@@ID@@", String(RIG_IDENTIFIER)); s.replace("@@MEMORY@@", String(ESP.getFreeHeap())); s.replace("@@VERSION@@", String(SOFTWARE_VERSION)); + + #if defined(CAPTIVE_PORTAL) + s.replace("@@RESET_SETTINGS@@", "• Reset settings"); + #else + s.replace("@@RESET_SETTINGS@@", ""); + #endif server.send(200, "text/html", s); } #endif @@ -592,13 +600,13 @@ void setup() { #if defined(CAPTIVE_PORTAL) preferences.begin("duino_config", false); - strcpy(duco_username, preferences.getString("duco_username", "").c_str()); - strcpy(duco_password, preferences.getString("duco_password", "").c_str()); - strcpy(duco_rigid, preferences.getString("duco_rigid", "").c_str()); + strcpy(duco_username, preferences.getString("duco_username", "username").c_str()); + strcpy(duco_password, preferences.getString("duco_password", "None").c_str()); + strcpy(duco_rigid, preferences.getString("duco_rigid", "None").c_str()); preferences.end(); - DUCO_USER = duco_username; - RIG_IDENTIFIER = duco_rigid; - MINER_KEY = duco_password; + configuration->DUCO_USER = duco_username; + configuration->RIG_IDENTIFIER = duco_rigid; + configuration->MINER_KEY = duco_password; String captivePortalHTML = R"( Duino BlushyBox @@ -672,6 +680,7 @@ void setup() { #endif server.on("/", dashboard); + server.on("/reset", reset_settings); server.begin(); #endif From 0d19d984347fdce2c2cb93bf56c32ffc134d8d9a Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 3 Aug 2024 15:05:04 +0200 Subject: [PATCH 43/52] Reset settings button --- ESP_Code/Dashboard.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ESP_Code/Dashboard.h b/ESP_Code/Dashboard.h index f2349858..1e737174 100644 --- a/ESP_Code/Dashboard.h +++ b/ESP_Code/Dashboard.h @@ -131,6 +131,7 @@ const char WEBSITE[] PROGMEM = R"=====( github.com/revoxhere/duino-coin + @@RESET_SETTINGS@@ From 82ed1c0f5b7ace33d95e875f445995cbb8bd15c6 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 3 Aug 2024 17:42:36 +0200 Subject: [PATCH 44/52] Missing def --- ESP_Code/ESP_Code.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 17b68dd9..e8812e91 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -215,6 +215,7 @@ namespace { client->setInsecure(); client->setTimeout(10000); HTTPClient http; + http.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS); if (http.begin(*client, URL)) { int httpCode = http.GET(); @@ -680,7 +681,9 @@ void setup() { #endif server.on("/", dashboard); - server.on("/reset", reset_settings); + #if defined(CAPTIVE_PORTAL) + server.on("/reset", reset_settings); + #endif server.begin(); #endif From df2c9aed11305797886ec278cbbf1deb2aa5844e Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:22:38 +0200 Subject: [PATCH 45/52] DNS setting field --- ESP_Code/Settings.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index 753013b7..13bc34fc 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -210,4 +210,6 @@ extern unsigned int ping = 0; } #endif +IPAddress DNS_SERVER(1, 1, 1, 1); // Cloudflare DNS server + #endif // End of SETTINGS_H From cc56249e453c0ac3a4b536fafa2149ce9a66cec4 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:23:05 +0200 Subject: [PATCH 46/52] DNS change logic --- ESP_Code/ESP_Code.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index e8812e91..e0ba11cb 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -346,6 +346,7 @@ namespace { wait_passes = 0; } } + WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), DNS_SERVER); #if defined(SERIAL_PRINTING) Serial.println("\n\nSuccessfully connected to WiFi"); From 6350bb90dd714d92e93851b33e04e48d81f3a8ae Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:28:37 +0200 Subject: [PATCH 47/52] Better wifi connection wait --- ESP_Code/ESP_Code.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index e0ba11cb..437a7806 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -336,12 +336,13 @@ namespace { WiFi.begin(SSID, PASSWORD); int wait_passes = 0; - while (WiFi.waitForConnectResult() != WL_CONNECTED) { + while (WiFi.waitForConnectResult() != WL_CONNECTED || WiFi.localIP() == IPAddress(192, 168, 4, 2)) { delay(500); #if defined(SERIAL_PRINTING) Serial.print("."); #endif if (++wait_passes >= 10) { + WiFi.disconnect(); WiFi.begin(SSID, PASSWORD); wait_passes = 0; } From cbe1831e6c8f7a2169b89eaa494bfedb4c24c6d9 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sun, 4 Aug 2024 12:17:38 +0200 Subject: [PATCH 48/52] Add power usage column --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6646f694..a2cf0a5c 100644 --- a/README.md +++ b/README.md @@ -137,17 +137,17 @@ Server source code, documentation for API calls and official libraries for devel ## Version 4.0 reward goals Captured at normal multiplier (no weekend boost) -| Device | Hashrate | Threads | DUCO/day | -|-----------------------|---------------------|---------|----------| -| Arduino | 343 H/s | 1 | 12 | -| ESP32 | 170-180 kH/s | 2 | 10 | -| ESP32-S2/C3 | 85-96 kH/s | 1 | 8 | -| ESP8266 | 66 kH/s | 1 | 6 | -| Raspberry Pi 4 (LOW) | 1 MH/s (no fasthash)| 4 | 6-7 | -| Raspberry Pi 4 (MED) | 5.4 MH/s (fasthash) | 4 | 7-8 | -| Low power PCs | | 4 | 4-6 | -| Medium | | 4-8 | 6-10 | -| High end | | 8+ | 10-12 | +| Device | Hashrate | Threads | DUCO/day | Power usage | +|-----------------------|---------------------|---------|----------|-------------| +| Arduino | 343 H/s | 1 | 12 | <0.5 W +| ESP32 | 170-180 kH/s | 2 | 10 | 1.5-2 W +| ESP32-S2/C3 | 85-96 kH/s | 1 | 8 | 1-1.5 W +| ESP8266 | 66 kH/s | 1 | 6 | 1-1.5 W +| Raspberry Pi 4 (LOW) | 1 MH/s (no fasthash)| 4 | 6-7 | 6.5 W +| Raspberry Pi 4 (MED) | 5.4 MH/s (fasthash) | 4 | 7-8 | 6.5 W +| Low power PCs | | 4 | 4-6 | - +| Medium | | 4-8 | 6-10 | - +| High end | | 8+ | 10-12 | -
Other tested devices and their benchmarks From 99288fec07c5d992af658267246172ff435170d5 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Sun, 4 Aug 2024 15:13:31 +0200 Subject: [PATCH 49/52] DNS setting only for ESP32 for the time being --- ESP_Code/ESP_Code.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 437a7806..690f01f6 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -347,7 +347,9 @@ namespace { wait_passes = 0; } } - WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), DNS_SERVER); + #ifndef(ESP8266) + WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), DNS_SERVER); + #endif #if defined(SERIAL_PRINTING) Serial.println("\n\nSuccessfully connected to WiFi"); From add78ae746ae496f0d67d050a6ec0751ca6d2538 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:53:32 +0200 Subject: [PATCH 50/52] Version bump --- AVR_Miner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AVR_Miner.py b/AVR_Miner.py index fab66ab4..e242ce3b 100644 --- a/AVR_Miner.py +++ b/AVR_Miner.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Duino-Coin Official AVR Miner 4.1 © MIT licensed +Duino-Coin Official AVR Miner 4.2 © MIT licensed https://duinocoin.com https://github.com/revoxhere/duino-coin Duino-Coin Team & Community 2019-2024 @@ -109,7 +109,7 @@ def port_num(com): class Settings: - VER = '4.1' + VER = '4.2' SOC_TIMEOUT = 15 REPORT_TIME = 120 AVR_TIMEOUT = 10 From 374be4654a0672776a2621eeb92f1f18d7170d3b Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:53:53 +0200 Subject: [PATCH 51/52] Version bump --- Arduino_Code/Arduino_Code.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino_Code/Arduino_Code.ino b/Arduino_Code/Arduino_Code.ino index 697b56a0..1b6836ff 100644 --- a/Arduino_Code/Arduino_Code.ino +++ b/Arduino_Code/Arduino_Code.ino @@ -4,7 +4,7 @@ ( _ \( )( )(_ _)( \( )( _ )___ / __)( _ )(_ _)( \( ) )(_) ))(__)( _)(_ ) ( )(_)((___)( (__ )(_)( _)(_ ) ( (____/(______)(____)(_)\_)(_____) \___)(_____)(____)(_)\_) - Official code for Arduino boards (and relatives) version 4.1 + Official code for Arduino boards (and relatives) version 4.2 Duino-Coin Team & Community 2019-2024 © MIT Licensed https://duinocoin.com From 2b2815ad4d438f96a22f1d0b4f3ae9344b4c11e5 Mon Sep 17 00:00:00 2001 From: revoxhere <50244265+revoxhere@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:54:11 +0200 Subject: [PATCH 52/52] Version bump --- PC_Miner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PC_Miner.py b/PC_Miner.py index f2fffb39..2d728844 100644 --- a/PC_Miner.py +++ b/PC_Miner.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Duino-Coin Official PC Miner 4.1 © MIT licensed +Duino-Coin Official PC Miner 4.2 © MIT licensed https://duinocoin.com https://github.com/revoxhere/duino-coin Duino-Coin Team & Community 2019-2024 @@ -142,7 +142,7 @@ class Settings: """ ENCODING = "UTF8" SEPARATOR = "," - VER = 4.1 + VER = 4.2 DATA_DIR = "Duino-Coin PC Miner " + str(VER) TRANSLATIONS = ("https://raw.githubusercontent.com/" + "revoxhere/"