MSP-EXP430F5529 & CCS: Temperature sensor using LM35 and LCD102x64

mayo 04, 2018 0 comentarios

The connection is very basic, the sensor to VCC and GND, the signal Vout of the LM35 is connected to the analog channel A6 of the MSP.

To obtain the temperature we need to perform a few calculations, for example in the LM35 datasheet it tells us that Vout = 10mV / ° C, in other words 1 ° C = 10mV, for example if we have a temperature of 30 ° C we will have Vout = 300mV, another point that we should consider will be the resolution of the ADC, in this case it is 12 bits, this means that we can have values ​​from 0 to 4096, to know what voltage corresponds to a bit we can say that; 1Bit = 3.3V / 4096 = 3300mV / 4096 = 0.8056mV.

With this we can know how many bits will be present in A6 when the temperature is 30 ° C, therefore Bits30 ° C = 300mV / 0.8056mV = 372.39.

The ways of presenting the equation that describes the behavior of the temperature can be of different forms but in the end the same result is achieved, I do it in the following way, of course, considering the previous calculations.

1 Bit = 0.8056mV
1 ° C = 10mV

And applying a rule of three we have 1 Bit = 0.8056mV * ° C / 10mV = 0.08056 ° C

Then I can deduce that if this constant is multiplied by the bits in A0, I will obtain my desired temperature, for example; 0.08056 * 373.30 = 29.99 ° C, considering that we have not used all the decimals we can say that our temperature is correct.

With this constant we reduce a little the process in the code, to avoid making the divisions, I must also mention that in the code I take 32 samples (1 sample every 32mS approximately) and then I get the average value with a displacement, so I update the temperature in approximately 1 second and show it on the screen, there is also a bar where we show from 10 ° C to 45 ° C, when the temperature is less at 45 ° C the LED1 changes state every second, when it is higher the LED1 changes its status every 32 milliseconds (flashing faster).

Here a small video of the working temperature sensor.

Here the direct link to DOWNLOAD the available files, you can also check or download the information from my repository on GitHub, if you do not know how to download it you can check here, well for now it's all, if you have doubts, comments, suggestions, concerns, etc. leave them and I will try to answer as soon as possible.

Share Share Tweet Share

0 comentarios en "MSP-EXP430F5529 & CCS: Temperature sensor using LM35 and LCD102x64"