This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
uphp:functions:adc_read [2017/04/13 06:47] jeff |
uphp:functions:adc_read [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 7: | Line 7: | ||
====Description==== | ====Description==== | ||
- | <well size=" | + | <well size=" |
- | < | + | |
<span style=" | <span style=" | ||
- | <span style=" | + | <span style=" |
- | </ | + | |
- | [[adc_read]] ( | + | |
- | < | + | |
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
- | </ | + | </ |
- | </ | + | |
Return the raw <tooltip title=" | Return the raw <tooltip title=" | ||
Line 32: | Line 27: | ||
Channel 2 is connected to pin A3, which reads 0-5V DC. | Channel 2 is connected to pin A3, which reads 0-5V DC. | ||
- | ====Return | + | ====Return |
< | < | ||
Line 43: | Line 38: | ||
===Example #1=== | ===Example #1=== | ||
- | Read Channel 0 and use the constants v_adc_offset and v_adc_mul to obtain a calibrated voltage((**Example #1** demonstrates a legacy method to obtain a calibrated voltage, which was the primary method in early Wattmon releases, and has not yet been removed from the OS. The calibration constants are loaded automatically into [[uphp: | + | |
+ | Read Channel 0 and use the constants v_adc_offset and v_adc_mul to obtain a calibrated voltage((**Example #1** demonstrates a legacy method to obtain a calibrated voltage, which was the primary method in early [[hardware: | ||
<code php> | <code php> | ||
Line 66: | Line 62: | ||
====Additional Information==== | ====Additional Information==== | ||
- | The raw ADC values can be accessed using [[adc_read()]], | + | The raw ADC values can be accessed using [[adc_read()]], |
===Example #2=== | ===Example #2=== | ||
+ | |||
Use [[mb_get_dev_by_id()]] to obtain calibrated values for A1, A2 and A3: | Use [[mb_get_dev_by_id()]] to obtain calibrated values for A1, A2 and A3: | ||
Line 93: | Line 90: | ||
[[uphp: | [[uphp: | ||
+ | |||
+ | [[pin_configure()]] - Configure an <tooltip title=" | ||
[[floatval()]] - < | [[floatval()]] - < | ||