I've been using the max31855 with arduino for some time and I thought it's time to migrate the project to the esp platform. I dont find any max31855 shields for the Wemos D1 so my plan is to make one myself. However, when connecting the module to the wemos directly I cannot get any reedings at all with the sample code serialtermocouple from adafruit:
/***************************************************
This is an example for the Adafruit Thermocouple Sensor w/MAX31855K
Designed specifically to work with the Adafruit Thermocouple Sensor
----> https://www.adafruit.com/products/269
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 <SPI.h>
#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);
}
I set up a breadboard with only the max31855, an arduino and a wemos d1 to compare and locate the problem.
A photo of my setup:
The arduino nano (left) is connected via a logic level converter since it is running on 5V and the max31855 wants 3.3V. The esp is connected directly to the module. It is a bit hard to see but everything is color coded according to:
5V red
3.3V orange
gnd black
DO blue
CS purple
CLK yellow
It works perfectly fine on the arduino but from the esp I only get zero reedings:
Internal Temp = 0.00
C = 0.00
I've tested some different pins for the wemos but it does not seem to make any difference..
From what I've read it should not be any problem to use the esp together with the max chip. I am probably making some stupid beginners misstake...
If you have any suggestion what can be my problem, please guide me in the right direction!
Thanks in advance!
Best regards
Olle