树莓派4B通过蓝牙连接墨水屏配置教程(Ubuntu环境)

无意间看到了这篇文章我Hack了一个蓝牙墨水屏,还挺好玩 (长期置顶) | 千里之豪的格物垛,发现可以将蓝牙墨水屏定时更新,就买了墨水屏进行试用。

作者开源了项目,代码在:GitHub - gadore/ink-screen-bluetooth: An script that can control a inkScreen with bluetooth protocol

本人环境是树莓派 4B,系统是 ubuntu
在部署的过程中,需要安装一些依赖,下面记录一下:

安装 node 环境

可以用 nvm 安装 18 左右的版本

sudo apt update
sudo apt install build-essential libssl-dev
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
source ~/.bashrc

nvm install 18
npm install -g yarn

安装依赖包

sudo apt install build-essential libssl-dev
sudo apt install libpixman-1-dev

安装项目依赖

git clone https://github.com/gadore/ink-screen-bluetooth.git
cd ink-screen-bluetooth
yarn
node app.js

在上面命令,到 yarn 这一步会报如下错:

  1. No package 'pixman-1' found
sudo apt install libpixman-1-dev
  1. No package 'cairo' found
    gyp: Call to 'pkg-config cairo --libs' returned exit status 1 while in binding. gyp. while trying to load binding. gyp gyp ERR! configure error
sudo apt install libcairo2-dev
  1. No package 'pangocairo' found
sudo apt install libpango1.0-dev
  1. make: Entering directory '/home/pi/ink-screen-bluetooth/node_modules/canvas/build'
make: Entering directory '/home/pi/ink-screen-bluetooth/node_modules/canvas/build' SOLINK_MODULE (target) Release/obj. target/canvas-postbuild. node gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] COPY Release/canvas-postbuild. node CXX (target) Release/obj. target/canvas/src/backend/Backend. o CXX (target)

看来你正在尝试编译 canvas 模块,并且过程遇到了某些依赖问题。为了确保所有必要的依赖都已安装,建议你按照以下步骤操作:
安装必要的开发库和工具:

sudo apt install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

至此再次运行 yarn 就可成功安装所有的依赖

启动项目

node app.js

运行之后,有个警告

noble warning: adapter state unauthorized, please run as root or with sudo or see README for information on running without root/sudo: https://github.com/sandeepmistry/noble#running-on-linux

在给出的链接中,可通过如下方式解决
image.png

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
sudo apt-get install libcap2-bin

修改代码中的设备名,这样才能连接到你的设备

image.png

在树莓派终端运行命令 bluetoothctl scan on,可找到 EPD-开头的设备。

在浏览器调用:`http://192.168.xxx.xxx:8080/notify? CPU=1&Memory=22&Disk=1&visitor=a `, `http://192.168.101.230:8080/nas?CPU=1&Memory=22&Disk=1&visitor=a`

恭喜全部完成,接下来你可以自己调整代码。


已发布

分类

作者:

标签

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注