我已经将 max31855 与 arduino 一起使用了一段时间,我认为是时候将项目迁移到 esp 平台了。我没有找到适用于 Wemos D1 的任何 max31855 防护罩,所以我的计划是自己制作一个。但是,当将模块直接连接到 wemos 时,我无法使用 adafruit 的示例代码 serialtermocouple 获得任何信号:
代码:
全选/***************************************************
This is an example for the Adafruit Thermocouple Sensor w/MAX31855K
Designed specifically to work with the Adafruit Thermocouple Sensor
These displays use SPI to communicate, 3 pins are required to
interface
Adafruit invests
time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include
#include "Adafruit_MAX31855.h"
// Default connection is using software SPI, but comment and uncomment one of
// the two examples below to switch between software SPI and hardware SPI:
// Example creating a thermocouple instance with software SPI on any three
// digital IO pins.
//arduino nano
//#define MAXDO 4
//#define MAXCS 5
//#define MAXCLK 3
// esp8266
#define MAXDO D6//12
#define MAXCS D1//5
#define MAXCLK D5//14
// initialize the Thermocouple
Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO);
// Example creating a thermocouple instance with hardware SPI (Uno/Mega only)
// on a given CS pin.
//#define MAXCS 10
//Adafruit_MAX31855 thermocouple(MAXCS);
#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif
void setup() {
#ifndef ESP8266
while (!Serial); // will pause Zero, Leonardo, etc until serial console opens
#endif
Serial.begin(9600);
Serial.println("MAX31855 test");
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
// basic readout test, just print the current temp
Serial.print("Internal Temp = ");
Serial.println(thermocouple.readInternal());
double c = thermocouple.readCelsius();
if (isnan(c)) {
Serial.println("Something wrong with thermocouple!");
} else {
Serial.print("C = ");
Serial.println(c);
}
//Serial.print("F = ");
//Serial.println(thermocouple.readFarenheit());
delay(1000);
}
我搭建了一个只有max31855、一个arduino和一个wemos d1的面包板来对比定位问题。
我的设置照片:
arduino nano(左)通过逻辑电平转换器连接,因为它在 5V 上运行,而 max31855 需要 3.3V。esp 直接连接到模块。有点难看,但所有颜色都根据以下颜色编码:
5V 红色
3.3V 橙色
gnd 黑色
DO 蓝色
CS 紫色
CLK 黄色
它在 arduino 上工作得很好,但从 esp 我只得到零读数:
我已经为 wemos 测试了一些不同的引脚,但似乎没有任何区别。
根据我的阅读,将 esp 与 max 芯片一起使用应该没有问题。