Berry on ESP32
Rules are a sentence; sometimes you need a
paragraph. For ESP32 devices, Tasmota
carries one: Berry, a small, fast
scripting language designed for embedded
systems, embedded in every tasmota32
build. The ESP8266 cannot have it — this is
the sharpest dividing line between the chip
families. The lab verified Berry's place in
the project directly: the Berry interpreter
and its Tasmota libraries ship in the
source tree under lib/libesp32/berry
(with berry_animation and berry_custom
alongside), a folder that only ESP32 builds
draw from. The official documentation says
it in one line: "Berry Scripting is
included in all tasmota32 builds. It is NOT
supported on ESP82xx."
What Berry is for
Berry scripts are programs that run inside the firmware with access to nearly all of it. From the official documentation, the working surface includes:
- Driving Tasmota itself —
tasmota.cmd("Dimmer 60")runs any command, and helpers liketasmota.get_power()/set_power()wrap the common ones. - Reacting to events —
tasmota.add_rule("Dimmer>50", fn)registers a function against the same trigger language rules use, except the "action" is now real code: maths, state, decisions. - Time —
tasmota.set_timer(ms, fn)for callbacks, andtasmota.add_cron(...)for calendar schedules beyond what the 16 hardware timers express. - Building things rules can't: complete device drivers (including I2C drivers for new sensors), light animations frame by frame, little state machines, protocol translators.
Scripts are edited and run from the
Berry Scripting Console (under the
device's Configuration menu), which is a
REPL: type an expression, see the result.
A file named autoexec.be on the device's
filesystem runs at every boot, which is how
scripts become permanent.
Rules or Berry?
Keep both in their lanes. If the behaviour
fits in one ON … DO … ENDON line, write
the rule: it is inspectable on the device,
survives in the settings backup, and fails
simply. Reach for Berry when the behaviour
has real logic — calculations, more than a
couple of states, data massaging, driving
hardware in a loop — and accept that you
are now maintaining a program, with a
program's debugging. On ESP8266 devices the
choice is made for you, which is worth
remembering when a "simple" automation
starts growing: that growth is an argument
for the ESP32 version of the device, not
for cleverer rules.