This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:iot-open:practical:hardware:sut:stm32:emb2_1 [2024/04/21 11:20] – ktokarz | en:iot-open:practical:hardware:sut:stm32:emb2_1 [2024/04/21 11:25] (current) – [Result validation] ktokarz | ||
---|---|---|---|
Line 13: | Line 13: | ||
Reading of the ADC is possible using the regular '' | Reading of the ADC is possible using the regular '' | ||
- | <note tip>In STM32, ADC has by default | + | <note tip>In STM32, ADC has a 12-bit resolution |
===== Prerequisites ===== | ===== Prerequisites ===== | ||
To implement this scenario, it is advised to get familiar with at least one of the following scenarios first: | To implement this scenario, it is advised to get familiar with at least one of the following scenarios first: | ||
Line 92: | Line 92: | ||
=== Step 4 === | === Step 4 === | ||
- | Initialise the I2C bus and configure ADC's GPIO as input: | + | Initialise the I2C bus and configure ADC's GPIO as input. Change the ADC resolution to 12-bits. |
<code c> | <code c> | ||
Wire.begin(); | Wire.begin(); | ||
pinMode(POT_ADC, | pinMode(POT_ADC, | ||
+ | analogReadResolution(12); | ||
</ | </ | ||
Line 128: | Line 129: | ||
</ | </ | ||
==== Result validation ==== | ==== Result validation ==== | ||
- | A relation between the potentiometer set value and ADC reading should be almost linear from 0V up to about 3V. It becomes horizontal because | + | A relation between the potentiometer set value and ADC reading should be almost linear from 0V up to the maximum. The linear correlation is never perfect, either because of the devices' |
===== FAQ ===== | ===== FAQ ===== |