docs : edit README

This commit is contained in:
2026-01-05 16:27:31 +09:00
parent f06f5e0f61
commit 1144c1f83e
3 changed files with 46 additions and 60 deletions

View File

@@ -27,10 +27,10 @@ HX711 scale;
// ===== 설정 변수 ===== // ===== 설정 변수 =====
float calibration_factor = -411.17; // 캘리브레이션 팩터 (실제 무게(g) = 90060(Raw 값) ÷ 캘리브레이션 팩터) float calibration_factor = -411.17; // 캘리브레이션 팩터 (실제 무게(g) = 90060(Raw 값) ÷ 캘리브레이션 팩터)
int measureDelay = 100; // 측정 간격 (ms) - HX711 10Hz 기준 int measureDelay = 100; // 측정 간격 (ms)
const int DELAY_STEP = 10; // 측정 간격 조절 단위 (ms) const int DELAY_STEP = 10; // 측정 간격 조절 단위 (ms)
const int MIN_DELAY = 10; // 최소 측정 간격 (ms) // const int MIN_DELAY = 10; // 최소 측정 간격 (ms)
const int MAX_DELAY = 2000; // 최대 측정 간격 (ms) // const int MAX_DELAY = 2000; // 최대 측정 간격 (ms)
// ===== 상태 변수 ===== // ===== 상태 변수 =====
bool isPaused = false; // 일시정지 상태 bool isPaused = false; // 일시정지 상태
@@ -45,6 +45,10 @@ void printHelp();
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
while (!Serial) {
delay(10);
}
// 시작 메시지 // 시작 메시지
Serial.println("================================="); Serial.println("=================================");
Serial.println(" LoadCellMeasure 시작"); Serial.println(" LoadCellMeasure 시작");
@@ -105,7 +109,7 @@ void loop() {
Serial.print(",\"unit\":\"g\",\"time\":"); Serial.print(",\"unit\":\"g\",\"time\":");
Serial.print(elapsedTime, 2); // 소수점 2자리 (0.01초 단위) Serial.print(elapsedTime, 2); // 소수점 2자리 (0.01초 단위)
Serial.print(",\"delay\":"); Serial.print(",\"delay\":");
Serial.print(measureDelay); Serial.print(measureDelay+100); //HX711 읽기(100ms)
Serial.println("}"); Serial.println("}");
} }
@@ -173,26 +177,10 @@ void processCommand(char cmd) {
} }
break; break;
// '+' : 측정 속도 빠르게 (딜레이 감소) // 't' 또는 'T' : 시간 초기화
case '+': case 't':
if (measureDelay > MIN_DELAY) { startTime = millis();
measureDelay -= DELAY_STEP; Serial.println("\n>> 측정 시간 초기화!\n");
if (measureDelay < MIN_DELAY) measureDelay = MIN_DELAY;
Serial.println(">> 측정 간격 감소: " + String(measureDelay) + " ms (빠름)");
} else {
Serial.println(">> 최소 측정 간격입니다: " + String(MIN_DELAY) + " ms");
}
break;
// '-' : 측정 속도 느리게 (딜레이 증가)
case '-':
if (measureDelay < MAX_DELAY) {
measureDelay += DELAY_STEP;
if (measureDelay > MAX_DELAY) measureDelay = MAX_DELAY;
Serial.println(">> 측정 간격 증가: " + String(measureDelay) + " ms (느림)");
} else {
Serial.println(">> 최대 측정 간격입니다: " + String(MAX_DELAY) + " ms");
}
break; break;
// 'h' 또는 'H' : 도움말 // 'h' 또는 'H' : 도움말

View File

@@ -24,31 +24,44 @@ Arduino HX711 로드셀 데이터를 실시간으로 웹 브라우저에 그래
Python 3.7 이상이 필요합니다. Python 3.7 이상이 필요합니다.
```bash ```bash
# 가상환경 생성 (선택사항, 권장) # 프로젝트 루트에서 web_UI 폴더로 이동
python -m venv venv cd web_UI
(# 가상환경 생성 (이미 venv 폴더가 있다면 건너뛰기))
(python -m venv venv)
# 가상환경 활성화 # 가상환경 활성화
# Windows: # Windows (Command Prompt):
venv\Scripts\activate venv\Scripts\activate
# Windows (PowerShell):
.\venv\Scripts\Activate.ps1
# macOS/Linux: # macOS/Linux:
source venv/bin/activate source venv/bin/activate
# 가상환경 활성화 확인 (프롬프트에 (venv) 표시됨)
# 필요한 패키지 설치 # 필요한 패키지 설치
pip install -r requirements.txt pip install -r requirements.txt
``` ```
> **참고**: 가상환경을 비활성화하려면 `deactivate` 명령어를 사용하세요.
---
### 2. Arduino 준비 ### 2. Arduino 준비
1. Arduino IDE에서 `LoadCellMeasure.ino` 파일을 Arduino에 업로드 1. Arduino IDE에서 `LoadCellMeasure.ino` 파일을 Arduino에 업로드
2. Arduino와 PC가 USB로 연결되어 있는지 확인 2. Arduino와 PC가 USB로 연결되어 있는지 확인
3. Arduino IDE의 시리얼 모니터는 **닫아야 합니다** (포트 충돌 방지) 3. Arduino IDE의 시리얼 모니터는 **닫아야 합니다** (포트 충돌 방지)
---
## 실행 방법 ## 실행 방법
### 1. Python 서버 실행 ### 1. Python 서버 실행 (PowerShell)
```bash ```PowerShell
cd web_gui # web_UI 폴더에서 가상환경이 활성화된 상태로 순서대로 실행
cd web_UI
.\venv\Scripts\Activate.ps1
python app.py python app.py
``` ```
@@ -98,18 +111,17 @@ http://[서버PC의IP주소]:5000
- `c`: 영점 조절 - `c`: 영점 조절
- `p`: 일시정지 - `p`: 일시정지
- `r`: 재시작 - `r`: 재시작
- `+`: 측정 속도 빠르게
- `-`: 측정 속도 느리게
- `h`: 도움말 - `h`: 도움말
## 프로젝트 구조 ## 프로젝트 구조
``` ```
web_gui/ web_UI/
├── app.py # Flask 백엔드 서버 ├── app.py # Flask 백엔드 서버
├── requirements.txt # Python 패키지 목록 ├── requirements.txt # Python 패키지 목록
├── venv/ # Python 가상환경
├── templates/ ├── templates/
│ └── index.html # 웹 프론트엔드 │ └── loadcell_measure.html # 웹 프론트엔드
└── README.md # 이 파일 └── README.md # 이 파일
``` ```
@@ -156,7 +168,7 @@ port = "COM3" # 또는 /dev/ttyUSB0 (Linux), /dev/cu.usbserial (macOS)
### 그래프 데이터 포인트 수 변경 ### 그래프 데이터 포인트 수 변경
`templates/index.html` 파일에서: `templates/loadcell_measure.html` 파일에서:
```javascript ```javascript
const maxDataPoints = 50; // 원하는 숫자로 변경 const maxDataPoints = 50; // 원하는 숫자로 변경
@@ -164,7 +176,7 @@ const maxDataPoints = 50; // 원하는 숫자로 변경
### 측정 간격 조절 ### 측정 간격 조절
Arduino 코드의 `measureDelay` 변수 조절 또는 웹에서 `+`/`-` 키로 조절 Arduino 코드의 `measureDelay` 변수 조절
### 서버 포트 변경 ### 서버 포트 변경
@@ -173,7 +185,3 @@ Arduino 코드의 `measureDelay` 변수 조절 또는 웹에서 `+`/`-` 키로
```python ```python
socketio.run(app, host='0.0.0.0', port=5000, debug=False) # 포트 번호 변경 socketio.run(app, host='0.0.0.0', port=5000, debug=False) # 포트 번호 변경
``` ```
## 라이선스
이 프로젝트는 교육 및 연구 목적으로 자유롭게 사용할 수 있습니다.

View File

@@ -231,24 +231,13 @@
</div> </div>
</div> </div>
<!-- 측정 속도 조절 -->
<div style="margin-top: 20px;">
<h3 style="margin-bottom: 10px; color: #666;">측정 속도 조절</h3>
<div style="display: flex; align-items: center; gap: 10px;">
<button class="btn btn-primary" onclick="sendCommand('-')" style="flex: 1; font-size: 1.5em;">-</button>
<div style="flex: 2; text-align: center; font-size: 0.9em; color: #666;">
느리게 / 빠르게
</div>
<button class="btn btn-primary" onclick="sendCommand('+')" style="flex: 1; font-size: 1.5em;">+</button>
</div>
</div>
<!-- Controls --> <!-- Controls -->
<div class="controls"> <div class="controls">
<button class="btn btn-primary" onclick="sendCommand('c')">영점 조절</button> <button class="btn btn-primary" onclick="sendCommand('c')">영점 조절</button>
<button class="btn btn-secondary" onclick="sendCommand('p')">일시정지</button> <button class="btn btn-secondary" onclick="sendCommand('p')">일시정지</button>
<button class="btn btn-success" onclick="sendCommand('r')">재시작</button> <button class="btn btn-success" onclick="sendCommand('r')">재시작</button>
<button class="btn btn-danger" onclick="clearChart()">그래프 초기화</button> <button class="btn btn-danger" onclick="clearChart()">그래프 초기화</button>
</div> </div>
</div> </div>
</div> </div>
@@ -300,8 +289,6 @@
}, },
y: { y: {
beginAtZero: true, beginAtZero: true,
min: 0,
max: 5000, // 최대값 5kg(5000g)로 고정
title: { title: {
display: true, display: true,
text: '무게 (g)' text: '무게 (g)'
@@ -433,6 +420,9 @@
document.getElementById('maxWeight').textContent = '0.0'; document.getElementById('maxWeight').textContent = '0.0';
document.getElementById('avgWeight').textContent = '0.0'; document.getElementById('avgWeight').textContent = '0.0';
// Arduino 측정 시간 초기화
sendCommand('t');
addLog('그래프 및 통계가 초기화되었습니다.'); addLog('그래프 및 통계가 초기화되었습니다.');
} }