0

Hi I'm new in matlab GUI

I am trying to create an axes plot the temperature which comes from LM35 through arduino uno to matlab

I used the following code to read the analog voltage, readVoltage(a,0) I get a values about 0.28 - 0.30 but I don't know exactly what this values exactly means is it the the real temperature/100 or what? I know there is an ADC inside arduino converts the input voltage to another range (0-1023) when I use analogRead() on the arduino side. Does it also work here or not? I confused about this thing when I should assume it is 0-1023 or directly get the reading.

Smern
  • 18,746
  • 21
  • 72
  • 90

1 Answers1

2

The arduino ADC reads a voltage and outputs a number according to

  1. the reference voltage
  2. the bit width of the ADC

in this case I suppose that you are using the 5V reference and 10 bit mode, so

Vmeasured = NumberFromADC * 5V / 1024

Now, according to the LM35 datasheet the output voltage is

Vout = 10mV/°C * T

inverting the equation:

T = Vout / (10mV/°C) = NumberFromADC * 5V / 1024 / (10mV/°C) = NumberFromADC * 500 / 1024

(of course expressed in °C)

BTW I suggest you to change the voltage reference to an internal one, since the 5V are not stable and precise enough to have a good measuring system. More info here.

And, of course, if you change the reference voltage you will need to change the equation since the reference itself will not be 5V anymore.

frarugi87
  • 2,826
  • 1
  • 20
  • 41
  • thank you but my question was about ADC and readVoltage() command which on matlab side I think it is gives me the input voltage directly or what ? – Eng-Mohammed Kayed May 19 '15 at 19:28
  • Oh, sorry. When I read Matlab I thought you were using just for displaying rather than programming the Arduino. My bad. Anyway... In matlab you just have `readVoltage`, which gives you the converted voltage. In arduino IDE, on the other side, you have `analogRead`, which gives you the ADC reading (i.e. 0-1023). [Here](http://it.mathworks.com/help/supportpkg/arduinoio/ref/readvoltage.html) you can find some documentation about the `readVoltage` function. – frarugi87 May 20 '15 at 21:47