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/03/31 12:38] jeff |
uphp:functions:adc_read [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
======adc_read====== | ======adc_read====== | ||
+ | |||
< | < | ||
Line 5: | Line 6: | ||
====Description==== | ====Description==== | ||
- | <well size=" | + | |
- | <span style=" | + | <well size=" |
- | < | + | <span style=" |
+ | <span style=" | ||
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
</ | </ | ||
+ | |||
Return the raw <tooltip title=" | Return the raw <tooltip title=" | ||
====Parameter==== | ====Parameter==== | ||
- | < | + | |
+ | <html><b>< | ||
Channel 0 is attached to pin <tooltip title=" | Channel 0 is attached to pin <tooltip title=" | ||
Line 23: | 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 |
- | < | + | |
- | < | + | < |
+ | |||
+ | < | ||
+ | |||
+ | < | ||
====Examples==== | ====Examples==== | ||
- | **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: | + | |
+ | ===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 [[hardware: | ||
<code php> | <code php> | ||
Line 51: | Line 61: | ||
====Additional Information==== | ====Additional Information==== | ||
- | The raw ADC values can be accessed using [[adc_read()]], | ||
- | **Example #2** - Use [[mb_get_dev_by_id()]] to obtain calibrated values for A1, A2 and A3: | + | The raw ADC values can be accessed using [[adc_read()]], |
+ | |||
+ | ===Example #2=== | ||
+ | |||
+ | Use [[mb_get_dev_by_id()]] to obtain calibrated values for A1, A2 and A3: | ||
<code php> | <code php> | ||
Line 75: | Line 88: | ||
====See Also==== | ====See Also==== | ||
+ | |||
[[uphp: | [[uphp: | ||
- | [[floatval()]] - Return the floating point value of a number or string | + | [[pin_configure()]] - Configure an <tooltip title=" |
+ | |||
+ | [[floatval()]] - < | ||