1 month ago.
AnalogIn on pin A3 on Nucleo-L432KC
I have defined pin A3 as an analogIn and DewPoint as a variable as follows in my code:
AnalogIn DP_In(A3); float DewPoint = 0;
I am also using a 16x2 LCD that has been setup as follows:
TextLCD lcd(D6, D9, D2, D3, D4, D5); // rs, e, d4-d7
I then have a loop that reads the A3 pin every 1 second with the following code:
DewPoint = DP_In.read()*100.0f;
I have set the input voltage to pin A3 to 2,8V.
I expect to have a constant value for DewPoint as a percentage of 0-3.3V.
The value that I receive is not constant it is fluctuating between 83% and 88% with every read. This value should be constant in line with my 2.8V input signal. What am I doing wrong?
- Can Pin A3 be used as analogue input?
- Is there a problem in my code?
- Is it possible that my screen is interfering with me analogue readings?
- Which pins do you recommend I use?
Your assistance is much appreciated.
1 month ago.
In general the analogue peripheral built into a MCU is not as stable as a dedicated A-D converter chip. Also most development boards do not have very good power supply regulation particularly for the ADC reference voltage input.
Generally the way round this is to make several samples in succession, ignore the highest and lowest values and average the rest. This gives quite good results.
You need to log in to post a question