Arduino UNO + TMP36 temperature sensor + Scilab

1. Create circuit with TMP36 sensor (google for examples)

2. Connect arduino to computer via USB port (it is for data exchange and power). In Ubuntu 14 you should allow this device. Open terminal and run

sudo chmod a+rw /dev/ttyACM0

note 'ttyACM0' is optional. You may need to change this line.
In arduino software check for:  Tools>Port

3. Install and run arduino software. Create new sketch (google for details):

int outputpin= 0;

void setup()

//main loop
void loop()
int rawvoltage= analogRead(outputpin);

float volts= (rawvoltage/1024.0) * 5;
float celsius= (volts-0.5)*100;



Go to Sketch > Upload.
Go Tools > Serial Monitor to see output (Temperature, degrees C, each 1 sec)

4. SciLab  > Applications > Module Manager - ATOMS > Real Time > Serial Communication Toolbox for Scilab

Install it and re-run scilab

5. Type Scinotes or go to Applications > SciNotes

Create code like (read help for details and commands):

n=300 // plot 300 data points from serial port "/dev/ttyACM0"
while i<=n
data(i) = strtod(readserial(h)); // char to number
plot(i,data(i),'b-o'); // real time plot
drawnow(); // show data

And run it (arduino monitor should be closed).
You will see output in real time. Scilab is getting string output (temperature) and transfer it to the numbers.

SciLab/Xcos also has special tool for Arduino. You may google videos on youtube for that.

No comments:

Post a Comment