当前位置:网站首页>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设计
等待更新....
边栏推荐
- C语言_枚举类型介绍
- Based on php tourism website management system acquisition (php graduation design)
- C Pitfalls and Defects Chapter 7 Portability Defects 7.9 Case Conversion
- Shell programming conditional statement
- Appendix A printf, varargs and stdarg A.1 printf family of functions
- Small program -- subcontracting
- Get started with Grafana in 15 minutes
- Jmeter combat | Repeated and concurrently grabbing red envelopes with the same user
- 基于php在线学习平台管理系统获取(php毕业设计)
- Spark shuffle tuning
猜你喜欢

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

MySQL相关知识

C语言_联合体共用体引入

Based on php online examination management system acquisition (php graduation design)

基于php湘西旅游网站管理系统获取(php毕业设计)

方舟生存进化是什么游戏?好不好玩

测试开发人均年薪30w+?软件测试工程师如何进阶拿到高薪?

左旋氧氟沙星/载纳米雄黄磁性/As2O3磁性Fe3O4/三氧化二砷白蛋白纳米球

Homework 8.1 Orphans and Zombies
![[Chinese tree tags - CTB]](/img/f4/b985da2ff83b2a9ab4eebb8bd060bf.png)
[Chinese tree tags - CTB]
随机推荐
C Pitfalls and Defects Chapter 7 Portability Defects 7.6 Memory Location 0
JVM内存结构详解
Appendix A printf, varargs and stdarg a. 2 use varargs. H to realize the variable argument list
微软校园大使喊你来秋招啦!
ORI-GB-NP半乳糖介导冬凌草甲素/姜黄素牛血清白蛋白纳米粒的研究制备方法
Spark集群搭建
shell programming conventions and variables
CS-NP白蛋白包覆壳聚糖纳米颗粒/人血清白蛋白-磷酸钙纳米颗粒无机复合材料
【Objective-C中的@synthesize】
【Unity实战100例】文件压缩Zip和ZIP文件的解压
方舟:生存进化官服和私服区别
Spark shuffle调优
你居然不懂Bitmap和Drawable? 相关知识大扫盲
HCIP---多生成树协议相关知识点
C pitfalls and pitfalls Chapter 7. Portability pitfalls 7.10 Free first, then realloc
Based on php film and television information website management system acquisition (php graduation design)
数据库练习
【力扣】字符串相乘
10 Practical Uses of NFTs (NFT System Development)
ISC2022 HackingClub white hat summit countdown 1 day!Most comprehensive agenda formally announced!Yuan universe, wonderful!