当前位置:网站首页>Raspberry Pi information display small screen, display time, IP address, CPU information, memory information (C language), four-wire i2c communication, 0.96-inch oled screen
Raspberry Pi information display small screen, display time, IP address, CPU information, memory information (C language), four-wire i2c communication, 0.96-inch oled screen
2022-08-01 21:37:00 【Mr. alone】
0、前提:Raspberry Pi already haswiringPithis package andcmake,If no, please go(wiringPi参考链接)(cmake参考链接)参考链接自己安装
1、Connect the wires and turn on the Raspberry Pii2c
1.1、接线

Four wires usedoled gnd vcc scl sdaJust connect it
Specific wiring diagram as follows:

1.2、打开i2c
输入命令 sudo raspi-config,选择第3item start5项的i2c


2、Download what I wroteoled驱动代码GitHub链接:GitHub - ShangHTao/Raspberry-sysinfo-display: 树莓派i2cinterface driven0.96寸的oled显示屏,可以显示ip地址cpuOccupancy and temperature etc.
2.1For example, we first enter the desktop and perform the following operations
cd ~/Desktop
mkdir test
cd test/
git clone https://github.com/ShangHTao/Raspberry-sysinfo-displayThis creates atestinside the folderoled显示程序
2.2构建代码,执行下面的操作
cd Raspberry-sysinfo-display/
ls![]()
enter the commandCMakeCache.txtfile deletion abilitycmake
输入命令
rm CMakeCache.txt
cmake .
make
如图所示,constructed aoled_i2c_show_status的可执行程序
可以简单使用./oled_i2c_show_status执行一下看看oledWhether the corresponding content is displayed
It is recommended to run input commands in the background ./oled_i2c_show_status & (多加一个&)


3、设置开机自启动
问题1:在 /etc/rc.d/rc.local添加sudo nohup ~/oled_i2c_show_status &It will start automatically,But after a while the quest is killed it's not worth it why,Can someone please explain.
问题2:在~/.config文件中创建的autostart.desktopSet the boot to start automatically is also runningsudo nohup ~/oled_i2c_show_status &,Also back kills after running for a while,Does anyone with a good heart know??
ps:直接运行sudo nohup ~/oled_i2c_show_status &Can always run without being killed,为什么?
思考:我创建个shell脚本,然后开机自启动,在shell里面执行sudo nohup ~/oled_i2c_show_status &Is it possible not to be killed??
I know how to prevent system kill command and update again,Format and nothing to be adjusted later,There are still many errors,望指正.......(The above content is for Xiaobai to learnlinux的记录,It is a small white,欢迎大家交流,Students who need the original code can browse and make suggestions)
All of the above problems have been found,is due to the loop callpopen()function but error段错误,I can't solve it after looking for many reasons.
后面又使用fopen()Functions may indeed increase the background time to run,但是还是错误(报错too many open files,But obviously it has been usedfclose()function still error),very annoying.怀疑是fopen()It's a standard library function after all.,Then switch to system functionopen()依然报错too many open files,The clock reaches a certain level and kills the background.
Finally built ashell脚本(我起名为)Check if you have been killed,Execute again if killed,Otherwise, continue to check,具体内容如下:
#!/bin/sh
while :
do
if [ $(ps -ef | grep -c "oled_i2c_show_status") -lt 2 ];
then
$( /home/pi/autostart/oled_i2c_show_status &) ;
fi
sleep 60s
doneIndeed, it continued to execute when it was killed.oled_i2c_show_status,But sensory indicators don't cure the root cause.I'll try it later, if it workspython里的os.popen(),python调用c库函数.
4、python设计
等待更新....
边栏推荐
- 迁移学习——Discriminative Transfer Subspace Learning via Low-Rank and Sparse Representation
- Popular explanation: what is a clinical prediction model
- Interview Blitz 70: What are sticky packs and half packs?How to deal with it?
- Based on php Xiangxi tourism website management system acquisition (php graduation design)
- How to make the timer not execute when the page is minimized?
- 方舟:生存进化PVE模式和PVP模式
- WEB 渗透之端口协议
- 基于php影视资讯网站管理系统获取(php毕业设计)
- LeetCode·每日一题·1374.生成每种字符都是奇数个的字符串·模拟
- 如何优雅的性能调优,分享一线大佬性能调优的心路历程
猜你喜欢

shell编程规范与变量

Based on php animation peripheral mall management system (php graduation design)

CS-NP白蛋白包覆壳聚糖纳米颗粒/人血清白蛋白-磷酸钙纳米颗粒无机复合材料

Interview Blitz 70: What are sticky packs and half packs?How to deal with it?

第一讲 测试知多少

shell programming conventions and variables

如何优雅的性能调优,分享一线大佬性能调优的心路历程

空间数据库开源路,超图+openGauss风起禹贡

基于php在线音乐网站管理系统获取(php毕业设计)

Shell编程条件语句
随机推荐
LeetCode
Image fusion GANMcC study notes
SQL injection of WEB penetration
作业8.1 孤儿进程与僵尸进程
Appendix A printf, varargs and stdarg A.1 printf family of functions
C pitfalls and pitfalls Chapter 8 Suggestions and answers 8.2 Answers
Shell programming conditional statement
shell programming conventions and variables
C Pitfalls and Defects Chapter 7 Portability Defects 7.7 Truncation During Division
Day016 类和对象
sizeof的详细解说和与strlen的区别
C Pitfalls and Defects Chapter 7 Portability Defects 7.6 Memory Location 0
关于npm的那些事儿
MySQL related knowledge
JVM内存结构详解
回收租凭系统100%开源无加密 商城+回收+租赁
shell脚本
[Chinese tree tags - CTB]
Based on php tourism website management system acquisition (php graduation design)
基于php旅游网站管理系统获取(php毕业设计)