weather-station/README.md

48 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 气象站数据接收系统
UDP接收气象站数据存PostgreSQL。
## 数据库字段转换
### 温度
- `temp_f`, `dewpoint_f`, `windchill_f`, `indoor_temp_f`: 存储值=实际值×10 (°F)
### 湿度
- `humidity`, `indoor_humidity`: 直接存整数百分比 (%)
### 风速
- `wind_dir`: 直接存角度 (°)
- `wind_speed_mph`, `wind_gust_mph`: 存储值=实际值×100 (mph)
### 降雨量
- 所有rain字段: 存储值=实际值×1000 (英寸)
### 气压
- `abs_barometer_in`, `barometer_in`: 存储值=实际值×1000 (英寸汞柱)
### 其他
- `solar_radiation`: 存储值=实际值×100 (W/m²)
- `uv`: 直接存整数
- `low_battery`: 布尔值
## 单位转换
- 华氏→摄氏: (°F - 32) * 5/9
- 英里→公里: mph * 1.60934
- 英寸→毫米: in * 25.4
- 英寸汞柱→百帕: inHg * 33.8639
## 查询示例
```sql
SELECT
station_id,
timestamp AT TIME ZONE 'Asia/Shanghai' as local_time,
temp_f::float/10 as temp_f,
(temp_f::float/10 - 32) * 5/9 as temp_c,
humidity,
wind_speed_mph::float/100 as wind_speed_mph,
barometer_in::float/1000 * 33.8639 as barometer_hpa
FROM weather_data
ORDER BY timestamp DESC
LIMIT 10;
```