GY-63_MS5611/libraries/MAX31855_RT/examples/max31855_hwSPI/max31855_hwSPI.ino

89 lines
1.7 KiB
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: max31855_hw_SPI.ino
// AUTHOR: Rob Tillaart
2021-07-05 02:37:20 -04:00
// VERSION: 0.1.1
2021-01-29 06:31:58 -05:00
// PURPOSE: thermocouple lib demo application
// DATE: 2020-08-30
// URL: https://github.com/RobTillaart/MAX31855_RT
//
2021-07-05 02:37:20 -04:00
2021-01-29 06:31:58 -05:00
#include "MAX31855.h"
2021-07-05 02:37:20 -04:00
// read() timing UNO timing ESP32 |
// HWSPI 16000000 ~68 us ~16 us
// HWSPI 4000000 ~72 us ~23 us
// HWSPI 1000000 ~100 us ~51 us
// HWSPI 500000 ~128 us ~89 us
// SWSPI bitbang ~500 us ~
2021-01-29 06:31:58 -05:00
//
// | HW SPI | UNO | ESP32 |
// |:---------|:-----:|:-------:|
// | CLOCKPIN | 13 | 18 |
// | MISO | 12 | 19 |
2021-07-05 02:37:20 -04:00
// | MOSI | 11 | 23 | * not used...
2021-01-29 06:31:58 -05:00
2021-07-05 02:37:20 -04:00
const int csPin = 25;
const int clkPin = 18;
const int dataPin = 19;
2021-01-29 06:31:58 -05:00
uint32_t start, stop;
2021-07-05 02:37:20 -04:00
2021-01-29 06:31:58 -05:00
MAX31855 tc(csPin);
2021-07-05 02:37:20 -04:00
// MAX31855 tc(clkPin, csPin, dataPin); // sw SPI
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
2021-07-05 02:37:20 -04:00
Serial.println(__FILE__);
2021-01-29 06:31:58 -05:00
Serial.print("Start max31855_demo0: ");
Serial.println(MAX31855_VERSION);
Serial.println();
tc.begin();
}
2021-07-05 02:37:20 -04:00
2021-01-29 06:31:58 -05:00
void loop()
{
start = micros();
int status = tc.read();
stop = micros();
Serial.println();
Serial.print("time:\t\t");
Serial.println(stop - start);
Serial.print("stat:\t\t");
Serial.println(status);
uint32_t raw = tc.getRawData();
Serial.print("raw:\t\t");
2021-07-05 02:37:20 -04:00
uint32_t mask = 0x80000000;
for (int i = 0; i < 32; i++)
{
if ((i > 0) && (i % 4 == 0)) Serial.print(" ");
Serial.print((raw & mask) ? 1 : 0);
mask >>= 1;
}
Serial.println();
2021-01-29 06:31:58 -05:00
float internal = tc.getInternal();
Serial.print("internal:\t");
2021-07-05 02:37:20 -04:00
Serial.println(internal, 3);
2021-01-29 06:31:58 -05:00
float temp = tc.getTemperature();
Serial.print("temperature:\t");
2021-07-05 02:37:20 -04:00
Serial.println(temp, 3);
2021-01-29 06:31:58 -05:00
delay(1000);
}
2021-07-05 02:37:20 -04:00
// -- END OF FILE --