[FX30] ADC usage


I’m having issues with analog reading on a FX30.
In order to read the ADC value I’m using /sys/class/hwmon/hwmon0/device/mpp_05.

Firstly, I’m unable to select the range between 0-5V or 0-10V.
From the documentation “41110030_FX30 Hardware User Guide_r1.pdf” (page 38), it should be possible to select the ADC range through AT commands but running these commands fails:
modem /dev/ttyAT 230400 “AT!FWD=GPIOCFG,25,OUT”
Same for modem /dev/ttyAT 230400 “AT!BSGPIO=25,1,0”

The document 41110030_FX30 User Guide_r2.pdf may be a better more up to date version but it describes the range without indicating how to set it.

I also tried to manually configure GPIO25 this way:
echo out > /sys/class/gpio/gpio25/direction
echo 1 > /sys/class/gpio/gpio25/value

This gives no error, but there’s no change in what /sys/class/hwmon/hwmon0/device/mpp_05 reports.

A second issue is that the range of raw values seems to be compressed: at 0V the raw value is 24808, while at 5V the raw value is 42750. This makes a range of 17942, which is quite far from the theoretical range of 32768 (15 bits).

At page 22 of the user guide, the table says that the analog input is connected on I/O 2 on the power connector, together with GPIO21. Manually disabling pull up on GPIO21 didn’t change anything (echo down > /sys/class/gpio/gpio21/pull)

Firmware version: SWI9X15Y_07.11.22.00 r33729 CARMD-EV-FRMWR1 2017/01/11 18:04:06 (as reported by modem /dev/ttyAT 230400 “AT+GMR”)

Is there additional configuration switches to manage the analog input ?
Thanks in advance

Hi there,

My apologies, the ADC select output has not been implemented in software at this time. The User Guide incorrectly states that the input range can be controlled.

Did you ensure the internal pull-up on ext IO2 is disabled?


Hello Chris,

Thanks for your answer.
I double checked the IO2 pull-up and performed some more manipulations/measurements. Here they are:

[code]Disabling the IO2 pull up
command: “echo 0 > /sys/class/gpio/gpio53/value”

Reading ADC value with sys device reading:
command: “cat /sys/class/hwmon/hwmon0/device/mpp_05”
0v -> Result:8926 Raw:24771
1v -> Result:358503 Raw:28335
2v -> Result:714061 Raw:31960
3v -> Result:1067659 Raw:35565
4v -> Result:1420472 Raw:39162
5v -> Result:1777208 Raw:42799
6v -> Result:1797022 Raw:43001

Reading ADC value with modem command:
command: “modem /dev/ttyAT 230400 AT!MADC?5”
0v -> 9
1v -> 358
2v -> 713
3v -> 1066
4v -> 1414
5v -> 1777
6v -> 1797

From this I understand that the selected range is 5v.
The “Result” corresponds to the modem returned value with more precision.
But I do not find the 15bits ADC resolution… the “Result” could correspond to a part of a 21 bits precision ADC…

What is really the precision of the ADC?
What is the “Raw” value returned by the reading of the SYS device?

Regards, Christian.

Hi Christian,
The voltage range on the ADC is 0-1.8V and the Result is actually the voltage. The precision should be 15 bits, and I agree the Raw doesn’t correspond to this, could be a bug… will examine this.

For sysfs the reading is in uV while the AT command reports in mV.

So, at 6v, you’re reading is full scale at 1.797v