5 years, 2 months ago.

STM32L476G-DISCO. board with LM35 temp. sensor. Can anyone suggest me for analog in pins to use ?

I am using STM32L476G-DISCO. I have to use LM35 temperature sensor for which I need to connect the Analog In pin to the board. Can anyone suggest me the pins to use e.g. PA_1 etc. I have read that these pins PA_1, PA_2 etc. are all connected to Joystick. Can somebody help me to free up the PA_1 pin specially. I am new to this and stuck.

1 Answer

5 years, 2 months ago.

All the available Analog In pins are used for the Joystick, the rest of the MCU Analog pins are used for the lcd display and mag sensor. However if you do not use the Joystick or one of the switch lines, for instance left or right switch (PA_1, PA_2) then you can use either of these pins for your sensor. The Disco boards are packed with toys that do take up a most of the MCU pins. The Nucleo 64 or 144 boards are best for hooking up components.

Accepted Answer

Thanks Paul for the answer, I am using PA_1 but when I press reset button only then temperature is coming. Also I have declared variable. Can you please suggest something on this. Please see the code below.

  1. include <mbed.h>
  2. include <pinmap.h>
  3. include "PeripheralPins.h"

const PinMap PinMap_ADC[] = { {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, {NC, NC, 0} };

AnalogIn analog_value(PA_1);

int main() {

float temp_value; float meas;

while (1) {

meas = analog_value.read(); converts the analog value to eq. temprature. temp_value = ((meas*5000)/100); printf("Temp: %2.2f degree C\r\n",temp_value); wait(1); }; }

posted by Aji Kumar Singh 21 Mar 2019