Objetivo
El objetivo de este manual es ofrecer la manera de testear el modulo de temperatura KY-013 con nuestro Uno R3 midiendo la temperatura de manera analoga.
Materiales necesarios:
- Modulo Sensor de Temperatura Analogo KY-013 para Arduino
- Uno R3 + Cable USB para Arduino
- Jumpers Macho-Hembra 20cm
Diagrama de conexión:
SENSOR KY-001 |
ARDUINO UNO R3 |
Pin (Centro) | 5V |
Pin (S) | PIN A0 |
Pin (-) | GND (-) |
Codigo utilizado:
#include <math.h>
int sensorPin = A0; // select the input pin for the potentiometer
double Thermistor(int RawADC) {
double Temp;
Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
//Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
void setup() {
Serial.begin(9600);
}
void loop() {
int readVal=analogRead(sensorPin);
double temp = Thermistor(readVal);
Serial.println(temp); // display tempature
//Serial.println(readVal); // display tempature
delay(500);
}