Command Reference

ESP Easy offers a set of commands to control hardware devices and provide some basic local control using rules. There are several ways to launch commands on ESP Easy:

Protocol Syntax Extra information
HTTP http://<espeasyip>/control?cmd= <command> Send commands over the HTTP protocol.
MQTT <MQTT subscribe template>/cmd with payload: <command> Send commands over the MQTT protocol.
Serial (TTL) <command> Send commands using serial (RX/TX). Just type the <command>
UDP SendTo,<unit nr>, <command> Send commands from one ESP Easy unit to another. Setup UDP ESP Easy peer-2-peer controller first.
Rules <command> Internally within ESP Easy. Just enter the <command> within an event block or conditional block.

Commands are divided into several classes:

Internal can be run from serial and rules engine

Rules can be run from serial and rules engine

Plugin can be run from serial, rules engine, HTTP, MQTT

Special can be used from any source

Commands listed

(core commands and plugin commands)

Command Class Purpose / Syntax
Debug Internal

Change Serial port debug level

Debug,<1-4>

IP Internal

Change IP address

IP,<IP address>

Let Internal

Set the value of n (1..16).

Let,<n>,<value>

LogEntry Internal

Add string to log

LogEntry,<string>

Name Internal

Set the name of the unit

Name,<new name>

Password Internal

Set the password of the unit

Password,<new password>

Reboot Internal

Reboot the ESP

Reboot

Reset Internal

Reset config to factory default. Caution, all settings will be lost!

Reset

Reset Flash Write Counter Internal

Reset flash write to zero.

ResetFlashWriteCounter

Rules Internal

Rules enabled (1) or rules disabled (0)

Rules,<1/0>

Save Internal

Save config to persistent flash memory

Save

Settings Internal

Show settings on serial terminal

Settings

TaskClear Internal

Delete the given task/device

TaskClear,<task/device nr>

TaskClearAll Internal

Delete ALL task/device

TaskClearAll

TaskRun Internal

Run/excecute the given task/device, use to manually force an update/read of the task.

TaskRun,<task/device nr>

Unit Internal

Set the unit number

Unit,<unit number>

WifiAPKey Internal

Change AP WPA key

WifiAPKey,<WPA key>

WifiAPMode Internal

Force the unit into AP mode.

WifiAPMode

WifiConnect Internal

Connect to configured wireless network

WifiConnect

WifiDisconnect Internal

Disconnect from wireless network

WifiDisconnect

WifiKey Internal

Change WPA key for primary WiFi

WifiKey,<Wifi WPA key>

WifiKey2 Internal

Change WPA key for secondary WiFi

WifiKey2,<Wifi WPA key>

WifiScan Internal

Scan Wireless networks

WifiScan

WifiSSID Internal

Change SSID to connect as primary WiFi

WifiSSID,<SSID>

WifiSSID2 Internal

Change SSID to connect as secondry WiFi

WifiSSID2,<SSID>

Delay Rules

Delay rule processing

Delay,<delay in milliSeconds>

Publish Rules

Send command using MQTT broker service

Publish,<topic>,<value>

SendTo Rules

Send command to other ESP (using UDP)

SendTo,<unit nr>,<command>

SendToHTTP Rules

Send command to other network device using HTTP

SendToHTTP,<IP address>,<Portnumber>,<command>

SendToHTTP,<domain>,<Portnumber>,</url>

SendToUDP Rules

Send command to other network device using UDP (non-ESP Easy units)

SendToUDP,<IP address>,<Portnumber>,<command>

TaskValueSet Rules

Set values on a Dummy Task (device)

TaskValueSet,<task/device nr>,<value nr>,<value/formula>

TimerSet Rules

Start a timed event

TimerSet,<timernr>,<timeInSeconds>

TimerSet,<timernr>,0 disables the timer

Event Special

Create an event, it’s possible to send a float value along as well.

See event syntax below…

Event command

The event command is a special command used to trigger an event. This event can then be acted upon from the rules. You can send 0..4 event values along with the event.

Event / Info

Event,SingleEvent

The event (triggered by any of the launch ways) will make the unit publish a message.

Rules example

on SingleEvent do
  Publish,%sysname%/Info,A single event has been triggered!
endon

Event,SingleValue=123

The event value 123 is intercepted and published.

Rules example

on SingleValue do
  Publish,%sysname%/Info,An event has been sent (%eventvalue%)!
endon

Event,Multi=1,2,3,99

The event value 99 (4) is intercepted and the rule TaskValueSet... is triggered, value of task 12 value 1 is then 1 + 2 = 3 or 1 - 2 = -1.

Rules example

on Multi do
  if %eventvalue4%=99
    TaskValueSet,12,1,[%eventvalue1%+%eventvalue2%]
  else
    TaskValueSet,12,1,[%eventvalue3%-%eventvalue2%]
  endif
endon

Internal GPIO handling and ringtones

Internal GPIO handling NORMAL

Supported hardware: Relay, Servo motor

Command (GPIO/Value) Extra information

GPIO,<GPIO>,<state>

GPIO: 0 … 16

State:

2 (HIGH-Z, input)

1 (HIGH, output)

0 (LOW, output)

Basic on/off.. We can control a pin with simple http URL commands. To change the pin to high or low steady output. Setting GPIO to 2 means that it will be able to detect low level relays (with high impedance, Z).

GPIOtoggle,<GPIO>

GPIO: 0 … 16

Toggle on/off.. Toggle the current (output) state of the given GPIO pin. This will only be executed on pins set to be in output mode.

LongPulse,<GPIO>,<state>,<duration>

GPIO: 0 … 16

State: 1/0

Duration: 1 … 999 S

To send a *long* pulse to a certain pin.. A long pulse is basically the same as the plain pulse. Duration is defined in seconds, which makes it more suitable for longer duration. This command is not blocking, but will send 2 events to start and stop the pulse. This may have some variation depending on the system load of the module. Variation is typically up-to 10 msec, but may be up-to a second, depending on active plugins and controllers performing blocking operations.

LongPulse_mS,<GPIO>,<state>,<duration>

GPIO: 0 … 16

State: 1/0

Duration: 10 … 15000 msec

To send a *long* pulse to a certain pin. A LongPulse_mS is the same as the regular LongPulse. The only difference is the time base in milliseconds rather than in seconds.

Pulse,<GPIO>,<state>,<duration>

GPIO: 0 … 16

State: 1/0

Duration: 0 … 1000 msec

To send a *short* pulse to a certain pin. Example to send an active high (1) pulse on GPIO 14 for 500 mSeconds. Pulse duration is in milliseconds. State is 1 or 0. N.B. this is a blocking call, meaning no other actions will be performed during the pulse.

PWM,<GPIO>,<duty>

PWM,<GPIO>,<duty>,<duration>

PWM,<GPIO>,<duty>,<duration>,<frequency>

GPIO: 0 … 15

Duty: 0 … 1023

Duration: 100 … 15000 msec (optional)

Frequency: 100 … 40000 Hz (optional)

To set a certain PWM level. If you have set a certain GPIO to a PWM level and want to use it as a regular HIGH/LOW pin you need to reset by setting the PWM level to 0.

Duration (in msec) parameter will create a fading. Value of 0 will not set a duration.

Frequency (in Hz) will be set to 1000 Hz when not given. Frequencies above 30 kHz are not stable and will likely crash the ESP.

Servo,<servo>,<GPIO>,<position>

GPIO: 0 … 15

Servo: 1/2

Position: -180 … 180 (see warning below)

To control a servo motor. We currently support a maximum of two servo motors so you can build a pan & tilt device if you like.

Warning

Most servos are not able to turn full 360°! Normally the servos are able to go from -90° to 90°, some rare servos do allow for -135° to 135°.

A position value of 9000 will stop the PWM signal. This can be useful to save energy on servos which do not need power to remain at the same position.

Monitor,<GPIO>

GPIO: 0 … 16

To monitor a GPIO state. By the use of the command you will receive events when the GPIO state of that pin is changed from 1 to 0 and from 0 to 1.

GPIOtoggle,<GPIO>

GPIO: 0 … 16

To toggle a GPIO state. With this command you can change the given state of a pin from either 1 to 0 or from 0 to 1.

Internal GPIO handling NORMAL

Supported hardware: Buzzer (RTTTL), Piezo element, Speaker (Ringtones etc.)

Command (GPIO/Value) Extra information

tone,<gpio>,<tone>,<duration>

GPIO: 12 … 16

Tone: 20 … 13000 Hz

Duration: 100 … 15000 msec

You should try to use GPIO 12…16 since these generally aren’t used. The recommended tone range is 20 Hz … 13 kHz. Up-to 40 kHz should be possible to generate, but will be inaudible for humans. Frequencies above 30 kHz are not stable and will likely crash the ESP.

Duration is set in ms.

N.B. tones with a duration less than 50 msec will be blocking. Longer duration will use the scheduler, which may cause some fluctuations in the duration.

rtttl,<gpio>,<value>

GPIO: 12 … 16

Value: d=<duration>,o=<octave>,b=<tempo>,<notes…>

You should try to use GPIO 12…16 since these generally aren’t used by ESP internal functions. N.B. Playing a tune is blocking for as long as the tune is playing.

Value can be defined like <name_of_melody:duration,octave,beat,notes….>

For example: rtttl,14,test:d=8,o=5,b=180,c6,b,c6,p,g,g-

More RTTTL Ringtone Downloads

Plugin based commands

Besides the internal commands there’s also plugin specific commands. These are listed here below.

P052 Gases - CO2 Senseair

Command (GPIO/Value) Extra information

senseair_setrelay,<value>

Value:

1 will set the relay to ON.

0 will set the relay to OFF.

-1 will remove control over relay.

Used in tSense (K70) to set the relay to either 1 or 0. Observe that using this command will take over the control of the relay from the tSense. If you want to give the control back you use the -1 value.