# I2C0 Current Monitor IC (U101)¶

The MitySOM-335x Development Kit features on on-board (U101) I2C current monitor circuit that can be used to measure the current consumption of the 335x module that is installed into the development kit. We have provided a script called sh_modpwr which is also attached to this wiki for use in the Linux OS. This script can be run from Linux and returns the current usage of the module each time it is run so it will vary each time. As well it is possible to check the current monitor from U-Boot but a set of commands are needed and documented below.

## Linux Access¶

Example output of sh_modpwr script

```root@mityarm-335x:~# sh_modpwr
Voltage across R110  =  0.029 V
Current through R110 =  294.1 mA
power used by SOM    =  970.4 mW
```

The script is attached and can be opened to show what steps are occurring to calculate the current usage.

## U-Boot Access¶

To obtain the current draw from U-Boot begin by enabling the I2C0 bus in U-Boot by following the steps outlined here: http://support.criticallink.com/redmine/projects/armc8-platforms/wiki/I2C0_Bus_Access_in_U-Boot

Once you can successfully read from the device you then need to take the returned value and convert it to an actual current draw number which is done as follows.

1. Obtain and record the value reported (0x01fb) from the i2c read command
```U-Boot# i2c md 48 0
0000: 01 fb 80 ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
```
2. Convert that number to decimal
```0x01fb = 507
```
3. Convert to a voltage based on the current monitors conversion factor
```(507 * 3.3V )/2048 = 0.817
```
4. Calculate the voltage scaled by the resistor values R135 and R136
```0.817/27 = 0.030V
```
5. Determine the current draw by multiplying by 10,000
```0.030 * 10000 = 300mA
```
6. Assuming a steady 3.3V input calculate the power usage
```300mA * 3.3V = 990mW
```

Add picture from clipboard (Maximum size: 600 MB)