MAX31855 thermocouple to ProbeHarbor
A K-type thermocouple through a MAX31855 amplifier, for temperatures a DS18B20 cannot survive.
ESP32
3V3
GND
EN
23
VP
22
VN
TX
34
RX
35
21
32
GND
33
19
25
18
26
5
27
17
14
16
12
4
GND
0
13
2
D2
15
D3
D1
CMD
D0
5V
CLK
Wiring
| From | To board | Note |
|---|---|---|
| MAX31855 Vin | 3V3 | |
| MAX31855 GND | GND | |
| MAX31855 CS | GPIO 5 | |
| MAX31855 CLK | GPIO 18 | |
| MAX31855 DO | GPIO 19 |
Tested on this board
Not run on this board yet. Treat the wiring and code as a first draft.
Firmware, Arduino sketch for ESP32 Dev Module
/**
* MAX31855 thermocouple → ProbeHarbor push ingest (Arduino: ESP32 / ESP8266 / Pico W).
*
* Library: Adafruit MAX31855.
* Wire CS / SCK / MISO to your board; set pins below.
* Pico W: Earle Philhower Raspberry Pi Pico/RP2040 board package.
*/
#include <SPI.h>
#include <Adafruit_MAX31855.h>
#if defined(ESP32) || defined(ESP8266) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RP2350)
#include <WiFi.h>
#include <HTTPClient.h>
#else
#error "This sample targets ESP32/ESP8266 or Pico W (Earle Philhower core). Adapt WiFi/HTTP for your board."
#endif
#ifndef WIFI_SSID
#define WIFI_SSID "your-wifi"
#endif
#ifndef WIFI_PASS
#define WIFI_PASS "your-password"
#endif
#ifndef INGEST_URL
#define INGEST_URL "https://probeharbor.dev/api/ingest/YOUR_DEVICE_KEY"
#endif
#ifndef MAX_CS
#define MAX_CS 5
#endif
#ifndef MAX_SCK
#define MAX_SCK 18
#endif
#ifndef MAX_MISO
#define MAX_MISO 19
#endif
Adafruit_MAX31855 thermocouple(MAX_SCK, MAX_CS, MAX_MISO);
const unsigned long INTERVAL_MS = 60UL * 1000UL;
unsigned long lastPost = 0;
void setup() {
Serial.begin(115200);
delay(500);
if (!thermocouple.begin()) {
Serial.println("MAX31855 not found");
}
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(400);
Serial.print(".");
}
Serial.println(" WiFi ok");
}
bool postTempF(float tempF) {
HTTPClient http;
http.begin(INGEST_URL);
http.addHeader("Content-Type", "application/json");
char body[160];
snprintf(
body,
sizeof(body),
"{\"sensors\":[{\"key\":\"tc1\",\"kind\":\"temperature\",\"value\":%.2f,\"unit\":\"F\"}],\"rssi\":%d}",
tempF,
WiFi.RSSI()
);
int code = http.POST(body);
Serial.printf("POST %d\n", code);
http.end();
return code >= 200 && code < 300;
}
void loop() {
unsigned long now = millis();
if (now - lastPost < INTERVAL_MS) return;
lastPost = now;
double c = thermocouple.readCelsius();
if (isnan(c)) {
Serial.println("Thermocouple fault");
return;
}
postTempF((float)(c * 9.0 / 5.0 + 32.0));
}
Parts
| Quantity | Part | Where to buy |
|---|---|---|
| 1× | ESP32 dev board | Buy at Amazon |
| 1× | MAX31855 thermocouple amplifier breakout | |
| 1× | K-type thermocouple |
Amazon buy links may include an Associates tag, and this site may earn a commission from qualifying Amazon purchases at no extra cost to you. Adafruit links are direct.
Libraries
Adafruit MAX31855 library
Load it
- In the Arduino IDE, install the esp32 board package and pick the board named above the sketch.
- Install the libraries listed above from the Library Manager.
- Paste the sketch, choose the board's port and upload. Hold BOOT if the upload stalls at Connecting.
- Close the IDE's serial monitor, then open the bench here to watch the output.
Field notes
- Set WIFI_SSID, WIFI_PASS and INGEST_URL at the top of the sketch. The ingest URL comes from a push device under Dashboard, Devices at probeharbor.dev.