Introduction
This article focuses on reading voltages supplied to desktops using Linux terminal, specifically for PMBus (Power Management Bus) and SMBus (System Management Bus) systems. When attempting to read voltages using the 'di2c-tools' package like 'i2chwmon', it may seem that the values are not right. In this article, we will provide a detailed context on the topic, covering key concepts, subtopics, and proper formatting for code blocks.
Background
PMBus and SMBus are communication protocols used to monitor and control various devices, including power supplies, fans, and sensors. Both buses use the I2C (Inter-Integrated Circuit) protocol for communication. Linux provides several tools to interact with these buses, such as 'i2c-tools' and 'smbus-tools'.
Reading Voltages with Linux
i2c-tools
To read voltages using 'i2c-tools', first, you need to identify the I2C address of the device. For example, for a voltage regulator with an address of 0x1a, you can use the 'i2cdetect' command:
sudo i2cdetect -y 1
Then, use the 'i2cget' command to read the voltage value. For a 12-bit resolution sensor, the command would be:
sudo i2cget -y 1 0x1a 0x35 2raw
The output will be two hexadecimal numbers. The first number represents the lower 8 bits, and the second number represents the higher 4 bits. Combine these numbers to get the 12-bit value. Convert this value to voltage using the sensor's calibration data.
smbus-tools
For SMBus devices, use the 'smbus' command to read voltages. First, identify the I2C address using 'i2cdetect'. Then, use the 'smbus' command to read the voltage value:
sudo smbusclient -c 1 0x1a i2c-list
i2c-sel: 0x1a
i2c-read: 0x35
0x35: 0x00 0x00
i2c-read: 0x36
0x36: 0x00 0x80
In this example, the voltage value is 0x80 * 0x100 + 0x00 = 800 mV.
Troubleshooting
If the voltages read using 'i2chwmon' or 'smbus-tools' seem incorrect, check the following:
- Ensure the correct I2C address is used.
- Check the sensor's calibration data.
- Make sure the sensor is connected correctly.
- Update the Linux drivers and tools.
References
i2c-tools User Guide smbus-tools User Guide Linux I2C driver API