基于树莓派的蓝牙出勤追踪系统

2023-05-16

本文介绍一个基于树莓派的蓝牙出勤追踪系统,用于记录和监督自己的工作时长情况。
代码与安装指引已更新在GitHub上:树莓派蓝牙出勤追踪系统。

该系统使用树莓派扫描附近的蓝牙或蓝牙低功耗设备,以无感方式收集出勤信息。信息将被存储在InfluxDB中,并通过Grafana的Dashboard使数据可视化。

我使用APScheduler设置定时事件,往数据库中插入一个异常值,来触发Grafana的报警,向邮箱发送每日报告。

系统目前支持多个蓝牙设备(蓝牙或BLE)的同时扫描与记录,便于多人使用。多人使用时,需要在代码中增加对应的scheduler。

此系统还可为树莓派在其他物联网场景的应用提供支持。

欢迎star与fork。

【附安装指引】

RPi Bluetooth Attendance Information Collection System

This system helps collect attendance information in a non-inductive way by scanning the nearby Bluetooth or BLE device using Raspberry Pi.

The system stores information in InfluxDB and makes the information observable via Grafana.

The Daily report is also supported.

Installation

1. Clone the repository

cd ~
git clone https://github.com/forskamse/RPi-Bluetooth-Attendance-Information-Collection-System.git

2. System dependencies

[Hardware: Raspberry Pi 4 - 4G RAM Version]
[OS: Raspbian GNU/Linux 10 (buster)]
[HCI Tool: V5.50]
[Influx DB: V1.6.4]
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt install influxdb influxdb-client
[Grafana V6.6.0]
wget https://dl.grafana.com/oss/release/grafana_6.6.0_armhf.deb
sudo dpkg -i grafana_6.6.0_armhf.deb
[Grafana Rendering Plugin]
wget https://nodejs.org/dist/v12.16.0/node-v12.16.0-linux-armv7l.tar.xz
sudo ln -s /home/pi/Projects/node-v12.16.0-linux-armv7l/bin/node /usr/bin/node
sudo ln -s /home/pi/Projects/node-v12.16.0-linux-armv7l/bin/npm /usr/bin/npm
npm -g install yarn
npm -g install typescript
sudo ln -s /home/pi/Projects/node-v12.16.0-linux-armv7l/bin/tsc /usr/bin/tsc
sudo ln -s /home/pi/Projects/node-v12.16.0-linux-armv7l/bin/yarn /usr/bin/yarn
# You should change to root and run the following commands.
su root
cd /var/lib/grafana/plugins/
git clone https://github.com/grafana/grafana-image-renderer.git
cd grafana-image-renderer
make deps
make build
sudo apt install chromium-browser chromium-chromedriver
cd /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-706915/chrome-linux/    # here pls check whether your chrome version number is 706915 or not
mv chrome chrome.bak
cp /usr/bin/chromium-browser /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-706915/chrome-linux/chrome
cd ~

3. Python dependencies

Since BLE scanning requires system permission, using system python3 environment is highly recommended. Otherwise you might suffer from some issues on module searching when running the code with sudo permission.

sudo pip3 install influxdb apscheduler -i https://pypi.tuna.tsinghua.edu.cn/simple/

Configuration

1. Code modification

  • RPi-Bluetooth-Attendance-Information-Collection-System.py

    On considering the security, just write [your_db_pwd] into a txt file.

    Change [your_db_user].

    Change target device names(targetDevName, data type: list) and target device addresses(targetDevAddrs, data type: list). You can put both ‘Bluetooth’ and ‘BLE’ device addresses in targetDevAddrs.

    Set triggers individually for each target device name if necessary. As a reminder, you should check whether your machine time and local time are consistant.

  • start-when-power-on.sh

    Change /path/to/your/Project.

2. InfluxDB configuration

sudo systemctl unmask influxdb.service
sudo systemctl enable influxdb
sudo systemctl start influxdb

Enter influxdb cli mode(by runing ‘influx’ on shell):

CREATE USER [your_db_user] WITH PASSWORD [your_db_pwd] WITH ALL PRIVILEGES
CREATE DATABASE attendanceInformation

3. Grafana configuration

## Start grafana-image-renderer server in the background
cd /var/lib/grafana/plugins/grafana-image-renderer/
nohup node build/app.js server --port=8081 &
## Edit grafana config file
sudo nano /etc/grafana/grafana.ini
#######################################
[smtp]
enabled = true
host = [your_email_smtp_host]
user = [your_email_address]
password = [your_email_passwd]
from_address = [your_email_address]
from_name = Grafana
;For example: 
;[your_email_smtp_host]: smtp.qq.com:465
;[your_email_address]: xxx@qq.com
[rendering]
server_url = http://localhost:8081/render
callback_url = http://localhost:3000/
#######################################
## Enable and start grafana server
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server
sudo systemctl start grafana-server

Run ‘hostname -I’ for [your_host_address].

Visit http://[your_host_address]:3000/.
Change admin password when first login with username as ‘admin’ and password as ‘admin’.

Create a dashbord and add data source InfluxDB with [your_db_user] and [your_db_pwd].

Set up query rules:

Some additional query settins help with data observability and default image rendering time range:

Set up alert rules:

‘Evaluate every’ determines the intervals when the rule is evaluated. ‘For’ determines the pending duration after the alert rule was triggered.

Set up notification channels:

Here ‘Include image’ determines whether to send a rendered image or not. ‘Disable Resolve Message’ prevents from sending another [OK] alerting email once the former alerting situation was resolved.

4. Boot from power on

## Add configuration before "exit 0"
sudo nano /etc/rc.local
########################################################
/bin/bash /path/to/your/Project/start-when-power-on.sh
########################################################

Running

cd /path/to/your/Project/
nohup sudo python3 RPi-Bluetooth-Attendance-Information-Collection-System.py >> RpiAttendance.log &

Reference

https://pimylifeup.com/raspberry-pi-grafana/

https://github.com/grafana/grafana-image-renderer/blob/master/docs/building_from_source.md

https://github.com/grafana/grafana-image-renderer/issues/7

https://grafana.com/docs/grafana/latest/administration/image_rendering/

https://community.openhab.org/t/tutorial-grafana-rendering-on-raspberry-pi/71777

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

基于树莓派的蓝牙出勤追踪系统 的相关文章

  • python 把文件夹及子文件夹内的所有文件移动到指定文件夹中

    python 把文件夹及子文件夹内的所有文件移动到指定文件夹中 1 提取路径下所有文件到指定文件夹下 import shutil import os def move files source dest for root dirs file
  • vscode 中文乱码(解决方法)

    vscode一次自动更新后 xff0c 发现中文乱码了 查看了网上的解答 xff0c 记录一种解决方法 切换右下角任务栏的编码方式 xff0c UFT gt GB2312 或下拉GBK xff0c 如下图 xff1a
  • max_element() 和 min_element()

    找出容器中的最值 vector和数组都可以 一维的数据可以 多维的还没找到方法 xff0c 可能是不行的 完整代码 xff1a include lt iostream gt include lt vector gt include lt a
  • C/C++ 提取字符串中的指定位置(截取字符串、提取字符串)

    版权声明 xff1a 转载需标明该文链接 https blog csdn net zaibeijixing article details 88721195 一 利用C 43 43 自带字符串函数 xff1a int a 61 str fi
  • 树莓派-从入手到使用(一):树莓派入手操作第一步

    新组装的电脑硬盘显卡什么都有 xff0c 把window或linux系统安装在硬盘上就能开机使用了 树莓派没硬盘 xff0c 因此需要加个内存卡当硬盘 xff0c 另外要给这个硬盘上安装系统 xff0c 才能用 本人的是Raspberry
  • jupyter notebook 中运行.py文件

    jupyter notebook页面 xff0c 在需要运行的name py文件目录页面中 xff0c 新建python文件 xff0c 打开 xff0c 在cell中添加如下命令 xff1a run name py 运行该cell即可 根
  • 直方图均衡化及算法步骤

    2019 07 16 xff0c 科学家首次拍摄到一种量子纠缠的照片 量子领域还不懂 xff0c 先不研究 猛一看和今年刚出的黑洞照片倒有几分相似 黑洞照片看起来还是比较清晰地 xff0c 这个是黑白的 xff0c 亮度不均 xff0c 肉
  • 解决mongodb启动报错ERROR: child process failed, exited with error number 14的问题

    在使用mongodb导入数据时 xff0c 数据库无法链接 xff0c 关闭service 后仍然无法启动 可能的原因 xff1a service mongodb restart时启动失败没有正常关闭mongodb引起的 xff0c 比如直
  • 面向对象分析(4):步骤

    面向对象分析通常按照下面的步骤来进行 xff1a xff08 1 xff09 标识对象和类 可以从应用领域开始 xff0c 逐步确定形成整个应用的基础类和对象 这一步需要分析领域中目标系统的责任 xff0c 调查系统的环境 xff0c 从而
  • NTFS for Mac - 免费让 Mac 原生支持NTFS读写

    使用 Mac 电脑的朋友可能都遇过 xff0c 在使用 NTFS 文件格式的移动硬盘或U盘时 xff0c 默认只能以 只读 模式打开 xff0c 也就是说你只能读取复制文件而不能移动 修改 重命名或删除里面的东西 这确实很不便 xff0c
  • C++ 将十六进制字符串转换为二进制字符串

    C 43 43 将十六进制字符串转换为二进制字符串 前言一 源代码 前言 一种简单的方法将十六进制字符串转为二进制字符串 xff0c 不限制十六进制的字节数 一 源代码 传入的十六进制字符串需要转换为大写 xff01 X toupper s
  • python——paramiko详解

    目录 一 SSHClient类 ssh远程连接服务器 connet 远程主机没有本地主机密钥或HostKeys对象时的连接方法 xff0c 需要配置set missing host key policy policy 远程执行命令 在远程服
  • 绿盟网站安全防护服务(vWAF)

    平台 xff1a linux 类型 xff1a 虚拟机镜像 软件包 xff1a basic software devops nsfocus security waf 服务优惠价 按服务商许可协议 云服务器费用 查看费用 立即部署 产品详情
  • 华为服务器操作系统EulerOS V2.0

    平台 xff1a linux 类型 xff1a 虚拟机镜像 软件包 xff1a java 1 8 0 php 5 4 16 python 2 7 5 qt 4 8 5 tomcat 7 0 69 basic software euleros
  • 星环一站式大数据平台-4.6

    平台 xff1a arm 类型 xff1a ARM 模板 软件包 xff1a 星环一站式大数据平台 basic software big data hadoop tdh tos transwarp 大数据 星环科技 星环一站式大数据平台 云
  • 故障排除:无法启动、访问或连接到 Azure 虚拟机上运行的应用程序

    有多种原因可导致无法启用或连接到在 Azure 虚拟机 VM 上运行的应用程序 原因包括应用程序未在预期端口上运行或侦听 侦听端口受到阻止 xff0c 或网络规则未将流量正确传递到应用程序 本文说明有条理地找到问题并更正问题 如果在使用 R
  • 文件系统损坏导致虚拟机无法正常启动的问题及解决方法

    简介 计算机的文件系统是一种存储和组织计算机数据的方法 xff0c 它使得对其访问和查找变得容易 xff0c 文件系统使用文件和树形目录的抽象逻辑概念代替了硬盘和光盘等物理设备使用数据块的概念 xff0c 用户使用文件系统来保存数据不必关心
  • 连接到 Azure (Resource Manager) 上的 SQL Server 虚拟机

    概述 本主题介绍如何连接到运行于 Azure 虚拟机的 SQL Server 实例 它介绍了一些常规连接方案 xff0c 并提供了在 Azure VM 中配置 SQL Server 连接的详细步骤 Note Azure 具有用于创建和处理资
  • 网络安全组(NSG)简介

    韩源 xff0c 资深工程师 xff0c 存储和灾备专家 Azure 网络安全解析 作为公有云最重要环节之一 xff0c 网络安全一直是 Azure 的重中之重 在 Azure 中 xff0c 多种安全技术共同构成了立体的网络保护 xff1
  • gnome manjaro设置无法打开

    本文转载自 xff1a https joshtronic com 2018 04 02 unable to open gnome settings on arch linux after gnome upgrade 我经常会写关于主题的博客

随机推荐

  • 手动将经典 VM 从 VHD 迁移到新的 ARM 托管磁盘 VM

    本部分有助于将现有 Azure VM 从经典部署模型迁移到资源管理器部署模型中的托管磁盘 计划迁移到托管磁盘 本部分可帮助你针对 VM 和磁盘类型做出最佳决策 位置 选取 Azure 托管磁盘可用位置 如果要迁移到高级托管磁盘 xff0c
  • 适用于 Azure 虚拟网络的常见 PowerShell 命令

    如果想要创建虚拟机 xff0c 需要创建虚拟网络或了解可在其中添加 VM 的现有虚拟网络 通常情况下 xff0c 创建 VM 时 xff0c 还需考虑创建本文所述资源 有关安装最新版 Azure PowerShell 选择订阅和登录到帐户的
  • 创建包含多个子网的虚拟网络

    本教程介绍如何创建包含独立公共子网和专用子网的基本 Azure 虚拟网络 虚拟网络中的资源可以彼此通信 xff0c 并可以与连接到虚拟网络的其他网络中的资源通信 可在虚拟网络中相同或不同的子网中创建 Azure 资源 xff0c 如虚拟机
  • matplotlib笔记

    文章目录 matplotlib笔记cmap选择cmap创建cmap 子图断点轴 Broken axis 子图大小 坐标轴scale matplotlib笔记 有一个在线使用matplotlib的网址 cmap 选择cmap choose c
  • Fortran pgplot安装

    pgplot 首先确保已经安装了gfortran 以下为linux下安装流程 从这里下载安装包解压tar zxvf pgplot5 2 tar gz到某个目录比如 src pgplot创建一个文件夹xxx pgplot用于安装 xff0c
  • CUDA和Compute Capability

    CUDA Enabled GPUs Cuda支持的GPU 在这个参考包含了GPU的Compute Capacity列表 比如我的笔记本搭载了一块Geforce830m xff0c 查询列表就可以发现如下图 那么这块830M GPU的Comp
  • Javascript笔记

    数据类型 基本类型 primitive value 简单的数据段 xff0c 包括 Undefined Null Boolean Number String初始化只使用2原始字面量形式 xff0c 如果使用new则会创建Object无法加入
  • 前端面试题笔记

    前端面试八股 发现了一个地方包含了很多前端面试八股 1 用户喜好 为了不断优化推荐效果 xff0c 今日头条每天要存储和处理海量数据 假设有这样一种场景 xff1a 我们对用户按照它们的注册时间先后来标号 xff0c 对于一类文章 xff0
  • Matlab:数据写入Excel

    使用xlswrite 可以help xlswrite查看用法 xlswrite filename A xlswrite filename A sheet xlswrite filename A xlRange xlswrite filena
  • python处理FITS 1:astropy介绍与安装

    1 1介绍 astropy是一个开源的python库 xff0c 专门用于处理天文方面的数据 astropy包是Astropy 项目的内核 xff0c 这个项目致力于发展一个鲁棒性较好的伴随子包 xff08 能兼容优秀的astropy这个库
  • 使用sublime编译运行C程序

    1 打开sublime xff0c 找到顶部工具 xff08 Tool xff09 菜单 gt 编译系统 xff08 Build System xff09 gt 新编译系统 xff08 New Build System xff09 xff1
  • python处理FITS文件 2:astropy.io.fits介绍及打开FITS文件

    astropy这个库有很多功能 xff0c 因为本文主要涉及FITS文件 xff0c 因此仅仅使用astropy io fits 1介绍 astropy io fits包提供FITS文件操作的函数接口 xff0c 使得用户可以忽略FITS文
  • python处理FITS 3:处理头文件和数据单元

    1头文件处理 在获得hdul后 xff0c 可以使用两个属性 header data分别获得头文件和数据单元 gt gt gt hdul 61 fits span class hljs built in open span fits ima
  • Django使用pip安装

    1 pip安装 pip是python的包管理器 xff0c 使用这个工具可以很轻松安装各种python库 直接运行 pip install django 然后就可以安装了 1 1安装问题 输入 pip install django 报错 x
  • 内网穿透方式

    ssh 内网中的机器A 需要访问内网中的c 64 C 公网中的机器B xff0c 用户名b 内网中的机器A ssh CNR 7280 C 22 b 64 B 公网中的机器B ssh fCNL 7279 localhost 7280 loca
  • vue笔记

    rollup 专注于JavaScript打包不包含无关代码 对比webpack tree shaking 最开始由rollup实现 xff0c 之后被webpack借鉴配置output format xff0c 选择输出资源的模块形式 xf
  • geant4学习

    文章目录 配置vscode configuration materialgeant4的类及成员函数physicsList选择构建Physics List 粒子粒子类型能量损失重子和离子 杂项getEnergyoptical photon的速
  • C++枚举与字符串转换工具类

    C 43 43 枚举与字符串转换工具类 最近需要一个能够在字符串和枚举值之间互相转换的功能 xff0c 因为C 43 43 没有对枚举值进行遍历 反射之类的操作 xff0c 不像Java那样可以轻松搞定 网上找到一些代码感觉用起来有点不爽
  • iOS 使用xmpp做聊天客户端

    可以号称史上最详细的xmpp做iOS客户端聊天介绍 简介 xff1a XMPP协议是一种基于Socket长连接 以XML格式进行基本信息交换 C S S S多种架构的聊天协议 XMPPServer 基于XMPP协议的服务端 例如eJabbe
  • 基于树莓派的蓝牙出勤追踪系统

    本文介绍一个基于树莓派的蓝牙出勤追踪系统 xff0c 用于记录和监督自己的工作时长情况 代码与安装指引已更新在GitHub上 xff1a 树莓派蓝牙出勤追踪系统 该系统使用树莓派扫描附近的蓝牙或蓝牙低功耗设备 xff0c 以无感方式收集出勤