=head1 SYNOPSIS use PINE64::MCP9808; my $temp_sensor = PINE64::MCP9808->new(0, '0x18'); my @reading = $temp_sensor->read_temperature(); my $celsius = $reading[0]; my $fahrenheit = $reading [1]; =head1 DESCRIPTION This module allows you to take temperature readings with the highly accurate MCP9808 I2C temperature sensor using a PINE64A+ board. =head1 METHODS =head2 new(0, 0x18) You can optionally pass the I2C device id and the address of the MCP9808 on the I2C bus. The PINE64A+ I2C bus is /dev/i2c-0, and the default I2C address for an MCP9808 is 0x18. new() called with no arguments will default to /dev/i2c-0 and 0x18. =head2 read_temperature() Reads the ambient temperature register of the MCP9808 and returns an array containing the reading in celsius and fahrenheit. The ambient temperature register is 0x05. Bits 13-15 have to be masked out. Bit 12 is the sign bit. The two's complement temperature reading is bits 0-11. $reading[0] is temperature in celsius, $reading[1] is the reading in temperature.