当前位置:网站首页>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-display
This 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
done
Indeed, 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设计
等待更新....
边栏推荐
- shell specification and variables
- Anacoda的用途
- C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.3 The Standard I/O Library and the C Preprocessor
- Based on php hotel online reservation management system acquisition (php graduation project)
- scikit-learn no moudule named six
- [Chinese tree tags - CTB]
- 【力扣】字符串相乘
- LeetCode·每日一题·1374.生成每种字符都是奇数个的字符串·模拟
- Day33 LeetCode
- C Pitfalls and Defects Chapter 7 Portability Defects 7.11 An Example of a Portability Problem
猜你喜欢
C expert programming
NFT的10种实际用途(NFT系统开发)
Based on php online learning platform management system acquisition (php graduation design)
回收租凭系统100%开源无加密 商城+回收+租赁
Interview Blitz 70: What are sticky packs and half packs?How to deal with it?
Jmeter combat | Repeated and concurrently grabbing red envelopes with the same user
基于php旅游网站管理系统获取(php毕业设计)
LeetCode·每日一题·1374.生成每种字符都是奇数个的字符串·模拟
C语言_枚举类型介绍
Chapter 12, target recognition of digital image processing
随机推荐
MySQL related knowledge
scikit-learn no moudule named six
2022牛客多校联赛第五场 题解
【Objective-C中的@synthesize】
C Pitfalls and Defects Chapter 7 Portability Defects 7.8 Size of Random Numbers
Appendix A printf, varargs and stdarg A.3 stdarg.h ANSI version of varargs.h
AIDL通信
用户量大,Redis没法缓存响应,数据库宕机?如何排查解决?
基于php酒店在线预定管理系统获取(php毕业设计)
365 days challenge LeetCode1000 questions - Day 046 Generate a string with odd number of each character + add two numbers + valid parentheses
Homework 8.1 Orphans and Zombies
C Pitfalls and Defects Chapter 7 Portability Defects 7.7 Truncation During Division
基于php在线音乐网站管理系统获取(php毕业设计)
Spark练习题+答案
(七)《数电》——CMOS与TTL门电路
Jmeter combat | Repeated and concurrently grabbing red envelopes with the same user
C Pitfalls and pitfalls Appendix B Interview with Koenig and Moo
WEB渗透之SQL 注入
PyQt5 + MySQL5.8 【学生信息管理系统】【增删改查】
0DFS Medium LeetCode6134. Find the closest node to the given two nodes