9 years, 2 months ago.

AnalogIn problem (pics included); strange values for temperature sensor (LM35DZ) and STM32F103RB

I'm a beginner in STM32, so please help me with the following issue:

I've made firmware upgrades, stm32 library updates, In picture one first rows readings are from a 1.28V battery the rest are from the LM35 sensor. Battery seemns ok but for LM35 I get 367mV instead of 270mV (measured with a multimeter) I don't know why the value from L35 is not ok from the uC's ADC . The connections are made like pic 3 (I use analog in A2 ) /media/uploads/alexlungu10/capture_JRWGvl1.jpg

/media/uploads/alexlungu10/tmp36fritz-1-.gif The code: http://developer.mbed.org/users/alexlungu10/code/ADC4Home/

Text code below:

test

#include "test_env.h"
Serial pc(USBTX, USBRX);
AnalogIn analogValue(A2);
DigitalIn userButton(USER_BUTTON);
DigitalOut led(LED1);

// Calculate the corresponding acquisition measure for a given value in mV
#define MV(x) ((0xFFF*x)/3300)

void notify_completion(bool success) {
	led = 0;
	pc.baud(9600);
	int count = 0;
	bool enFlag = true;
	while (1) {

		count++;
		if (userButton == 0) {
			enFlag = (enFlag == true) ? false : true;
			//pc.close();
		}
		if (enFlag) {
			unsigned short meas = (analogValue.read_u16());
			//float fl = analogValue.read() * 3300;
			//float final = (float) 3300* (float) meas / 65535 ; // normal 0.0008  or 3.3v-3300mV  0,8058608058608059 3300/4095
			pc.printf("%d; 16bit %hu val in mV: %d  \n", count,
					meas, ((meas * 3300) / 0xFFFF)); //, (int) fl);

		}

		led = !led;

		wait(1.5f);
	}

}



1 Answer

9 years, 2 months ago.

I had a similar problem with Nucleo L152 and MCP9700 (similar in operation to the LM35 sensor). Potentiometer voltage measurements were consistent with a multimeter, but with the sensor were wrong (as in your test, voltage read by the A / D was significantly too big). When I connected an oscilloscope it turned out that the input A / D signal was noisy and definitely helped capacitor between GND and input A / D. I gave RC filter 1k and 1uF. The system measures fine.

Accepted Answer

10x for the advice, a 10uF polarized cap did the work.

posted by alex alex 15 Feb 2015