Skip to content

Instantly share code, notes, and snippets.

@HectorTorres HectorTorres/.c
Last active May 21, 2018

Embed
What would you like to do?
#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
You can’t perform that action at this time.