Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
Frost happens in the last hours of a calm, clear night
In an orchard, the temperature at flower height can be well below what the weather station in town reports. Blossoms are damaged at around −2 °C, so a sensor hung at that height in a small radiation shield gives you a warning when it counts.
A two-stage alert
Send an early note when the temperature falls to about +2 °C, and an urgent one near −0.5 °C. The first gives you time to prepare smoke, irrigation or covers. The node wakes every 10 minutes, measures, sends, and sleeps. If the garden is far from the router, a LoRa or an ESP-NOW relay can bridge the distance.
Do not charge a Li-ion cell below 0 °C: a TP4056 has no temperature protection. Use a charger with a thermistor or charge indoors.
A cell loses capacity in the cold, so allow a margin.
Keep the sensor out of the direct sun and away from the ground heat, otherwise the reading will be wrong.
Components
ESP32-C3 SuperMini
DS18B20 waterproof probe
18650 Li-ion cell + holder
TP4056 USB-C Li-ion charger with protection
Plastic project enclosure
Wiring
Module
Module pin
ESP32 pin
Note
DS18B20 DATA
1-Wire
GPIO5
4.7 kΩ pull-up to 3V3; probe at plant height
DS18B20 VCC / GND
3V3 / GND
Libraries
OneWire
DallasTemperature
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 <OneWire.h>
#include <DallasTemperature.h>
OneWire ow(5); DallasTemperature ds(&ow);
const float WARN_C = 2.0, FROST_C = 0.0;
const uint64_t SLEEP_US = 10ULL * 60ULL * 1000000ULL;
RTC_DATA_ATTR int level = 0; RTC_DATA_ATTR int wakes = 0; // 0 normal, 1 warning sent, 2 frost sent
void setup() {
Serial.begin(115200); ds.begin(); ds.requestTemperatures();
float t = ds.getTempCByIndex(0); wakes++;
int now = t < -100 ? 3 : (t <= FROST_C ? 2 : (t <= WARN_C ? 1 : 0));
if (now > level || (now == 0 && level > 0) || wakes % 144 == 0) {
if (connectWiFi()) {
if (now == 3) telegramSend("Frost sensor fault");
else if (now == 2) telegramSend(String("FROST: ") + String(t, 1) + " C");
else if (now == 1) telegramSend(String("Frost warning: ") + String(t, 1) + " C");
else if (level > 0) telegramSend(String("Temperature is back to normal: ") + String(t, 1) + " C");
else telegramSend(String("Frost sensor alive: ") + String(t, 1) + " C");
}
}
level = now == 3 ? level : now;
esp_sleep_enable_timer_wakeup(SLEEP_US); esp_deep_sleep_start();
}
void loop() {}
Build tips
Put the probe at plant height in the shade, not on bare metal or soil.
Use a pull-up and a short cable; long cables need shielding.
Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.
Comments
No comments yet. Share your experience or ask a question.