【树莓派】:电压监控一直提示low voltage warning,please check your power supply

使用VNC连接树莓派时桌面任务栏一直提示low voltage warning,please check your power supply
【现象分析】:
对于使用集成raspberry 4B系列产品使用官方电源一般不会有报警,本报警主要为使用CM4核心板+自制载板时出现的异常现象,报警提示如下:
在这里插入图片描述
【原因分析】:
1.CM4核心板需要3.3v的供电,首先分析是电压供电不足导致的报警:
在这里插入图片描述
发生报警时,首先检查核心板3.3V的供电是否异常,负载过多会存在较大压降,
ioboard的具体原理参考:
核心板模块介绍:
载板模块介绍:
官网整个模块介绍:

2.电压检测脚本:
1.使用sh检测

#!/bin/bash

# Before running this script, make sure you have sysbench installed:
#           sudo apt-get install sysbench
#
# This script helps you check if your Raspberry pi is correctly powered.
# You can read more about Raspberry pi powering issues here: https://ownyourbits.com/2019/02/02/whats-wrong-with-the-raspberry-pi/


# If you're pi is correctly powered (stable power supply and quality cable), after running the script, you should get something like:
#
# 45.6'C 1400 / 600 MHz 1.3813V -
# 55.3'C 1400 / 1400 MHz 1.3813V -
# 58.0'C 1400 / 1400 MHz 1.3813V -
# 60.2'C 1400 / 1400 MHz 1.3813V -
# 60.2'C 1400 / 1400 MHz 1.3813V -
# 61.1'C 1400 / 1400 MHz 1.3813V -
# 61.1'C 1400 / 1400 MHz 1.3813V -
# 60.8'C 1400 / 1400 MHz 1.3813V -

# If your power supply can't provide a stable 5V 2.5A or if the cable is not good enough, you should get something like:
#
# 39.7'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 48.3'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 52.1'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 54.8'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 55.8'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 56.4'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 57.5'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 58.0'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,
# 59.6'C 1400 / 1400 MHz 1.3875V - Throttling has occurred, Under-voltage has occurred,

function throttleCodeMask {
  perl -e "printf \"%s\", $1 & $2 ? \"$3\" : \"$4\""
}

# Make the throttled code readable
#
# See the `get_throttled` method documentation on: https://www.raspberrypi.org/documentation/raspbian/applications/vcgencmd.md
#

function throttledToText {
  throttledCode=$1
  throttleCodeMask $throttledCode 0x80000 "Soft temperature limit has occurred, " ""
  throttleCodeMask $throttledCode 0x40000 "Throttling has occurred, " ""
  throttleCodeMask $throttledCode 0x20000 "Arm frequency capping has occurred, " ""
  throttleCodeMask $throttledCode 0x10000 "Under-voltage has occurred, " ""
  throttleCodeMask $throttledCode 0x8 "Soft temperature limit active, " ""
  throttleCodeMask $throttledCode 0x4 "Currently throttled, " ""
  throttleCodeMask $throttledCode 0x2 "Arm frequency capped, " ""
  throttleCodeMask $throttledCode 0x1 "Under-voltage detected, " ""
}

# Main script, kill sysbench when interrupted
trap 'kill -HUP 0' EXIT
sysbench --test=cpu --cpu-max-prime=10000000 --num-threads=4 run > /dev/null &
maxfreq=$(( $(awk '{printf ("%0.0f",$1/1000); }' < /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) -15 ))

# Read sys info, print and loop
while true; do
  temp=$(vcgencmd measure_temp | cut -f2 -d=)
  real_clock_speed=$(vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f", $2 / 1000000); }' )
  sys_clock_speed=$(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
  voltage=$(vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
  throttled_text=$(throttledToText $(vcgencmd get_throttled | cut -f2 -d=))
  echo "$temp $sys_clock_speed / $real_clock_speed MHz $voltage - $throttled_text"
  sleep 5
done

2.添加到ssh连接时自动展示:
在/etc/profile.d/新增temp-volt.sh脚本文件,具体代码如下

#换行
echo ''
#运行命令查看cpu温度
#echo `vcgencmd measure_temp`
#执行脚本文件
source  ~/raspberry-power-supply-check.sh

raspberry-power-supply-check.sh脚本内容:

#!/bin/bash
function throttleCodeMask {
  perl -e "printf \"%s\", $1 & $2 ? \"$3\" : \"$4\""
}
function throttledToText {
  throttledCode=$1
  throttleCodeMask $throttledCode 0x80000 "Soft temperature limit has occurred, " ""
  throttleCodeMask $throttledCode 0x40000 "Throttling has occurred, " ""
  throttleCodeMask $throttledCode 0x20000 "Arm frequency capping has occurred, " ""
  throttleCodeMask $throttledCode 0x10000 "Under-voltage has occurred, " ""
  throttleCodeMask $throttledCode 0x8 "Soft temperature limit active, " ""
  throttleCodeMask $throttledCode 0x4 "Currently throttled, " ""
  throttleCodeMask $throttledCode 0x2 "Arm frequency capped, " ""
  throttleCodeMask $throttledCode 0x1 "Under-voltage detected, " ""
}
temp=$(vcgencmd measure_temp | cut -f2 -d=)
real_clock_speed=$(vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f", $2 / 1000000); }' )
sys_clock_speed=$(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
voltage=$(vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
throttled_text=$(throttledToText $(vcgencmd get_throttled | cut -f2 -d=))
echo "$temp $sys_clock_speed / $real_clock_speed MHz $voltage - $throttled_text"

结果展示:
在这里插入图片描述
参考链接:

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是基于树莓派和Qt编写的交通灯控制代码示例: 1. 首先需要在树莓派上安装Qt Creator和WiringPi库。 2. 创建一个Qt项目,添加以下代码: ```c++ #include <wiringPi.h> #include <QCoreApplication> #include <QTimer> const int RED_PIN = 0; // 定义红灯引脚为0 const int YELLOW_PIN = 1; // 定义黄灯引脚为1 const int GREEN_PIN = 2; // 定义绿灯引脚为2 int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); wiringPiSetup(); // 初始化WiringPi库 pinMode(RED_PIN, OUTPUT); // 设置红灯引脚为输出模式 pinMode(YELLOW_PIN, OUTPUT); // 设置黄灯引脚为输出模式 pinMode(GREEN_PIN, OUTPUT); // 设置绿灯引脚为输出模式 digitalWrite(RED_PIN, HIGH); // 默认设置红灯亮 digitalWrite(YELLOW_PIN, LOW); digitalWrite(GREEN_PIN, LOW); QTimer timer; // 创建定时器 QObject::connect(&timer, &QTimer::timeout, [](){ // 定时器回调函数,用于控制交通灯的状态 digitalWrite(RED_PIN, LOW); digitalWrite(YELLOW_PIN, HIGH); delay(2000); digitalWrite(YELLOW_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); delay(5000); digitalWrite(GREEN_PIN, LOW); digitalWrite(YELLOW_PIN, HIGH); delay(2000); digitalWrite(YELLOW_PIN, LOW); digitalWrite(RED_PIN, HIGH); }); timer.start(10000); // 设置定时器间隔为10秒 return a.exec(); } ``` 3. 连接树莓派的GPIO口和交通灯,将红灯接到树莓派的0号引脚,黄灯接到1号引脚,绿灯接到2号引脚。 4. 在Qt Creator中编译并运行代码,即可控制交通灯的状态。 注意:在运行代码之前,需要使用sudo权限运行程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时间之里

好东西就应该拿出来大家共享

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值