$adc=adc_read(0);
$volts=floatval($_GLOBALS['v_adc_mul'])*(floatval($adc)+floatval($_GLOBALS['v_adc_offset']));
print("adc=".$adc."\r\n");
print("v_adc_offset=".$_GLOBALS['v_adc_offset']."\r\n");
print("v_adc_mul=".$_GLOBALS['v_adc_mul']."\r\n");
print("volts=".$volts."\r\n");
?>
Typical output for the above example (results vary depending on actual voltage and calibration constants):
adc=192
v_adc_offset=24.811435
v_adc_mul=0.065411
volts=14.181854
====Additional Information====
The raw ADC values can be accessed using [[adc_read()]], but it is recommended to use the functions [[mb_get_val_by_role()]] or [[mb_get_dev_by_id()]] in order to obtain calculated values for A1, A2 and A3 that are adjusted by the calibration values stored in //
$dev=mb_get_dev_by_id(0);
$a1=$dev['a1']/10; // scaled by 10
$a2=$dev['a2']/10; // scaled by 10
$a3=$dev['a3']/100; // scaled by 100
print("A1=".$a1." V\r\n");
print("A2=".$a2." V\r\n");
print("A3=".$a3." V\r\n");
?>
Typical output for the above example (results vary depending on actual voltage and calibration constants):
A1=13.600001 V
A2=2.100000 V
A3=4.980000 V
====See Also====
[[uphp:uphp_special_variables]] - Special arrays that are populated automatically (including ''$_GLOBALS'')
[[pin_configure()]] - Configure an