dht11-temp

TotalClaw 作者 totalclaw

从 DHT11 传感器读取温度和湿度。通过 CLI 参数或环境变量支持自定义 GPIO 引脚。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~noahseeger-dht11-temp
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~noahseeger-dht11-temp/file -o noahseeger-dht11-temp.md
# DHT11 Temperature & Humidity Sensor

Read temperature and humidity from a DHT11 sensor.

## Hardware Setup

**Wiring (adjust pin as needed):**
```
DHT11 Pinout:
─────────────
1. VCC     → 5V (Pin 2 oder 4)
2. DATA    → GPIO <PIN> + 10K Pull-Up Widerstand → 5V
3. GND     → GND (Pin 6)
```

**Important:** The 10K pull-up resistor must be connected between DATA and VCC (5V)!

## Installation

```bash
# Install dependencies
pip3 install RPi.GPIO
```

## Usage

### Read Sensor (default pin 19)
```bash
sudo python3 scripts/dht/main.py
```

### Read Sensor (custom pin)
```bash
sudo python3 scripts/dht/main.py 4     # Uses GPIO 4
```

### Using Environment Variable
```bash
export DHT_PIN=4
sudo python3 scripts/dht/main.py
```

## Output

- Line 1: Temperature (°C)
- Line 2: Humidity (%)

## Customization

| Variable | Default | Description |
|----------|---------|-------------|
| DHT_PIN | 19 | GPIO pin number |

## Example crontab entry

```bash
# Read every 30 minutes
*/30 * * * * sudo python3 ~/scripts/dht/main.py >> /var/log/dht.log 2>&1
```

---

## 中文说明

# DHT11 Temperature & Humidity Sensor

从 DHT11 传感器读取温度和湿度。

## 硬件连接

**接线(按需调整引脚):**
```
DHT11 Pinout:
─────────────
1. VCC     → 5V (Pin 2 oder 4)
2. DATA    → GPIO <PIN> + 10K Pull-Up Widerstand → 5V
3. GND     → GND (Pin 6)
```

**重要:** 10K 上拉电阻必须连接在 DATA 和 VCC(5V)之间!

## 安装

```bash
# Install dependencies
pip3 install RPi.GPIO
```

## 用法

### 读取传感器(默认引脚 19)
```bash
sudo python3 scripts/dht/main.py
```

### 读取传感器(自定义引脚)
```bash
sudo python3 scripts/dht/main.py 4     # Uses GPIO 4
```

### 使用环境变量
```bash
export DHT_PIN=4
sudo python3 scripts/dht/main.py
```

## 输出

- 第 1 行:温度(°C)
- 第 2 行:湿度(%)

## 自定义

| Variable | Default | Description |
|----------|---------|-------------|
| DHT_PIN | 19 | GPIO 引脚编号 |

## crontab 条目示例

```bash
# Read every 30 minutes
*/30 * * * * sudo python3 ~/scripts/dht/main.py >> /var/log/dht.log 2>&1
```