-
-
Save HectorTorres/5a14866cc77776cee7fcf54e8cbe2ce4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include "Adafruit_MCP9808.h" | |
Adafruit_MCP9808 sensor = Adafruit_MCP9808(); //objeto que tendrá los valores del sensor de temperatura | |
void setup() | |
{ | |
Serial.begin(9600); | |
Serial.println("Lecturas:"); | |
Serial.println(" "); | |
if (!sensor.begin(0x1F)) //direccion I2C para encontrar el sensor | |
{ | |
Serial.println("No se encontro el sensor MCP9808!"); | |
while (1); | |
} | |
} | |
void loop() | |
{ | |
Serial.println("Temperaturas: "); | |
sensor.shutdown_wake(0);//nesesaria para antes de leer la temperatura | |
float cel = sensor.readTempC(); //lectura de temperatura | |
Serial.print(cel); //impresion en celcius | |
Serial.println(" *C"); | |
float far = cel * 9.0 / 5.0 + 32; //conversion a fahrenheit | |
Serial.print(far); //impresion en fahrenheit | |
Serial.println(" *F"); | |
delay(250); | |
Serial.println("Fin lectura"); | |
Serial.println(" "); | |
sensor.shutdown_wake(1); | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment