Skip to content

Commit

Permalink
Merge pull request #137 from BitMaker-hub/dev
Browse files Browse the repository at this point in the history
Release 1.6.1

¡We are supporting ESP32-WROOM boards!

Use this code on cheapest hardware possible. Run up to 50Khs on a single ESP32.

Added best difficulty share to screen. (@golden-guy)
Improved watchdog functions (@golden-guy)
Added a pool connectivity delay to reduce overload connection at pool (@BitMaker-hub)
Added new sha version up to 56Khs on TTGO T-DISPLAY s3 (@BitMaker-hub)
Added support for ESP32-WROOM devices (@BitMaker-hub)

You can also build it easily using the flasher tool:
https://bitmaker-hub.github.io/diyflasher/
  • Loading branch information
BitMaker-hub authored Aug 27, 2023
2 parents 994118c + b7636dd commit af41625
Show file tree
Hide file tree
Showing 43 changed files with 2,961 additions and 5,312 deletions.
Binary file added 3d_files/NerdCase_withButtons_byJoaquin.stl
Binary file not shown.
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ Original project https://github.com/valerio-vaccaro/HAN
![image](images/NerdMinerv2.jpg)

## Requirements
- TTGO T-Display S3
- TTGO T-Display S3 or any supported boards (check Build tutorial 👇)
- 3D BOX [here](3d_files/)

### Project description
**ESP32 implementing Stratum protocol** to mine on solo pool. Pool can be changed but originally works with ckpool.
**ESP32 implementing Stratum protocol** to mine on solo pool. Pool can be changed but originally works with Public-pool.io (where Nerdminers are supported).

This project is using ESP32-S3, uses WifiManager to modify miner settings and save them to SPIFF.
This project was initialy developed using ESP32-S3, but currently support other boards. It uses WifiManager to modify miner settings and save them to SPIFF.
The microMiner comes with several screens to monitor it's working procedure and also to show you network mining stats.
Currently includes:
- NerdMiner Screen > Mining data of Nerdminer
- ClockMiner Screen > Fashion style clock miner
- GlobalStats Screen > Global minery stats and relevant data

This miner is multicore and multithreads, one thread is used to mine and other is implementing stratum work and wifi stuff.
This miner is multicore and multithreads, both cores are used to mine and several threads are used to implementing stratum work and wifi stuff.
Every time an stratum job notification is received miner update its current work to not create stale shares.

**IMPORTANT** Miner is not seen by all standard pools due to its low share difficulty. You can check miner work remotely using specific pools specified down or seeing logs via UART.
Expand All @@ -34,20 +34,24 @@ Every time an stratum job notification is received miner update its current work
## Build Tutorial
### Hardware requirements
- TTGO T-Display S3 > Buy it on aliexpress or amazon
- 3D BOX
- 3D BOX [here](3d_files/)

#### Current Supported Boards
- TTGO T-Display S3 ([Aliexpress link](https://s.click.aliexpress.com/e/_Ddy7739))
- ESP32-WROOM-32, ESP32-Devkit1.. ([Aliexpress link](https://s.click.aliexpress.com/e/_DCzlUiX))

### Flash firmware
#### microMiners Flashtool [Recommended]
Easyiest way to flash firmware. Build your own miner using the folowing firwmare flash tool:

1. Get a TTGO T-display S3
1. Get a TTGO T-display S3 or any other supported board
1. Go to NM2 flasher online: https://bitmaker-hub.github.io/diyflasher/

#### Standard tool
Create your own miner using the online firwmare flash tool **ESPtool** and the **binary files** that you will find in the src/bin folder.
If you want you can compile the entire project using Arduino, PlatformIO or Expressif IDF.

1. Get a TTGO T-display S3
1. Get a TTGO T-display S3 or any supported board
1. Download this repository
1. Go to ESPtool online: https://espressif.github.io/esptool-js/
1. Load the firmware with the binaries from the src/bin folder.
Expand All @@ -61,6 +65,7 @@ Update NerdMiner firmware following same flashing steps but only adding 0x10000_
1. ESPtool recommendations: use 115200bps
1. Build errors > If during firmware download upload stops, it's recommended to enter the board in boot mode. Unplug cable, hold right bottom button and then plug cable. Try programming
1. In extreme case you can "Erase all flash" on ESPtool to clean all current configuration before uploading firmware. There has been cases that experimented Wifi failures until this was made.
1. In case of ESP32-WROOM Boards, could be necessary to put your board on boot mode. Hold boot button, press reset button and then program.

### NerdMiner configuration
After programming, you will only need to setup your Wifi and BTC address.
Expand Down Expand Up @@ -108,11 +113,11 @@ With the USB-C port to the right:
## Developers
### Project guidelines
- Current project was addapted to work with PlatformIO
- Current project works with ESP32-S3 but any ESP32 can be used.
- Current project works with ESP32-S3 and ESP32-wroom.
- Partition squeme should be build as huge app
- All libraries needed shown on platform.ini

### On process
### Job done
- [x] Move project to platformIO
- [x] Bug rectangle on screen when 1milion shares
- [x] Bug memory leaks
Expand All @@ -123,6 +128,16 @@ With the USB-C port to the right:
- [x] Add blockHeight to screen
- [x] Add clock to show current time
- [x] Add new screen with global mining stats
- [x] Add pool support for low difficulty miners
- [x] Add best difficulty on miner screen
- [x] Add suport to standard ESP32 dev-kit / ESP32-WROOM

### On process
- [ ] Code changes to support adding multiple boards
- [ ] Create a daisy chain protocol via UART or I2C to support ESP32 hashboards
- [ ] Add support to TTGO T-display 1.14
- [ ] Add support to Amoled
- [ ] Create new screen like clockMiner but with BTC price
- [ ] Add support to control BM1397

### Donations/Project contributions
Expand Down
Binary file removed bin/0x10000_firmware_v1.4.bin
Binary file not shown.
Binary file added bin/bin ESP32-devKit/0x10000_firmware.bin
Binary file not shown.
Binary file added bin/bin ESP32-devKit/0x1000_bootloader.bin
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file added bin/bin TTGO TDisplay S3/0xe000_boot_app0.bin
Binary file not shown.
10 changes: 5 additions & 5 deletions lib/TFT_eSPI/User_Setup_Select.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
//#include <User_Setups/Setup44_TTGO_CameraPlus.h> // Setup file for ESP32 and TTGO T-CameraPlus ST7789 SPI bus TFT 240x240
//#include <User_Setups/Setup45_TTGO_T_Watch.h> // Setup file for ESP32 and TTGO T-Watch ST7789 SPI bus TFT 240x240
//#include <User_Setups/Setup46_GC9A01_ESP32.h> // Setup file for ESP32 and GC9A01 SPI bus TFT 240x240

//#include <User_Setups/Setup47_ST7735.h> // Setup file for ESP32 configured for ST7735 128 x 128 animated eyes

#ifdef DEVKITV1
#include <User_Setups/Setup47_ST7735.h> // Setup file for ESP32 configured for ST7735 128 x 128 animated eyes
#endif
//#include <User_Setups/Setup50_SSD1963_Parallel.h> // Setup file for ESP32 and SSD1963 TFT display

//#include <User_Setups/Setup51_LilyPi_ILI9481.h> // Setup file for LilyGo LilyPi with ILI9481 display
Expand Down Expand Up @@ -127,9 +127,9 @@
//#include <User_Setups/Setup204_ESP32_TouchDown.h> // Setup file for the ESP32 TouchDown based on ILI9488 480 x 320 TFT

//#include <User_Setups/Setup205_ESP32_TouchDown_S3.h> // Setup file for the ESP32 TouchDown S3 based on ILI9488 480 x 320 TFT

#ifdef NERDMINERV2
#include <User_Setups/Setup206_LilyGo_T_Display_S3.h>

#endif
//#include <User_Setups/Setup301_BW16_ST7735.h> // Setup file for Bw16-based boards with ST7735 160 x 80 TFT

//#include <User_Setups/SetupX_Template.h> // Template file for a setup
Expand Down
24 changes: 11 additions & 13 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[platformio]
globallib_dir = lib
default_envs = NerminerV2 ;, ESP32-devKitv1 TTGO-T-Display
default_envs = NerminerV2, ESP32-devKitv1

[env:NerminerV2]
platform = espressif32
Expand All @@ -35,14 +35,15 @@ build_flags =
-D BOARD_HAS_PSRAM
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D NERDMINERV2=1
;-D DEBUG_MINING=1
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient
https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4
;https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4


[env:ESP32-devKitv1]
Expand All @@ -58,26 +59,22 @@ monitor_speed = 115200
upload_speed = 115200

# 2 x 4.5MB app, 6.875MB SPIFFS
;board_build.partitions = large_spiffs_16MB.csv
;board_build.partitions = default_8MB.csv
;board_build.partitions = huge_app.csv
board_build.partitions = default.csv
board_build.partitions = huge_app.csv

build_flags =
-D ARDUINO_USB_MODE=1
-U FREERTOS
-D DEVKITV1=1
;-D DEBUG_MINING=1
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient
https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4


[env:TTGO-T-Display]
platform = espressif32
board = esp-wrover-kit
board = esp32dev ;esp-wrover-kit
framework = arduino
monitor_filters =
esp32_exception_decoder
Expand All @@ -87,16 +84,17 @@ board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 115200


# 2 x 4.5MB app, 6.875MB SPIFFS
board_build.partitions = huge_app.csv

;build_flags =
; -D ARDUINO_USB_MODE=1
build_flags =
;-D DEBUG_MINING=1
-D TDISPLAY=1
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient
https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4
;https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4
52 changes: 30 additions & 22 deletions src/NerdMinerV2.ino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
#include "mining.h"
#include "monitor.h"

#define CURRENT_VERSION "V1.6.0"
#define CURRENT_VERSION "V1.6.1"

//3 seconds WDT
#define WDT_TIMEOUT 3
//120 seconds WDT for miner task
#define WDT_MINER_TIMEOUT 120
//15 minutes WDT for miner task
#define WDT_MINER_TIMEOUT 900
OneButton button1(PIN_BUTTON_1);
OneButton button2(PIN_BUTTON_2);


OpenFontRender render;
extern monitor_data mMonitor;

/**********************⚡ GLOBAL Vars *******************************/
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
Expand All @@ -38,10 +39,12 @@ const char* ntpServer = "pool.ntp.org";
//void runMonitor(void *name);

void alternate_screen_state() {
#ifdef NERDMINERV2
int screen_state= digitalRead(TFT_BL);
//Serial.printf("Screen state is '%s', switching to '%s'", screen_state, !screen_state);
Serial.println("Switching display state");
digitalWrite(TFT_BL, !screen_state);
#endif
}

void alternate_screen_rotation() {
Expand All @@ -64,21 +67,23 @@ void setup()
//disableCore1WDT();

// Setup the buttons
#ifdef NERDMINERV2
// Button 1 (Boot)
button1.setPressTicks(5000);
button1.attachClick(alternate_screen_state);
button1.attachDoubleClick(alternate_screen_rotation);
// button1.attachLongPressStart([]{Serial.println("Button 1 started a long press");});
// button1.attachLongPressStop([]{Serial.println("Button 1 stopped a long press");});
// button1.attachDuringLongPress([]{Serial.println("Button 1 is being held down");});

// Button 2 (GPIO14)
button2.setPressTicks(5000);
button2.attachClick(changeScreen);
// button2.attachDoubleClick([]{Serial.println("Button 2 was double clicked");});
button2.attachLongPressStart(reset_configurations);
// button2.attachLongPressStop(reset_configurations);
// button2.attachDuringLongPress([]{Serial.println("Button 2 is being held down");});
#elif defined(DEVKITV1)
//Standard ESP32-devKit
button1.setPressTicks(5000);
button1.attachLongPressStart(reset_configurations);
pinMode(LED_PIN, OUTPUT);
#endif




/******** INIT NERDMINER ************/
Expand All @@ -105,9 +110,15 @@ void setup()
tft.fillScreen(TFT_BLACK);
tft.pushImage(0, 0, initWidth, initHeight, initScreen);
tft.setTextColor(TFT_BLACK);
tft.drawString(CURRENT_VERSION, 24, 130, FONT2);
tft.drawString(CURRENT_VERSION, 24, 147, FONT2);
delay(2000);

/******** SHOW LED INIT STATUS (devices without screen) *****/
mMonitor.NerdStatus = NM_waitingConfig;
#ifdef DEVKITV1
doLedStuff(LED_PIN);
#endif

/******** INIT WIFI ************/
init_WifiManager();

Expand All @@ -122,27 +133,20 @@ void setup()

/******** CREATE STRATUM TASK *****/
sprintf(name, "(%s)", "Stratum");
BaseType_t res2 = xTaskCreatePinnedToCore(runStratumWorker, "Stratum", 20000, (void*)name, 3, NULL,1);
BaseType_t res2 = xTaskCreatePinnedToCore(runStratumWorker, "Stratum", 15000, (void*)name, 3, NULL,1);


/******** CREATE MINER TASKS *****/
//for (size_t i = 0; i < THREADS; i++) {
// char *name = (char*) malloc(32);
// sprintf(name, "(%d)", i);

// Start stratum tasks
sprintf(name, "(%s)", "Miner0");
//BaseType_t res = xTaskCreatePinnedToCore(runMiner, "0", 10000, (void*)name, 1, NULL, 0);
//BaseType_t res3 = xTaskCreatePinnedToCore(runMiner, "0", 10000, (void*)name, 1,NULL, 0);
//sprintf(name, "(%s)", "Miner1");
//BaseType_t res4 = xTaskCreatePinnedToCore(runMiner, "1", 10000, (void*)name, 1,NULL, 0);
//Serial.printf("Starting %s %s!\n", "1", res3 == pdPASS? "successful":"failed");

// Start mining tasks
//BaseType_t res = xTaskCreate(runWorker, name, 35000, (void*)name, 1, NULL);
TaskHandle_t minerTask1, minerTask2 = NULL;
xTaskCreate(runMiner, "Miner0", 15000, (void*)0, 1, &minerTask1);
xTaskCreate(runMiner, "Miner1", 15000, (void*)1, 1, &minerTask2);
xTaskCreate(runMiner, "Miner0", 6000, (void*)0, 1, &minerTask1);
xTaskCreate(runMiner, "Miner1", 6000, (void*)1, 1, &minerTask2);

esp_task_wdt_add(minerTask1);
esp_task_wdt_add(minerTask2);

Expand All @@ -169,5 +173,9 @@ void loop() {

wifiManagerProcess(); // avoid delays() in loop when non-blocking and other long running code

#ifdef DEVKITV1
doLedStuff(LED_PIN);
#endif

vTaskDelay(50 / portTICK_PERIOD_MS);
}
Loading

0 comments on commit af41625

Please sign in to comment.