A worker service for managing and monitoring Whatsminer Bitcoin mining devices. This implementation provides comprehensive control over Whatsminer miners, including the models m30sp, m30spp, m53s, m56s, and, m63, with support for monitoring, configuration, and remote management.
- Overview
- Object Model
- Features
- Requirements
- Installation
- Configuration
- Usage
- Data Collection
- Error Monitoring
- Protocol Details
- Mock Server
- Development
- Troubleshooting
The Whatsminer worker extends the abstract miner worker framework to provide specific functionality for Whatsminer mining hardware. It implements an encrypted TCP connection for secure device communication and offers advanced power management and monitoring features.
The following is a fragment of MiningOS object model that contains the concrete classes representing Whatsminer miner workers (highlighted in blue), one generically representing any model of the brand, and child classes specifically representing models M30SP, M30SPP, M53S, M56S, and M63. The rounded nodes reprsent abstract classes while the square nodes represent concrete classes:
---
title: Object Model of MiningOS
---
flowchart RL
bfx-wrk-base@{ shape: stadium, label: "*bfx-wrk-base*" }
tether-wrk-base@{ shape: stadium, label: "*tether-wrk-base*" }
tether-wrk-base--->bfx-wrk-base
miningos-tlp-wrk-thing@{ shape: stadium, label: "*miningos-tlp-wrk-thing*" }
miningos-tlp-wrk-thing--->tether-wrk-base
miningos-tpl-wrk-miner@{ shape: stadium, label: "*miningos-tpl-wrk-miner*" }
miningos-tpl-wrk-miner--->miningos-tlp-wrk-thing
miningos-wrk-miner-whatsminer["miningos-wrk-miner-whatsminer"]
miningos-wrk-miner-whatsminer--->miningos-tpl-wrk-miner
miningos-wrk-miner-antminer["miningos-wrk-miner-antminer"]
miningos-wrk-miner-antminer--->miningos-tpl-wrk-miner
miningos-wrk-miner-avalon["miningos-wrk-miner-avalon"]
miningos-wrk-miner-avalon--->miningos-tpl-wrk-miner
miningos-wrk-miner-whatsminer-M30SP["miningos-wrk-miner-whatsminer-M30SP"]
miningos-wrk-miner-whatsminer-M30SP--->miningos-wrk-miner-whatsminer
miningos-wrk-miner-whatsminer-M30SPP["miningos-wrk-miner-whatsminer-M30SPP"]
miningos-wrk-miner-whatsminer-M30SPP--->miningos-wrk-miner-whatsminer
miningos-wrk-miner-whatsminer-M53S["miningos-wrk-miner-whatsminer-M53S"]
miningos-wrk-miner-whatsminer-M53S--->miningos-wrk-miner-whatsminer
miningos-wrk-miner-whatsminer-M56S["miningos-wrk-miner-whatsminer-M56S"]
miningos-wrk-miner-whatsminer-M56S--->miningos-wrk-miner-whatsminer
miningos-wrk-miner-whatsminer-M63["miningos-wrk-miner-whatsminer-M63"]
miningos-wrk-miner-whatsminer-M63--->miningos-wrk-miner-whatsminer
style miningos-wrk-miner-whatsminer fill:#005,stroke-width:4px
style miningos-wrk-miner-whatsminer-M30SP fill:#005,stroke-width:4px
style miningos-wrk-miner-whatsminer-M30SPP fill:#005,stroke-width:4px
style miningos-wrk-miner-whatsminer-M53S fill:#005,stroke-width:4px
style miningos-wrk-miner-whatsminer-M56S fill:#005,stroke-width:4px
style miningos-wrk-miner-whatsminer-M63 fill:#005,stroke-width:4px
Check out miningos-tpl-wrk-miner for more information about parent classes.
- M30SP
- M30SPP
- M53S
- M56S
- M63
- Device Management: Register, update, and remove Whatsminer devices
- Secure Communication: AES-encrypted token authentication
- Real-time Monitoring: Comprehensive metrics collection and status tracking
- Pool Management: Configure and monitor up to 3 mining pools
- Advanced Power Control: Low, normal, high, and sleep power modes
- Network Configuration: DHCP and static IP support
- Power Modes: Sleep, low, normal, and high performance modes
- Power Limiting: Set power consumption limits (watts)
- Frequency Control: Adjust mining frequency --- from -100% to +100% normal frequency (namely from 0 to double normal frequency)
- Fan Control: Zero-speed fan mode support
- Upfreq Speed: Control frequency ramping speed (0-100)
- Hashrate Tracking: 5s, 1m, 5m, 15m averages
- Temperature Monitoring:
- Chip-level temperatures (min/max/avg)
- PCB temperatures per board
- Ambient temperature
- Power Metrics: Consumption, efficiency (W/TH/s)
- Error Detection: Comprehensive error code monitoring
- Pool Statistics: Accepted, rejected, stale shares per pool
- Fast Boot: Enable/disable fast boot mode
- Web Pool Management: Enable/disable web-based pool configuration
- LED Control: Manual or automatic LED control
- Timezone Configuration: Set miner timezone
- PSU Information: Power supply unit monitoring
- Node.js (>= 20.0)
- Clone the repository
- Install dependencies:
npm install
- Configure the worker:
./setup-config.sh
{
"dir_log": "logs",
"debug": 0
}{
"thing": {
"minerDefaultPort": 4028,
"miner": {
"timeout": 30000,
"nominalEfficiencyWThs": {
"miner-wm-m30sp": 0,
"miner-wm-m30spp": 0,
"miner-wm-m53s": 0,
"miner-wm-m56s": 0,
"miner-wm-m63": 0
}
}
}
}Note: The nominalEfficiencyWThs values in the example configuration are set to 0. The worker uses default values from code if not overridden:
- M30SP/M30SPP: 33 W/TH/s (default)
- M53S/M56S/M63: 26 W/TH/s (default)
Each model has specific alert configurations for various conditions:
- Temperature warnings (PCB, chip, inlet)
- Power errors and protection states
- Hashboard errors
- Pool connectivity issues
- EEPROM errors
- Control board exceptions
See config/base.thing.json.example for complete alert definitions per model.
node worker.js --wtype wrk-miner-rack-m56s --env production --rack rack-1
node worker.js --wtype wrk-miner-rack-m53s --env production --rack rack-2
node worker.js --wtype wrk-miner-rack-m30sp --env production --rack rack-3
node worker.js --wtype wrk-miner-rack-m30spp --env production --rack rack-4
node worker.js --wtype wrk-miner-rack-m63 --env production --rack rack-5{
"method": "registerThing",
"params": {
"opts": {
"address": "192.168.1.100",
"port": 4028,
"password": "admin",
"timeout": 30000,
"type": "m56s" // Model type
},
"info": {
"serialNum": "WM123456",
"macAddress": "00:11:22:33:44:55",
"pos": "1",
"container": "container-01"
},
"tags": ["production", "site-1"]
}
}Standard miner management methods:
getRack: Get rack informationlistThings: List all managed minersregisterThing: Register new minerupdateThing: Update miner configurationforgetThings: Remove minersqueryThing: Execute miner commandsapplyThings: Apply operations to multiple minerstailLog: Retrieve historical data
Execute commands via the queryThing RPC method:
// Set power mode
{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "setPowerMode",
"params": ["high"] // "sleep", "low", "normal", or "high"
}
}
// Set power limit
{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "setPowerLimit",
"params": [3000] // Watts, use 99999 to reset
}
}{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "setPools",
"params": []
}
}// Set frequency adjustment
{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "setFrequency",
"params": ["10"] // -100 to 100 percent
}
}
// Set upfreq speed
{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "setUpfreqSpeed",
"params": ["50"] // 0 to 100
}
}// Reboot
{ "method": "queryThing", "params": { "id": "miner-id", "method": "reboot", "params": [] }}
// Factory reset
{ "method": "queryThing", "params": { "id": "miner-id", "method": "factoryReset", "params": [] }}
// LED control
{ "method": "queryThing", "params": { "id": "miner-id", "method": "setLED", "params": [true] }}
// Enable fast boot
{ "method": "queryThing", "params": { "id": "miner-id", "method": "enableFastBoot", "params": [] }}Automatic snapshot collection includes:
- Status (mining, sleeping, error)
- Hashrate metrics (multiple time windows)
- Power consumption and efficiency
- Temperature data (chip, PCB, ambient)
- Pool share statistics
- Error codes and minor error flags
- Network settings (IP, DNS, gateway)
- Pool configuration
- Power mode and limits
- Firmware version
- LED status
The system monitors numerous error conditions with model-specific handling:
- Power-related errors (over 20 types)
- Temperature errors and protection states
- Hashboard and EEPROM errors
- Pool connectivity issues
- Control board exceptions
- Firmware and software errors
Minor errors are distinguished from critical errors, allowing for nuanced monitoring.
- Fetch token using admin password
- All write operations require encrypted token
- Token refresh on expiration (Code 135)
- AES encryption in ECB mode
- SHA256 key derivation
- JSON payload encryption for write operations
- 131: Success
- 135: Token expired
- 136: IP limit exceeded
- 14: Invalid command
A comprehensive mock server is provided for testing:
DEBUG="*" node mock/server.js --type M56s -p 8080 -h 0.0.0.0
DEBUG="*" node mock/server.js --type M53s -p 8080 -h 0.0.0.0
DEBUG="*" node mock/server.js --type M30sp -p 8080 -h 0.0.0.0
DEBUG="*" node mock/server.js --type M30spp -p 8080 -h 0.0.0.0
DEBUG="*" node mock/server.js --type M63 -p 8080 -h 0.0.0.0The mock server simulates all Whatsminer commands and responses.
- Create worker file extending base:
class WrkMinerRackNewModel extends WrkMinerRack {
getThingType() {
return super.getThingType() + '-newmodel'
}
}- Add model to constants:
- Nominal efficiency values
- Minor error codes (if applicable)
- Configure model-specific alerts in base.thing.json
npm test