Skip to content

Instantly share code, notes, and snippets.

@parastuffs
Created October 19, 2023 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parastuffs/715a452d7d98b068cd18b19b39408695 to your computer and use it in GitHub Desktop.
Save parastuffs/715a452d7d98b068cd18b19b39408695 to your computer and use it in GitHub Desktop.
/**
Make sure that the 'MCP9800' library is installed.
https://github.com/JChristensen/MCP9800/tree/master
*/
#include <MCP9800.h>
MCP9800 mySensor;
void setup()
{
Serial.begin(115200);
delay(1000);
mySensor.begin(); // initialize the hardware
mySensor.writeConfig(ADC_RES_12BITS); // max resolution, 0.0625 °C
}
void loop()
{
float C = mySensor.readTempC16(AMBIENT) / 16.0;
Serial.println(C);
delay(2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment