Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created December 9, 2023 23:07
Show Gist options
  • Save cleverca22/95d2cb2f4e1f59be2bd94f0e1d446cc9 to your computer and use it in GitHub Desktop.
Save cleverca22/95d2cb2f4e1f59be2bd94f0e1d446cc9 to your computer and use it in GitHub Desktop.
clever@raspberrypi:~ $ vcgencmd pmic_read_adc
3V7_WL_SW_A current(0)=0.04782057A
3V3_SYS_A current(1)=0.04684464A
1V8_SYS_A current(2)=0.17078780A
DDR_VDD2_A current(3)=0.02049453A
DDR_VDDQ_A current(4)=0.00000000A
1V1_SYS_A current(5)=0.18933040A
0V8_SW_A current(6)=0.32888840A
VDD_CORE_A current(7)=0.92871990A
3V3_DAC_A current(17)=0.00054945A
3V3_ADC_A current(18)=0.00018315A
0V8_AON_A current(16)=0.00586080A
HDMI_A current(22)=0.01636140A
3V7_WL_SW_V volt(8)=3.70534400V
3V3_SYS_V volt(9)=3.31467300V
1V8_SYS_V volt(10)=1.80903400V
DDR_VDD2_V volt(11)=1.10292900V
DDR_VDDQ_V volt(12)=0.61575030V
1V1_SYS_V volt(13)=1.10512700V
0V8_SW_V volt(14)=0.80292960V
VDD_CORE_V volt(15)=0.72097620V
3V3_DAC_V volt(20)=3.30952000V
3V3_ADC_V volt(21)=3.30952000V
0V8_AON_V volt(19)=0.79765500V
HDMI_V volt(23)=5.16034000V
EXT5V_V volt(24)=5.17105900V
BATT_V volt(25)=0.00598290V
[clever@amd-nixos:~]$ curl pi5w:9101
pi5_current{name="3V7_WL_SW",id="0"} 0.04977243
pi5_current{name="3V3_SYS",id="1"} 0.05074836
pi5_current{name="1V8_SYS",id="2"} 0.17273960
pi5_current{name="DDR_VDD2",id="3"} 0.02049453
pi5_current{name="DDR_VDDQ",id="4"} 0.00000000
pi5_current{name="1V1_SYS",id="5"} 0.20104160
pi5_current{name="0V8_SW",id="6"} 0.32888840
pi5_current{name="VDD_CORE",id="7"} 0.91979000
pi5_current{name="3V3_DAC",id="17"} 0.00030525
pi5_current{name="3V3_ADC",id="18"} 0.00061050
pi5_current{name="0V8_AON",id="16"} 0.00567765
pi5_current{name="HDMI",id="22"} 0.01684980
pi5_volt{name="3V7_WL_SW",id="8"} 3.70720000
pi5_volt{name="3V3_SYS",id="9"} 3.35735900
pi5_volt{name="1V8_SYS",id="10"} 1.79926600
pi5_volt{name="DDR_VDD2",id="11"} 1.10769100
pi5_volt{name="DDR_VDDQ",id="12"} 0.61575030
pi5_volt{name="1V1_SYS",id="13"} 1.10329600
pi5_volt{name="0V8_SW",id="14"} 0.80146440
pi5_volt{name="VDD_CORE",id="15"} 0.72070740
pi5_volt{name="3V3_DAC",id="20"} 3.31043600
pi5_volt{name="3V3_ADC",id="21"} 3.30952000
pi5_volt{name="0V8_AON",id="19"} 0.79765500
pi5_volt{name="HDMI",id="23"} 5.16034000
pi5_volt{name="EXT5V",id="24"} 5.17642000
pi5_volt{name="BATT",id="25"} 0.00512820
#!/usr/bin/python3
from http.server import HTTPServer, BaseHTTPRequestHandler
from subprocess import run
import re
fmt = 'pi5_{}{{name="{}",id="{}"}} {}\n'
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
res = run(["vcgencmd","pmic_read_adc"], capture_output=True)
lines = res.stdout.decode("utf-8").splitlines()
for line in lines:
res = re.search('([A-Z_0-9]+)_[VA] (current|volt)\(([0-9]+)\)=([0-9.]+)', line)
self.wfile.write(fmt.format(res.group(2), res.group(1), res.group(3), res.group(4)).encode("utf-8"))
httpd = HTTPServer(('', 9101), MyHandler)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment