DS18B20 with Wi-Fi portal
The same DS18B20 probe, but Wi-Fi is set from a phone through a captive portal instead of being compiled in.
Board
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 |
|---|---|---|
| DS18B20 red | 3V3 | |
| DS18B20 black | GND | |
| DS18B20 data, usually yellow | GPIO 4 | 4.7 kΩ pull-up from data to 3V3 |
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
/**
* DS18B20 → ProbeHarbor push ingest with WiFiManager (ESP32 / ESP8266).
*
* Libraries: OneWire, DallasTemperature, WiFiManager (tzapu).
* Set INGEST_URL (Devices download or #define). First boot opens a captive portal
* AP named "ProbeHarbor-Setup" — join it, enter home Wi‑Fi, reboot.
*
* USB Serial 115200 → expect POST 200 after Wi‑Fi is saved.
*/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <WiFiManager.h>
#if defined(ESP32) || defined(ESP8266)
#include <WiFi.h>
#include <HTTPClient.h>
#else
#error "This sample targets ESP32/ESP8266."
#endif
#ifndef INGEST_URL
#define INGEST_URL "https://probeharbor.dev/api/ingest/YOUR_DEVICE_KEY"
#endif
#ifndef ONE_WIRE_PIN
#define ONE_WIRE_PIN 4
#endif
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);
const unsigned long INTERVAL_MS = 60UL * 1000UL;
unsigned long lastPost = 0;
void setup() {
Serial.begin(115200);
sensors.begin();
WiFiManager wifiManager;
// wifiManager.resetSettings(); // uncomment once to clear saved credentials
wifiManager.setConfigPortalTimeout(180);
if (!wifiManager.autoConnect("ProbeHarbor-Setup")) {
Serial.println("WiFi portal timed out — restarting");
delay(2000);
ESP.restart();
}
Serial.println("WiFi ok");
}
bool postTempF(float tempF) {
if (WiFi.status() != WL_CONNECTED) return false;
HTTPClient http;
http.begin(INGEST_URL);
http.addHeader("Content-Type", "application/json");
char body[128];
snprintf(body, sizeof(body), "{\"temp1\":%.2f,\"rssi\":%d}", tempF, WiFi.RSSI());
int code = http.POST(body);
Serial.printf("POST %d %s\n", code, body);
http.end();
return code >= 200 && code < 300;
}
void loop() {
unsigned long now = millis();
if (now - lastPost < INTERVAL_MS) return;
lastPost = now;
sensors.requestTemperatures();
float c = sensors.getTempCByIndex(0);
if (c == DEVICE_DISCONNECTED_C) {
Serial.println("DS18B20 disconnected");
return;
}
float f = c * 9.0f / 5.0f + 32.0f;
postTempF(f);
}
S3
3V3
GND
3V3
TX
RST
RX
4
1
5
2
6
42
7
41
15
40
16
39
17
38
18
37
8
36
3
35
46
0
9
45
10
48
11
47
12
21
13
20
14
19
5V
GND
GND
GND
Wiring
| From | To board | Note |
|---|---|---|
| DS18B20 red | 3V3 | |
| DS18B20 black | GND | |
| DS18B20 data, usually yellow | GPIO 4 | 4.7 kΩ pull-up from data to 3V3 |
Tested on this board
Not run on this board yet. Treat the wiring and code as a first draft.
Firmware, Arduino sketch for ESP32S3 Dev Module
/**
* DS18B20 → ProbeHarbor push ingest with WiFiManager (ESP32 / ESP8266).
*
* Libraries: OneWire, DallasTemperature, WiFiManager (tzapu).
* Set INGEST_URL (Devices download or #define). First boot opens a captive portal
* AP named "ProbeHarbor-Setup" — join it, enter home Wi‑Fi, reboot.
*
* USB Serial 115200 → expect POST 200 after Wi‑Fi is saved.
*/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <WiFiManager.h>
#if defined(ESP32) || defined(ESP8266)
#include <WiFi.h>
#include <HTTPClient.h>
#else
#error "This sample targets ESP32/ESP8266."
#endif
#ifndef INGEST_URL
#define INGEST_URL "https://probeharbor.dev/api/ingest/YOUR_DEVICE_KEY"
#endif
#ifndef ONE_WIRE_PIN
#define ONE_WIRE_PIN 4
#endif
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);
const unsigned long INTERVAL_MS = 60UL * 1000UL;
unsigned long lastPost = 0;
void setup() {
Serial.begin(115200);
sensors.begin();
WiFiManager wifiManager;
// wifiManager.resetSettings(); // uncomment once to clear saved credentials
wifiManager.setConfigPortalTimeout(180);
if (!wifiManager.autoConnect("ProbeHarbor-Setup")) {
Serial.println("WiFi portal timed out — restarting");
delay(2000);
ESP.restart();
}
Serial.println("WiFi ok");
}
bool postTempF(float tempF) {
if (WiFi.status() != WL_CONNECTED) return false;
HTTPClient http;
http.begin(INGEST_URL);
http.addHeader("Content-Type", "application/json");
char body[128];
snprintf(body, sizeof(body), "{\"temp1\":%.2f,\"rssi\":%d}", tempF, WiFi.RSSI());
int code = http.POST(body);
Serial.printf("POST %d %s\n", code, body);
http.end();
return code >= 200 && code < 300;
}
void loop() {
unsigned long now = millis();
if (now - lastPost < INTERVAL_MS) return;
lastPost = now;
sensors.requestTemperatures();
float c = sensors.getTempCByIndex(0);
if (c == DEVICE_DISCONNECTED_C) {
Serial.println("DS18B20 disconnected");
return;
}
float f = c * 9.0f / 5.0f + 32.0f;
postTempF(f);
}
C3
GND
GND
3V3
TX
3V3
RX
2
GND
3
9
GND
8
RST
GND
GND
7
0
6
1
5
10
4
GND
GND
5V
18
5V
19
GND
GND
Wiring
| From | To board | Note |
|---|---|---|
| DS18B20 red | 3V3 | |
| DS18B20 black | GND | |
| DS18B20 data, usually yellow | GPIO 4 | 4.7 kΩ pull-up from data to 3V3 |
Tested on this board
Not run on this board yet. Treat the wiring and code as a first draft.
Firmware, Arduino sketch for ESP32C3 Dev Module
/**
* DS18B20 → ProbeHarbor push ingest with WiFiManager (ESP32 / ESP8266).
*
* Libraries: OneWire, DallasTemperature, WiFiManager (tzapu).
* Set INGEST_URL (Devices download or #define). First boot opens a captive portal
* AP named "ProbeHarbor-Setup" — join it, enter home Wi‑Fi, reboot.
*
* USB Serial 115200 → expect POST 200 after Wi‑Fi is saved.
*/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <WiFiManager.h>
#if defined(ESP32) || defined(ESP8266)
#include <WiFi.h>
#include <HTTPClient.h>
#else
#error "This sample targets ESP32/ESP8266."
#endif
#ifndef INGEST_URL
#define INGEST_URL "https://probeharbor.dev/api/ingest/YOUR_DEVICE_KEY"
#endif
#ifndef ONE_WIRE_PIN
#define ONE_WIRE_PIN 4
#endif
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);
const unsigned long INTERVAL_MS = 60UL * 1000UL;
unsigned long lastPost = 0;
void setup() {
Serial.begin(115200);
sensors.begin();
WiFiManager wifiManager;
// wifiManager.resetSettings(); // uncomment once to clear saved credentials
wifiManager.setConfigPortalTimeout(180);
if (!wifiManager.autoConnect("ProbeHarbor-Setup")) {
Serial.println("WiFi portal timed out — restarting");
delay(2000);
ESP.restart();
}
Serial.println("WiFi ok");
}
bool postTempF(float tempF) {
if (WiFi.status() != WL_CONNECTED) return false;
HTTPClient http;
http.begin(INGEST_URL);
http.addHeader("Content-Type", "application/json");
char body[128];
snprintf(body, sizeof(body), "{\"temp1\":%.2f,\"rssi\":%d}", tempF, WiFi.RSSI());
int code = http.POST(body);
Serial.printf("POST %d %s\n", code, body);
http.end();
return code >= 200 && code < 300;
}
void loop() {
unsigned long now = millis();
if (now - lastPost < INTERVAL_MS) return;
lastPost = now;
sensors.requestTemperatures();
float c = sensors.getTempCByIndex(0);
if (c == DEVICE_DISCONNECTED_C) {
Serial.println("DS18B20 disconnected");
return;
}
float f = c * 9.0f / 5.0f + 32.0f;
postTempF(f);
}
Parts
| Quantity | Part | Where to buy |
|---|---|---|
| 1× | ESP32 dev board | Buy at Amazon |
| 1× | DS18B20 waterproof probe | Buy at Adafruit |
| 1× | 4.7 kΩ resistor | Buy at Amazon |
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
OneWire, DallasTemperature, WiFiManager (tzapu)
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 INGEST_URL at the top of the sketch. Wi-Fi is not compiled in.
- On first boot, join the ProbeHarbor-Setup network from a phone, enter your home Wi-Fi and let the board restart.