渗透之王 发表于 2019-9-4 11:35:15

Node-RED+ESP8266(tasmota)+LCD1602打造低成本提醒显示器

本帖最后由 渗透之王 于 2021-11-1 20:52 编辑

声音提醒虽然好,但有不适合的场景,比如,孩子在睡觉,突然播放音乐?播放开门提醒?自动背古诗?
也许你会和我一样,想要一个悄无声息的提醒器
1、准备材料:
硬件:nodemcu、LCD1602、IIC-1602转接板





OK,11.6+3.5+1.3,数学不好,不算了,当然还有USB线+5V充电器

软件:
node-red
nodemcu pyflasher
tasmota固件
2、烧写固件:这个不是重点,泛泛的截个操作图,
不放心还是说两个重点吧,
a:上电前nodemcu GPIO0要置低(flash按下)
b:选擦除全部固件
如果你一点都不懂,那在论坛搜索“刷Tasmota固件”
如果英文还不错,那我直接放出官方的说明书:https://github.com/arendst/Sonoff-Tasmota/wiki
How to start
You will need some tools to prepare your device for flashing Tasmota and connect it to your Wi-Fi network and MQTT broker.




3、配置端口并连接硬件



此时重启后,是不是看见时间显示了?对,这默认相当于是DIY一个电子时钟了。
(说句不该说的,既然是时钟,那时间一定要准,时区不对,串口发命令backlog Timezone 8更改时区,OK)

4、修改LCD显示模式
backlogDisplayMode 0
大功告成!
此时可以通过DisplayText命令显示字母了 是清除 是关屏幕 是开屏幕
DisplayText parametersIn the list below p stands for parameter and may be a number from 1 to n digits. On monochrome graphic displays things are drawn into a local frame buffer and sent to the display either via the dcommand or automatically at the end of the command.Positioninglp = sets a character line to print at (on LCD display p = {0…}, on TFT display p = {1…})
cp = sets a character column to print at (on LCD display p = {0…}, on TFT display p = {1…})
xp = sets the x position for consecutive prints
yp = sets the y position for consecutive printsText is printed at the last provided position, either l or y for the vertical position, and either x or x for the horizontal position. Neither x nor y are advanced/updated after printing text.Line primitiveshp = draws a horizontal line with length p (x is advanced)
vp = draws a vertical line with length p (y is advanced)
Lp:p = draws a line top:p (x,y are advanced)
kp = draws a circle with radius p
Kp = draws a filled circle with radius p
rp:p = draws a rectangle with p with and p height
Rp:p = draws a filled rectangle with p with and p height
up:p:p = draws a rounded rectangle with p with, p height and p radius
Up:p:p = draws a filled rounded rectangle with p with, p height and p radiusMiscellaneousz = clear the display
i = (re)init the display (in e-Paper mode with partial update)
I = (re)init the display (in e-Paper mode with full update)
d = update the display
Dp = switch display auto updates on(p=1)/off(p=0), when off display must be updated with d
o = switch display off
O = switch display on
ap = p (0..3) set rotation angle
t = display Tasmota time in HH:MM
tS = display Tasmota time in HH:MM:SS
T = display Tasmota date in DD.MM.YY
pp = pad text with spaces, positive values align left, negative values align right
sp = set text scaling for classic GFX font (scaling factor 1...N)
fp = set font (1=12, 2=24,(opt 3=8)) if font==0 the classic GFX font is used, if font==7 RA8876 internal font is used
Cp = set foreground color (0,1) for black or white and RGB decimal code for color
Bp = set background color (0,1) for black or white and RGB decimal code for color
Cip = set foreground index color (0..18) for color displays (see index color table below)
Bip = set background index color (0..18) for color displays (see index color table below)
wp = draws an analog watch with radius p (#define USE_AWATCH)
Pfilename: = display an rgb 16-bit color image when SD card file system is present

5、node-red流程

文字介绍流程,MQTT中转一下,将数据进行处理,并增加一连串操作。具体为:
a、当收到字符串时,点亮屏幕并显示,10S后背光熄灭,20S后文字清空,和断电状态一样
b、当字符串长度小于16时,在第1行居中显示,当长度大于16时,在第2行显示




放"字符串处理"代码:
var l=msg.payload.length;
var temp='                ';
if(l<=16)
{
    var kong_len=(16-l)/2;
    msg.payload = '' + temp.substring(0,kong_len)+msg.payload;
}
else
{
    msg.payload = ''+msg.payload.substring(0,16)+''+msg.payload.substring(16,32)
}
return msg;   


node-red流程导出,只需要修改成你自己的MQTT Broker 即可**** Hidden Message *****
效果展示:

放在桌面,键盘前,不会显得太乱,在办公时,屏幕亮自然会关注一下!


yueqiumao 发表于 2019-9-4 11:48:26

不错不错,,,,

komoya 发表于 2019-9-4 11:52:35

这个实用。关键物料我都还有:lol, 落灰2年了

natic 发表于 2019-9-4 15:20:12

非常实用,点个32个赞

qq200800704 发表于 2019-9-4 16:39:02

一斤猪肉六分之一的钱又可以快乐折腾了

zsyg 发表于 2019-9-4 18:29:59

谢谢分享

hanwei0708 发表于 2019-9-4 22:47:12

谢谢分享:D

tang5275 发表于 2019-9-5 10:37:54

用esp01 比较好,小巧

农本 发表于 2019-9-5 15:26:37

收藏学习

渗透之王 发表于 2019-9-5 19:21:32

tang5275 发表于 2019-9-5 10:37
用esp01 比较好,小巧

是的,esp01小巧,Nodemcu方便快捷
页: [1] 2 3 4 5 6 7 8 9
查看完整版本: Node-RED+ESP8266(tasmota)+LCD1602打造低成本提醒显示器