Initial I2C Working

Dependencies:   mbed

main.cpp

Committer:
sk398
Date:
2017-03-29
Revision:
2:832cb4376d2a
Parent:
1:444546e8cd20
Child:
3:c6aad2355a40

File content as of revision 2:832cb4376d2a:

#include "mbed.h"
#include "MCP9803.h"

MCP9803 TempSensor(PB_9,PB_8,0x90,100000);

int main()
{
    // Example of how to Configure Sensor
    
    int configSuccess = TempSensor.ConfigSensor(0x00,0x01,0x00,0x02,0x03,0x00);
    
    // Print value returned from ConfigSensor
    // 0 indicates success, 1 indicates failure
    printf("CONFIG Success = %d\r\n\r\n",configSuccess);
    
    // Print raw temp value
    // Anything other than 0x0FF0 indicates success
    printf("Temp Raw = %04x\r\n",TempSensor.RawTempValue());
    
    // Print converted temp values
    // Anything other than -2000.000 indicates success
    printf("Temp C = %f\r\n",TempSensor.FormattedTempValue(CELCIUS));
    printf("Temp F = %f\r\n",TempSensor.FormattedTempValue(FARENHEIT));
    printf("Temp K = %f\r\n",TempSensor.FormattedTempValue(KELVIN));
   
   // Example of failure from sending wrong format
   printf("Temp ? = %f\r\n",TempSensor.FormattedTempValue(0x0F));
}