当前位置:网站首页>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设计
等待更新....
边栏推荐
- 小程序--分包
- LeetCode
- NFT的10种实际用途(NFT系统开发)
- Unity Shader 常规光照模型代码整理
- ORI-GB-NP半乳糖介导冬凌草甲素/姜黄素牛血清白蛋白纳米粒的研究制备方法
- [Chinese tree tags - CTB]
- ModuleNotFoundError: No module named 'yaml'
- An online JVM FullGC made it impossible to sleep all night and completely crashed~
- JSD - 2204 - Knife4j framework - processing - Day07 response results
- CS-NP白蛋白包覆壳聚糖纳米颗粒/人血清白蛋白-磷酸钙纳米颗粒无机复合材料
猜你喜欢

Chapter 12, target recognition of digital image processing

回收租凭系统100%开源无加密 商城+回收+租赁

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

包含吲哚菁绿的多聚体白蛋白纳米球/载马钱子碱纳米粒的牛血清白蛋白微球的制备

教你VSCode如何快速对齐代码、格式化代码

【力扣】字符串相乘

ModuleNotFoundError: No module named ‘yaml‘

Day33 LeetCode

JVM内存结构详解

基于php湘西旅游网站管理系统获取(php毕业设计)
随机推荐
Appendix A printf, varargs and stdarg a. 2 use varargs. H to realize the variable argument list
方舟开服需要知道的那些事
Appendix A printf, varargs and stdarg A.1 printf family of functions
LeetCode
JVM内存结构详解
C Expert Programming Preface
property语法
基于php湘西旅游网站管理系统获取(php毕业设计)
Homework 8.1 Orphans and Zombies
Port protocol for WEB penetration
空间数据库开源路,超图+openGauss风起禹贡
render-props和高阶组件
【Jmeter常用断言组件】
ModuleNotFoundError: No module named ‘yaml‘
Day016 类和对象
ARFoundation入门教程U2-AR场景截图截屏
微软校园大使喊你来秋招啦!
【Unity实战100例】文件压缩Zip和ZIP文件的解压
Spark练习题+答案
Popular explanation: what is a clinical prediction model