MCP9808 - Temperature Sensor
The MCP9808 driver provides an easy way to interface with the temperature sensor on the AVR-IoT Cellular Mini development board.
Installation
The code can be found at GitHub. This driver is also available in the Arduino Library Manager.
In Arduino IDE, click on the Tools -> Manage libraries...
dropdown menu. Search for AVR-IoT MCP9808
as depicted in the screenshot below and click install.
Examples
Various examples can be found in the GitHub repo for reading the temperature, operating in low power mode and setting the resolution. To get started reading the temperature, the following example provides a starting point:
#include <mcp9808.h>
void setup(void) {
Serial3.begin(115200);
const int8_t error = Mcp9808.begin();
if (error) {
Serial3.println("Error: could not start MCP9808 library");
}
}
void loop(void) {
const float celsius = Mcp9808.readTempC();
const float fahrenheit = Mcp9808.readTempF();
Serial3.printf("Temperature (*C): %f\r\n", (double)celsius);
Serial3.printf("Temperature (*F): %f\r\n", (double)fahrenheit);
delay(2000);
}
API Documentation