Microcontroladores
Projeto – 10
Prof Júlio Vansan
[email protected]Projetos e exemplos livres para cópia e alteração
Projeto Sensor de Temperatura
Material necessário:
• 1 Arduino
• 1 Sensor de temperatura LM35
• 1 Protoboard
• Jumper cable
• Resistores de 220 ohms à um 1k ohms
• Leds (qualquer cor)
Projetos de Sensor de Temperatura
• https://learn.adafruit.com/tmp36-temperature-sensor
Lendo o Sensor de Temperatura
Lendo o Sensor de Temperatura
1. const int LM35 = A0; // Pino Analogico onde vai ser ligado o
LM35
2. const int REFRESH_RATE = 2000; //Tempo de atualização
3. const float CELSIUS_BASE =
0.4887585532746823069403714565; //Base de conversão para
Graus Celsius ((5/1023) * 100)
4. float temp=0;
5. void setup() {
6. Serial.begin(9600);
7. }
8. void loop() {
9. Serial.print("Temperatura: ");
10. temp=(analogRead(LM35) * CELSIUS_BASE);
11. Serial.println(temp);
12. delay(REFRESH_RATE);
13. }
Acionando um Ventilador - Temperatura
1. float tempC;
2. int tempPin = 0;
3. int ventilador=8;
4. void setup()
5. {
6. Serial.begin(9600); // Abre a porta Serial
7. pinMode(ventilador,OUTPUT);
8. }
9. void loop()
10. {
11. tempC = analogRead(tempPin); // Lendo o Sensor
12. tempC = (5.0 * tempC * 100.0)/1024.0; // convertendo para Temperatura
13. Serial.println(tempC); // Mandando o valor para a porta Serial
14. delay(1000); // delay
15. if (tempC > 25)
16. digitalWrite(ventilador,HIGH);
17. else
18. digitalWrite(ventilador,LOW);
19. }
Temperatura – Termistor NTC
• Termistor PTC (Positive
Temperature Coefficient): Este tipo de Termistor
tem o coeficiente de temperatura positivo, ou
seja, a resistência aumenta com o aumento da
temperatura.
• Termistor NTC (Negative
Temperature Coefficient): Já este é o inverso do
anterior e seu coeficiente de temperatura é
negativo. Com isto sua resistência diminui com o
aumento da temperatura.
Temperatura – Termistor NTC
Lendo o Sensor de Temperatura NTC
1. #include <Thermistor.h>
2. Thermistor temp(0);
3. void setup() {
4. Serial.begin(9600);
5. }
6. void loop()
7. {
8. int temperature = temp.getTemp();
9. Serial.print("Temperatura no Sensor eh: ");
10.Serial.print(temperature); Serial.println("*C");
11.delay(1000);
12.}