Informatiile sunt cam aceleasi cu cele din articolul Senzorul de temperatura TMP36 (LM50) si Arduino, doar ca LM-ul nostru nu are acel offset, asa ca modul de conectare simplu, e bun pana pentru temperaturi pozitive:
iar montajul este foarte simplu:
Am modificat foarte putin sketch-ul de la TMP36 si am obtinut:
Sketch-ul modificat este:
// original sketch from http://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor
// adapted sketch by niq_ro from http://nicuflorica.blogspot.com
//LMP35 Pin Variables
int sensorPin = 0; //the analog pin the LM35 Vout (sense) pin is connected to A0
//the resolution is 10 mV / degree centigrade with a
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
// added part by niq_ro
float vmed = 0;
float ve = 0;
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
void loop() // run over and over again
{
vmed = 0;
ve=0;
for (int j = 0; j < 10; j++) {
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
vmed = vmed + voltage;
delay(200);
}
ve = vmed/10;
// print out the voltage
Serial.print(ve); Serial.println(" volts");
// now print out the temperature
float temperatureC = ve * 100 ; //converting from 10 mv per degree
//to degrees (voltage) times 100)
Serial.print(temperatureC); Serial.println(" degrees C");
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
Serial.println("----------------");
delay(1000); //waiting a second
}
Deoarece e pacat sa nu folosim toata gama de masura, cu temperaturi negative, trebuie modificata foarte putin schema, prin adaugarea unei rezistente pe iesire si a 2 diode care "salta" tensiunea de iesire...
Aceasta schema nu prea a fost tratata de utilizatorii Arduino, dar pot spune ca este prezentata in articolul Termometru cu Arduino de pe ROROID unde este/era si un brick (modul de masura):
Am conectat si eu la fel pinii, pentru ca imi e greu sa redesenez acum, mentionand ca am folosit 2 diode 1N4007 si o rezistenta de 20k:
obtinand pe ecran citirile:
Sketch-ul folosit este:
// original sketch from http://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor
// adapted sketch by niq_ro from http://nicuflorica.blogspot.com
// LM35 datasheet: http://www.ti.com/lit/ds/symlink/lm35.pdf
// inspired by http://www.roroid.ro/wiki/pmwiki.php/Main/TermometruCuArduino
//LMP35 Pin Variables
int sensorPin = 0; //the analog pin the LM35 Vout (sense) pin is connected to A0
//the resolution is 10 mV / degree centigrade with a
int diodePin = 1; //pin for measure voltage diode
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
// added part by niq_ro
float vmed = 0;
float ve = 0;
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
void loop() // run over and over again
{
vmed = 0;
ve=0;
for (int j = 0; j < 10; j++) {
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
int reading1 = analogRead(diodePin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
float voltage1 = reading1 * 5.0;
voltage1 /= 1024.0;
vmed = vmed + voltage - voltage1;
delay(200);
}
ve = vmed/10;
// print out the voltage
Serial.print(ve); Serial.println(" volts");
// now print out the temperature
float temperatureC = ve * 100 ; //converting from 10 mv per degree
//to degrees (voltage) times 100)
Serial.print(temperatureC); Serial.println(" degrees C");
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
Serial.println("----------------");
delay(1000); //waiting a second
}
Am scos LM-ul afara sa masor temperatura, ca-i frig:
Niciun comentariu:
Trimiteți un comentariu