diff --git a/main/EMC2101.c b/main/EMC2101.c index 7cdfce48..66fd9bc8 100644 --- a/main/EMC2101.c +++ b/main/EMC2101.c @@ -71,7 +71,7 @@ uint16_t EMC2101_get_fan_speed(void) return RPM; } -float EMC2101_get_chip_temp(void) +float EMC2101_get_external_temp(void) { uint8_t temp_msb, temp_lsb; uint16_t reading; @@ -83,4 +83,11 @@ float EMC2101_get_chip_temp(void) reading >>= 5; return (float)reading / 8.0; -} \ No newline at end of file +} + +uint8_t EMC2101_get_internal_temp(void) +{ + uint8_t temp; + ESP_ERROR_CHECK(register_read(EMC2101_INTERNAL_TEMP, &temp, 1)); + return temp; +} diff --git a/main/EMC2101.h b/main/EMC2101.h index 4046fc4f..8ead1d0c 100644 --- a/main/EMC2101.h +++ b/main/EMC2101.h @@ -61,6 +61,6 @@ void EMC2101_set_fan_speed(float); // void EMC2101_read(void); uint16_t EMC2101_get_fan_speed(void); void EMC2101_init(void); -float EMC2101_get_chip_temp(void); - +float EMC2101_get_external_temp(void); +uint8_t EMC2101_get_internal_temp(void); #endif /* EMC2101_H_ */ \ No newline at end of file diff --git a/main/http_server/axe-os/src/app/components/home/home.component.html b/main/http_server/axe-os/src/app/components/home/home.component.html index 9901ac34..e9adb65b 100644 --- a/main/http_server/axe-os/src/app/components/home/home.component.html +++ b/main/http_server/axe-os/src/app/components/home/home.component.html @@ -92,6 +92,11 @@

Power

{{info.fanSpeed}} RPM + + Chip Temperature: + {{info.temp}} C + + diff --git a/main/http_server/axe-os/src/app/components/home/home.component.ts b/main/http_server/axe-os/src/app/components/home/home.component.ts index 748a2c58..886b0ce5 100644 --- a/main/http_server/axe-os/src/app/components/home/home.component.ts +++ b/main/http_server/axe-os/src/app/components/home/home.component.ts @@ -1,6 +1,6 @@ import { AfterViewChecked, Component, ElementRef, ViewChild } from '@angular/core'; import { ToastrService } from 'ngx-toastr'; -import { interval, Observable, shareReplay, switchMap } from 'rxjs'; +import { interval, Observable, shareReplay, startWith, switchMap } from 'rxjs'; import { LoadingService } from 'src/app/services/loading.service'; import { SystemService } from 'src/app/services/system.service'; import { WebsocketService } from 'src/app/services/web-socket.service'; @@ -25,6 +25,7 @@ export class HomeComponent implements AfterViewChecked { ) { this.info$ = interval(3000).pipe( + startWith(() => this.systemService.getInfo()), switchMap(() => { return this.systemService.getInfo() }), diff --git a/main/http_server/axe-os/src/app/services/system.service.ts b/main/http_server/axe-os/src/app/services/system.service.ts index 74e1da58..a2ed65f8 100644 --- a/main/http_server/axe-os/src/app/services/system.service.ts +++ b/main/http_server/axe-os/src/app/services/system.service.ts @@ -24,6 +24,7 @@ export class SystemService { "voltage": 5208.75, "current": 2237.5, "fanSpeed": 82, + "temp": 60, "hashRate": 0, "bestDiff": "0", "freeHeap": 200504, diff --git a/main/http_server/axe-os/src/models/ISystemInfo.ts b/main/http_server/axe-os/src/models/ISystemInfo.ts index 305d1bb2..ca7a9fb0 100644 --- a/main/http_server/axe-os/src/models/ISystemInfo.ts +++ b/main/http_server/axe-os/src/models/ISystemInfo.ts @@ -4,6 +4,7 @@ export interface ISystemInfo { voltage: number, current: number, fanSpeed: number, + temp: number, hashRate: number, bestDiff: string, freeHeap: number, diff --git a/main/http_server/http_server.c b/main/http_server/http_server.c index 9a0f1504..d4d7e503 100644 --- a/main/http_server/http_server.c +++ b/main/http_server/http_server.c @@ -270,8 +270,10 @@ static esp_err_t GET_system_info(httpd_req_t *req) cJSON_AddNumberToObject(root, "voltage", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.voltage); cJSON_AddNumberToObject(root, "current", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.current); cJSON_AddNumberToObject(root, "fanSpeed", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.fan_speed); + cJSON_AddNumberToObject(root, "temp", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.chip_temp); cJSON_AddNumberToObject(root, "hashRate", GLOBAL_STATE->SYSTEM_MODULE.current_hashrate); cJSON_AddStringToObject(root, "bestDiff", GLOBAL_STATE->SYSTEM_MODULE.best_diff_string); + cJSON_AddNumberToObject(root, "freeHeap", esp_get_free_heap_size()); cJSON_AddNumberToObject(root, "coreVoltage", ADC_get_vcore()); cJSON_AddStringToObject(root, "ssid", ssid); diff --git a/main/tasks/power_management_task.c b/main/tasks/power_management_task.c index 7ac5f137..f16254cc 100644 --- a/main/tasks/power_management_task.c +++ b/main/tasks/power_management_task.c @@ -46,7 +46,7 @@ void POWER_MANAGEMENT_task(void *pvParameters) while (1) { - if (read_power) + if (read_power == true) { power_management->voltage = INA260_read_voltage(); power_management->power = INA260_read_power() / 1000; @@ -57,7 +57,7 @@ void POWER_MANAGEMENT_task(void *pvParameters) if (strcmp(ASIC_MODEL, "BM1397") == 0) { - power_management->chip_temp = EMC2101_get_chip_temp(); + power_management->chip_temp = EMC2101_get_external_temp(); // Voltage // We'll throttle between 4.9v and 3.5v @@ -125,6 +125,8 @@ void POWER_MANAGEMENT_task(void *pvParameters) } else if (strcmp(ASIC_MODEL, "BM1366") == 0) { + power_management->chip_temp = EMC2101_get_internal_temp() + 5; + if (power_management->fan_speed < 10) { ESP_LOGE(TAG, "Detected fan speed too slow, setting vCore to 0"); diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 641f1e8b..ea901014 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -5,6 +5,6 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y CONFIG_ESPTOOLPY_FLASHSIZE="8MB" -CONFIG_ESP_MAXIMUM_RETRY=3 +CONFIG_ESP_MAXIMUM_RETRY=5 CONFIG_HTTPD_WS_SUPPORT=y CONFIG_SPIFFS_OBJ_NAME_LEN=64 \ No newline at end of file