diff --git a/README.md b/README.md index 60de35f..fcdbe85 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,122 @@ -# WiFi天气微站 +# WS2 桌面气象站 -esp8266版天气信息显示设备 +([English](README_en.md) | 中文) +基于ESP8266的桌面气象站,能够实时显示天气信息、环境数据和时间。 + +![WS2气象站](docs/ws2.jpg) + +## 功能特点 + +- 🌤️ **实时天气显示**:获取并显示当前天气状况、温度、湿度和空气质量 +- 📺 **TFT LCD彩色显示**:1.54寸240x240像素彩色液晶屏 +- 🕐 **多种显示模式**:支持多种UI界面,包括天气时钟和电子相册模式 +- 🌐 **Web管理界面**:内置轻量级Web服务器,支持浏览器配置和管理 +- 📊 **系统监控**:实时显示设备状态、内存使用和网络信息 +- 📡 **WiFi连接**:支持2.4GHz WiFi网络,自动重连机制 + +## 硬件规格 + +- **主控芯片**:ESP8266/ESP32 +- **显示屏**:1.54寸 TFT LCD 240×240像素 +- **网络**:802.11 b/g/n WiFi + +## 软件架构 + +本项目基于MicroPython开发,包含以下核心模块: + +- **app.py** - 主应用程序 +- **config.py** - 配置管理 +- **wifi_manager.py** - WiFi连接管理 +- **display.py** - 显示屏控制 +- **nanoweb.py** - 轻量级异步Web服务器 +- **captive_portal.py** - 配置门户 + +## 快速开始 + +1. 购物网站搜: WiFi天气时钟 +> 务必与商家确认可以通过usb下载固件 + +2. 连接设备usb,下载完整版固件到ESP8266 + ```bash + esptool.py --port /dev/ttyUSB0 --baud 460800 write-flash --flash-size=detect 0 firmware.bin + ``` + +### 初次配置 + +1. 设备启动后会创建WiFi热点 `WS2-xxxx` +2. 连接该热点,浏览器会自动跳转访问 `192.168.4.1` +3. 在配置页面输入WiFi信息 +4. 设备将自动连接并获取天气信息 + +## Web管理界面 + +设备Web界面提供以下功能: + +### 设备状态 +- 查看系统运行状态、内存使用情况 +- 监控设备IP地址和运行时间 +- 实时显示UUID和固件版本 + +### 屏幕显示 +- 调节屏幕亮度 +-切换显示模式 +- LCD内容预览 + +### 系统配置 +- 选择城市和地区 +- 设置自动熄屏时间 +- 保存/加载配置 + +### 高级设置 +- 执行系统命令 +- 查看MAC地址 +- 重启设备 +- 清空配置 ## API接口 -1. /ping +设备提供RESTful API接口,可通过HTTP请求获取数据: -2. /status +``` +GET /lcd - 获取LCD设置 +GET /status - 获取系统状态 +GET /config - 获取配置信息 +POST /exec - 执行系统命令 {cmd: "命令内容", token: "认证令牌"} +POST /lcd/set - 设置LCD参数 {brightness: 80, ui_type: "default"} +POST /config/set - 设置配置 {city: "北京", standby_time: "22:00"} +``` -3. /weather - /weather/?city=xxx&force=1 +## 开发指南 -4. /lcd +1. 修改/src/rom下相关文件,使用mpremote romfs更新 +2. 自行编译micropython固件需要集成*st7789py_mpy*(未整理) -5. /lcd/set, POST +## 故障排除 -6. /exec, POST +### 常见问题 -```sh - # read memory free - > *curl -H "Content-Type: application/json" -X POST -d '{"cmd":"import gc;gc.collect();R=gc.mem_free()", "token":"c6b74200"}' http://192.168.99.194/exec* +**Q: 设备无法连接WiFi** +A: 检查WiFi密码是否正确,或重启设备重新配置 - # reset - > *curl -H "Content-Type: application/json" -X POST -d '{"cmd":"import machine; machine.reset()", "token":"c6b74200"}' http://192.168.99.194/exec* +**Q: 天气数据不更新** +- A1: 检查网络连接,或尝试强制刷新天气数据 +- A2: 个人的天气服务器失联~ +## 许可证 -## 参考资料 -[MicroPython remote control: mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) +本项目采用MIT许可证 + +## 致谢 + +- [MicroPython](https://micropython.org/) - 高效的Python微控制器实现 +- [ST7789驱动](https://github.com/devbis/st7789py_mpy) - LCD显示屏驱动 +- [captive-portal](https://github.com/anson-vandoren/esp8266-captive-portal) - 认证门户 +- [Nanoweb](https://github.com/hugokernel/micropython-nanoweb) - 轻量级异步Web服务器 +- [mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) - mp控制终端 + +## 联系方式 + +- 项目主页: https://github.com/kicer/ws2 +- 项目主页: https://iot.foresh.com/git/kicer/ws2 +- 问题反馈: https://github.com/kicer/ws2/issues diff --git a/README_en.md b/README_en.md new file mode 100644 index 0000000..db8191c --- /dev/null +++ b/README_en.md @@ -0,0 +1,122 @@ +# WS2 Desktop Weather Station + +(English | [中文](README.md)) + +An ESP8266-based desktop weather station capable of displaying real-time weather information, environmental data, and time. + +![WS2 Weather Station](docs/ws2.jpg) + +## Features + +- 🌤️ **Real-time Weather Display**: Get and display current weather conditions, temperature, humidity, and air quality +- 📺 **TFT LCD Color Display**: 1.54-inch 240x240 pixel color LCD screen +- 🕐 **Multiple Display Modes**: Support for various UI interfaces, including weather clock and photo album modes +- 🌐 **Web Management Interface**: Built-in lightweight web server supporting browser configuration and management +- 📊 **System Monitoring**: Real-time display of device status, memory usage, and network information +- 📡 **WiFi Connectivity**: Support for 2.4GHz WiFi networks with automatic reconnection + +## Hardware Specifications + +- **Main Controller**: ESP8266/ESP32 +- **Display**: 1.54-inch TFT LCD 240×240 pixels +- **Network**: 802.11 b/g/n WiFi + +## Software Architecture + +This project is developed based on MicroPython and includes the following core modules: + +- **app.py** - Main application +- **config.py** - Configuration management +- **wifi_manager.py** - WiFi connection management +- **display.py** - Display screen control +- **nanoweb.py** - Lightweight asynchronous web server +- **captive_portal.py** - Configuration portal + +## Quick Start + +1. Search for "WiFi Weather Clock" on shopping websites +> Make sure to confirm with the seller that firmware can be downloaded via USB + +2. Connect the device via USB and download the complete firmware to ESP8266 + ```bash + esptool.py --port /dev/ttyUSB0 --baud 460800 write-flash --flash_size=detect 0 firmware.bin + ``` + +### Initial Configuration + +1. The device creates a WiFi hotspot named `WS2-xxxx` upon startup +2. Connect to this hotspot and the browser will automatically redirect to `192.168.4.1` +3. Enter WiFi information on the configuration page +4. The device will automatically connect and fetch weather information + +## Web Management Interface + +The device web interface provides the following features: + +### Device Status +- View system running status and memory usage +- Monitor device IP address and uptime +- Real-time display of UUID and firmware version + +### Screen Display +- Adjust screen brightness +- Switch display modes +- LCD content preview + +### System Configuration +- Select city and region +- Set auto-sleep time +- Save/load configuration + +### Advanced Settings +- Execute system commands +- View MAC address +- Restart device +- Clear configuration + +## API Interface + +The device provides RESTful API interfaces, accessible via HTTP requests: + +``` +GET /lcd - Get LCD settings +GET /status - Get system status +GET /config - Get configuration information +POST /exec - Execute system commands {cmd: "Command content", token: "Authentication token"} +POST /lcd/set - Set LCD parameters {brightness: 80, ui_type: "default"} +POST /config/set - Set configuration {city: "Beijing", standby_time: "22:00"} +``` + +## Development Guide + +1. Modify relevant files in /src/rom directory and use mpremote romfs to update +2. Custom compilation of MicroPython firmware requires integration of *st7789py_mpy* (not organized yet) + +## Troubleshooting + +### Common Issues + +**Q: Device cannot connect to WiFi** +A: Check if the WiFi password is correct, or restart the device to reconfigure + +**Q: Weather data doesn't update** +- A1: Check network connection or try force-refreshing weather data +- A2: Personal weather server may be offline~ + +## License + +This project is licensed under the MIT License + +## Acknowledgments + +- [MicroPython](https://micropython.org/) - Efficient Python implementation for microcontrollers +- [ST7789 Driver](https://github.com/devbis/st7789py_mpy) - LCD display driver +- [captive-portal](https://github.com/anson-vandoren/esp8266-captive-portal) - Captive portal +- [Nanoweb](https://github.com/hugokernel/micropython-nanoweb) - Lightweight asynchronous web server +- [mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) - MicroPython control terminal + +## Contact + +- Project Homepage: https://github.com/kicer/ws2 +- Project Homepage: https://iot.foresh.com/git/kicer/ws2 +- Issue Tracker: https://github.com/kicer/ws2/issues diff --git a/docs/ws2.jpg b/docs/ws2.jpg new file mode 100644 index 0000000..b86f681 Binary files /dev/null and b/docs/ws2.jpg differ