Skip to Content

Episode 1 — Pump failure alerts on your phone via Telegram with an ESP32 PLC

The complete prompt so Claude Code writes the firmware for you: alerts in seconds, no SCADA, no server
July 21, 2026 by
Technical Team

From Prompt to Plant is the series where we share, openly and in full, the prompts that let you program an Industrial Shields PLC with Claude Code. The AI writes the code; you validate it on a test bench.

⚡ Want the prompts for YOUR application? Open the PLC Prompt Generator →

The problem

A pump or a machine fails and nobody notices until someone walks past — or until production has been stopped for hours. The classic solution involves a SCADA or an intermediate server. Not here: the PLC itself talks directly to the Telegram API and the alert reaches the maintenance phone in seconds.

The hardware

An Industrial Shields ESP32 PLC 14, with digital input I0_0 wired to the dry contact of the pump's thermal relay (or to the 24V signal of a pressure switch). Nothing else.

The prompt (copy it in full)

Paste it as-is into Claude Code. If your model is another member of the ESP32 PLC family, change it in the first line: the I/O mapping changes between models.

I want to program an Industrial Shields ESP32 PLC 14 to send a Telegram
alert when a pump fails.

Hardware: Industrial Shields ESP32 PLC 14 (if your model is another member of
the ESP32 PLC family — 19R, 21, 38R, 42, 57R or 58 — write yours here: the
I/O mapping changes between models). Digital input I0_0 receives the failure
signal: a dry contact from the pump's thermal relay (or, if in your case it
is a 24V signal from a pressure switch, note it in the code with a comment so
it can be adapted).

Important: also tell me which board I must select in Arduino IDE (Industrial
Shields boards package) so that I0_0 maps to the correct physical pin of my
model, and if that input goes by another name on my board, say so.

Behaviour I need:
1. WiFi with non-blocking reconnection: if the network drops, the ESP32 must
   keep reading the input and controlling normally, retrying the connection
   in the background without delay() or blocking the loop.
2. When I0_0 goes from OK to failure, send a Telegram message with the time
   and the affected machine.
3. When the failure clears (I0_0 back to OK), send another message confirming
   it is resolved.
4. If the failure persists, send a reminder every 30 minutes, no more often.
5. Never send a message on every loop iteration: only on state changes and on
   the 30-minute reminders.
6. Use the HTTPClient library over HTTPS against the Telegram Bot API
   (api.telegram.org, sendMessage method), with BOT_TOKEN and CHAT_ID as
   constants at the top of the code, clearly marked as placeholders.

At the end of the code, explain to me:
- How input I0_0 is physically wired (polarity, and what changes if the
  contact is NO or NC).
- How I get the BOT_TOKEN by talking to @BotFather on Telegram.
- How I get the CHAT_ID of my chat or group.

Before anything else, tell me how to validate the system on a test bench,
simulating the failure with a manual switch on I0_0, before connecting it to
the real machine.

What you get

Claude Code delivers the complete sketch, ready to upload with Arduino IDE: the state logic (failure raised / failure resolved / reminder every 30 minutes, no spam), non-blocking WiFi reconnection and the HTTPS calls to Telegram. It also explains the I0_0 wiring (NO or NC contact), how to create the bot with @BotFather and how to get your CHAT_ID.

Before connecting it to the real machine

House rule: the AI writes the code, the technician validates it. First build a test bench with a manual switch on I0_0 simulating the failure, check the three messages (failure, resolved, reminder) and the WiFi reconnection, and only then wire the real contact.

Time

Before: between half a day and a full day of programming. With this: prompt, code and bench validation in under an hour.

Variant

If your plant already runs Node-RED, the node-red-contrib-telegrambot node does the same from the server, without touching firmware, and it also accepts incoming commands from Telegram towards the machine.

⚡ And for your own application?

This prompt solves one specific case. Answer five questions about your project — your I/O, your protocol, your control logic — and get the full prompt sequence, built with the same methodology as this series. Free.

Open the PLC Prompt Generator →

Every week, one real, verified prompt. Next episode: publishing your machine's variables over MQTT in JSON — the gateway to Industry 4.0. And if you want the full prompt archive in your inbox, subscribe to the From Prompt to Plant newsletter.

​Search in our Blog

Technical Team July 21, 2026
Share this post
Tags

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.

PLC Comparison