GY-63_MS5611/libraries/MCP9808_RT/examples/mcp9808_test/mcp9808_test.ino

144 lines
2.6 KiB
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: mcp9808_test.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// DATE: 2020-05-03
2021-11-08 14:21:36 -05:00
2021-01-29 06:31:58 -05:00
#include "mcp9808.h"
MCP9808 ts(24);
2021-11-08 14:21:36 -05:00
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
test_0();
test_1();
test_2();
test_3();
}
2021-11-08 14:21:36 -05:00
2021-01-29 06:31:58 -05:00
void test_0()
{
Serial.println();
Serial.println(__FUNCTION__);
Serial.print("CONFIG: ");
Serial.println(ts.getConfigRegister(), HEX);
Serial.print("TUPPER: ");
Serial.println(ts.getTupper());
Serial.print("TLOWER: ");
Serial.println(ts.getTlower());
Serial.print("TCRIT: ");
Serial.println(ts.getTcritical());
Serial.print("TAMBIENT: ");
Serial.println(ts.getTemperature());
Serial.print("Resolut: ");
Serial.println(ts.getResolution());
Serial.print("Manufact: ");
Serial.println(ts.getManufacturerID());
Serial.print("DeviceID: ");
Serial.println(ts.getDeviceID());
Serial.print("Revision: ");
Serial.println(ts.getRevision());
2021-11-08 14:21:36 -05:00
Serial.print("RFU: ");
2021-01-29 06:31:58 -05:00
Serial.println(ts.getRFU());
Serial.println();
}
2021-11-08 14:21:36 -05:00
2021-01-29 06:31:58 -05:00
void test_1()
{
Serial.println();
Serial.println(__FUNCTION__);
for (int i = 0; i < 10; i++)
{
Serial.print(ts.getTemperature(), 4);
Serial.print('\t');
Serial.print(ts.getStatus(), HEX);
Serial.print('\t');
Serial.println();
}
}
2021-11-08 14:21:36 -05:00
2021-01-29 06:31:58 -05:00
void test_2()
{
Serial.println();
Serial.println(__FUNCTION__);
for (int i = 0; i < 10; i++)
{
ts.setTlower(i * PI);
Serial.print(ts.getTlower(), 4);
Serial.print('\t');
Serial.print(ts.getTemperature(), 4);
Serial.print('\t');
Serial.print(ts.getStatus(), HEX);
Serial.print('\t');
Serial.println();
}
ts.setTlower(0);
Serial.println();
for (int i = 0; i < 10; i++)
{
ts.setTupper(i * PI);
Serial.print(ts.getTupper(), 4);
Serial.print('\t');
Serial.print(ts.getTemperature(), 4);
Serial.print('\t');
Serial.print(ts.getStatus(), HEX);
Serial.print('\t');
Serial.println();
}
ts.setTupper(0);
Serial.println();
for (int i = 0; i < 10; i++)
{
ts.setTcritical(i * 4);
Serial.print(ts.getTcritical(), 4);
Serial.print('\t');
Serial.print(ts.getTemperature(), 4);
Serial.print('\t');
Serial.print(ts.getStatus(), HEX);
Serial.print('\t');
Serial.println();
}
ts.setTcritical(0);
Serial.println();
}
2021-11-08 14:21:36 -05:00
2021-01-29 06:31:58 -05:00
void test_3()
{
Serial.println();
Serial.println(__FUNCTION__);
for (int i = 0; i < 4; i++)
{
ts.setResolution(i);
Serial.print(i);
Serial.print('\t');
Serial.print(ts.getResolution());
Serial.println();
}
ts.setResolution(3);
Serial.println();
}
2021-11-08 14:21:36 -05:00
void loop()
{
}
2021-01-29 06:31:58 -05:00
// -- END OF FILE --
2021-11-08 14:21:36 -05:00