Frost alert for orchard and greenhouse (Telegram) A battery sensor wakes every 10 minutes, and sends a warning near freezing, an alert at 0 °C and a notice when it recovers.
Level: Beginner Board: ESP32-C3 SuperMini Climate
⚠ Safety Li-ion cells: watch polarity, use protected cells and a charger with protection, never leave a damaged cell charging unattended.
What you need Buy the parts kit · Estimated total: $11.80
ESP32-C3 SuperMini × 1
$2.50
DS18B20 waterproof probe × 1
$1.50
18650 Li-ion cell + holder × 1
$4.00
TP4056 USB-C Li-ion charger with protection × 1
$0.80
Plastic project enclosure × 1
$3.00
Some links are affiliate links: we may earn a commission at no extra cost to you.
Libraries Arduino IDE → Tools → Manage Libraries, then install:
Code frost-alert.ino Copy Download .ino
#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() {}Flash a ready firmware from the browser Paste your error into the AI Error Doctor
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. ← ← All projects
Related ideas ⚠ Caution Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
A small outdoor station on a Li-ion cell and a solar panel that reports temperature, humidity and pressure trend every few minutes.
⚠ Caution Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
An ESP32-C3 on a Li-ion cell that advertises temperature over BLE and lasts months on deep sleep.
⛔ High risk 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.
A battery-backed ESP32-C3 that detects when mains disappears and sends a message with the time of the blackout.
Comments
No comments yet. Share your experience or ask a question.