Do you really need “raw ADC values” or do you actually need ADC values that indicate the light level shining on the phototransistor?
I use the adc_temperature statement with a couple of resistors to monitor the input voltage going into a controller board as detailed here:
This is being used as a basis for the functional test suite I’ve been working on to check the input voltage values and, more importantly, the ADC circuitry on the controller board.
Using a macro, I can test the voltage values (which are derived from the measured ADC voltages in the adc_temperature statement and respond accordingly:
[gcode_macro vintest]
gcode:
{% set VINMON_VALUE = ( printer["temperature_sensor PS_voltage"].temperature )|float %}
RESPOND TYPE=command MSG="VINTest: { VINMON_VALUE }V"
{% if 23.5 > VINMON_VALUE %}
RESPOND TYPE=error MSG="VINTest: Voltage BELOW 24V"
{% else %}
{% if 24.5 < VINMON_VALUE %}
RESPOND TYPE=error MSG="VINTest: Voltage ABOVE 24V"
{% else %}
RESPOND TYPE=command MSG="VINTest: PASS"
{% endif %}
{% endif %}
It may take a bit of work to determine the conversion value but it works very well and, in my case, the “temperature” values accurately correspond to the actual voltages input into the board.