适合覆盆子派的挂钟/天气预报http服务器
wallberry-uberpotato的Python项目详细描述
概要
一个简单、可扩展的web服务器,用于获取和记录天气信息,并在屏幕上显示良好。
依赖关系
- 预测
- Python瓶
- matplotlib
- w1热传感器(可选)
硬件
- 覆盆子皮
- DS18B20 1线温度传感器(可选)
设置
使用pip和virtualenv安装:
python3 -m virtualenv ~/wallberry
source ~/wallberry/bin/activate
pip install wallberry-uberpotato
需要一个暗黑的api密钥(从https://darksky.net/dev中释放)。
更改示例配置文件以包含密钥和位置。将配置文件另存为config.py
用法
通过运行sh wallberry/server.sh &
启动本地网络上的服务器
打开Web浏览器并导航到localhost:5000
对于挂钟,使用crontab和screen在启动时自动启动
sudo apt-get install screen
crontab -e
添加以下内容:
@reboot /usr/bin/screen -dmS Server /bin/sh ~/wallberry/server.sh
@reboot /bin/sh ~/wallberry/start.sh
0 7 * * * /bin/sh ~/wallberry/start.sh
0 23 * * * /bin/sh ~/wallberry/stop.sh
这将启动全屏信息亭浏览器,并从晚上11点到早上7点自动关闭屏幕。
还包括一个pir运动传感器的python脚本示例,用于自动打开和关闭屏幕
添加传感器
用post-reqst将温度、湿度和压力数据发送到/log
,格式为
{
name: <My Sensor Name>,
temperature: <Temp>, (optional)
humidity: <Humidity>, (optional)
pressure: <Pressure> (optional)
}
包含一个示例脚本weatherPOST.py
,供使用ds18b20传感器参考。要在RPI上设置此传感器:
正常模式:
将VDD连接到3.3V,数据连接到GPIO-4,接地,VDD和数据之间的上拉电阻器
添加到/boot/config.txt
中:
dtoverlay=w1-gpio,gpiopin=4
4是默认的w1 gpio引脚
添加到/etc/modules
中:
w1-gpio
w1-therm
寄生模式:
将VDD接地短路,数据连接到GPIO-4,VDD和数据之间的上拉电阻器
添加到/boot/config.txt
中:
dtoverlay=w1-gpio,gpiopin=4,pullup=1
添加到/etc/modules
中:
w1-gpio
w1-therm strong_pullup=2
调用w1thermsensor ls
列出所有连接的传感器的硬件地址
查看日志历史记录
对/log
的get请求生成日期范围选择和简单图