Akkus: Polung beachten, geschützte Zellen und Ladegeräte mit Schutz verwenden, beschädigte Zellen nie unbeaufsichtigt laden.
Wenn das Temperaturprotokoll das Produkt ist
Anders als ein einfacher Alarm führt dieser Logger Buch: wann ein Kühlschrank für Medikamente oder Lebensmittel im Bereich lag und wann nicht. Das hilft für einen Laden, ein Behandlungszimmer oder einen Gartenkeller. Eine kleine Batterie hält die Aufzeichnung durch einen Stromausfall.
Die Aufzeichnung vertrauenswürdig machen
Speichern Sie jeden Messwert mit Zeitstempel im Flash-Dateisystem und exportieren Sie als CSV. Zwischen den Proben gehen Sie in den Deep-Sleep, mit einem Intervall von ein bis fünf Minuten. Nach dem Schlaf muss die Uhr stimmen, synchronisieren Sie daher per NTP, sobald WLAN da ist. Der DS18B20 ist mit etwa ±0,5 °C spezifiziert, und jede Sonde lässt sich in Eiswasser prüfen, das nahe 0 °C zeigen sollte.
Das Display zeigt Minimum und Maximum seit dem letzten Reset, wie bei einem professionellen Thermometer.
Für Medikamente liegt der typische Bereich bei 2 bis 8 °C; setzen Sie die Alarmgrenzen nach Ihren eigenen Anforderungen.
Behalten Sie das Protokoll, wenn das Netz weg ist. Laden Sie hoch, wenn es zurückkehrt.
Komponenten
ESP32-C3 SuperMini
DS18B20 waterproof probe
OLED 0.96" 128x64 I2C SSD1306
18650 Li-ion cell + holder
TP4056 USB-C Li-ion charger with protection
Verdrahtung
Modul
Modul-Pin
ESP32-Pin
Hinweis
DS18B20 DATA
1-Wire
GPIO5
4.7 kΩ pull-up to 3V3
OLED SDA / SCL
I2C
GPIO8 / GPIO9
0x3C
Battery
3.7 V Li-ion
TP4056 charger, battery to the 5V pin of the board
use a protected cell; a boost or the 3V3 pin variant needs a low-dropout setup
Bibliotheken
OneWire
DallasTemperature
Adafruit SSD1306
Adafruit GFX Library
Code
#include <WiFi.h>
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";
bool connectWiFi(uint32_t timeoutMs = 20000) {
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
uint32_t t0 = millis();
while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
delay(250);
Serial.print(".");
}
Serial.println();
if (WiFi.status() == WL_CONNECTED) {
Serial.print("IP: ");
Serial.println(WiFi.localIP());
return true;
}
return false;
}
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
const char* TG_TOKEN = "123456:ABC-YOUR-BOT-TOKEN"; // from @BotFather
const char* TG_CHAT = "YOUR_CHAT_ID";
// Keep the text free of double quotes and line breaks (it is inserted into JSON).
bool telegramSend(const String& text) {
if (WiFi.status() != WL_CONNECTED) return false;
WiFiClientSecure client;
client.setInsecure(); // simple; pin the certificate for production
HTTPClient http;
String url = String("https://api.telegram.org/bot") + TG_TOKEN + "/sendMessage";
if (!http.begin(client, url)) return false;
http.addHeader("Content-Type", "application/json");
String body = String("{"chat_id":"") + TG_CHAT + "","text":"" + text + ""}";
int code = http.POST(body);
http.end();
return code == 200;
}
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
OneWire ow(5); DallasTemperature ds(&ow);
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const float LIMIT_HIGH = -10.0; // freezer: -10; use 8.0 for a fridge
const uint64_t SLEEP_US = 5ULL * 60ULL * 1000000ULL;
RTC_DATA_ATTR float tMin = 99, tMax = -99; RTC_DATA_ATTR int wakeCount = 0; RTC_DATA_ATTR int alertSent = 0;
void setup() {
Serial.begin(115200); Wire.begin(8, 9); ds.begin(); ds.requestTemperatures();
float t = ds.getTempCByIndex(0); wakeCount++;
if (t > -100) { tMin = min(tMin, t); tMax = max(tMax, t); }
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.clearDisplay(); oled.setTextColor(WHITE);
oled.setTextSize(2); oled.setCursor(0, 0); oled.printf("%.1f C", t);
oled.setTextSize(1); oled.setCursor(0, 28); oled.printf("min %.1f max %.1f", tMin, tMax); oled.setCursor(0, 40); oled.printf("wake #%d", wakeCount); oled.display();
bool bad = t > LIMIT_HIGH || t < -100;
if (bad && alertSent < 3 && connectWiFi()) { telegramSend(String("Cold chain alert: ") + (t < -100 ? "sensor fault" : String(t, 1) + " C")); alertSent++; }
if (!bad) alertSent = 0;
if (wakeCount % 144 == 0 && connectWiFi()) telegramSend(String("Logger alive. Last 12 h min/max: ") + String(tMin, 1) + " / " + String(tMax, 1));
delay(3000); oled.ssd1306_command(SSD1306_DISPLAYOFF);
esp_sleep_enable_timer_wakeup(SLEEP_US); esp_deep_sleep_start();
}
void loop() {}
Bautipps
Den Fühler in eine Flasche mit Wasser oder Glykol legen, um Fehlalarme beim Türöffnen zu vermeiden.
Das OLED ist bei jedem Aufwachen nur kurz an, um den Akku zu schonen.
230 V Netzspannung kann tödlich sein. Arbeiten Sie spannungsfrei, nutzen Sie zertifizierte isolierte Module im Gehäuse, sichern Sie die Leitung ab und fragen Sie im Zweifel eine Elektrofachkraft.
Kommentare
Noch keine Kommentare. Teilen Sie Ihre Erfahrung oder stellen Sie eine Frage.