Giter Site home page Giter Site logo

raspberrypi_ht_statistics's Introduction

简介

网络上有很多实时显示树莓派测量的温湿度的例子,但作者没有找到采集数据并能够展示历史数据的现有轮子,于是就自己摸索弄了一个,现在发布出来供大家参考使用。

frp内网穿透后的项目地址:树莓派温湿度监控

概览

程序环境

  1. 树莓派(我的是 2B )

  2. DHT22 温湿度传感器(其它传感器比如DHT11需要修改一部分代码。推荐使用 DHT22 ,比 DHT11 精度高)

  3. python 3.5+ 、 mysql

  4. 导入相关库,例如: Adafruit_DHT 、 pymysql 、 flask 、 json 等。

运行指南

上述环境准备工作完成后,将本项目代码下载解压到树莓派中。

数据采集

  1. 新建数据库。使用 sql 目录下的 ht.sql 建立“温湿度采集表”

有需要的话可以使用 test 文件下的 TestConnect.py 、 TestSelect.py 测试数据表是否创建成功。

python3 TestConnect.py

  1. 第1步没有问题后,将 HtDataRecord.py 中的数据库配置修改成你自己的, 在树莓派 GPIO4 上插好传感器后,运行

python3 HtDataRecord.py

如果打印出温湿度,数据库也插入成功,继续进行下面的数据展示。

页面展示

修改 Server.py 中的数据库连接配置,并运行

python3 Server.py

在浏览器输入: http://树莓派ip:5000/ht/ 统计图能够展示,则表示部署成功。

开机启动

vi /etc/rc.local

参考 config/rc.local 的配置。

可能存在的问题及其它说明

  • 由于作者住在广州,温度最低是 5 摄氏度左右,不会有什么问题,未测试 0 度以下是否存在 bug 。

  • 采集频率目前设置为 5 分钟测量 1 次,你也可以设置成 1 分钟采集 1 次;如果设置其它采集频率例如 2 分钟、 3 分钟等,查询及展示那块代码需要修改。

  • 目前的查询策略是,查 1 天的数据支持查 5 分钟的颗粒精细度;7天之内则以30分钟为颗粒度; 30 天、180天以内则为 60 分钟。待数据增加后,计划开发自定义时间范围选择。查询的时间范围以及精细度由前端传入后台。“当前温湿度”的数据为每20秒请求一次后台更新。

  • 需要外网访问建议安装 ZeroTier(自己看) 或使用 frp 穿透 (所有人都可以看)。

raspberrypi_ht_statistics's People

Contributors

yeqizhang avatar

Stargazers

 avatar  avatar Enze-Li李恩泽 avatar  avatar  avatar kaihong avatar s0uth4 avatar  avatar  avatar Mushu Wang avatar  avatar  avatar Stonex avatar  avatar  avatar 。。。源 avatar 葉修齊 avatar  avatar  avatar  avatar  avatar  avatar 李绍丰 avatar  avatar 一刀 avatar spark5 avatar Alfred Bargeron avatar  avatar Calhoun avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

raspberrypi_ht_statistics's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.