mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-12 09:36:59 +00:00
175 lines
5.6 KiB
Plaintext
175 lines
5.6 KiB
Plaintext
.. These P001 commands should be moved to core (P000)...
|
|
|
|
:ref:`P000_page` |P000_status|
|
|
|
|
Supported hardware: |P000_usedby_GPIO|
|
|
|
|
.. csv-table::
|
|
:header: "Command (GPIO/Value)", "Extra information"
|
|
:widths: 20, 30
|
|
|
|
"
|
|
``GPIO,<GPIO>,<state>``
|
|
|
|
GPIO: 0 ... <max supported GPIO pin>
|
|
|
|
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 ... <max supported GPIO pin>
|
|
|
|
","
|
|
**Toggle on/off.**.
|
|
Toggle the current (output) state of the given GPIO pin.
|
|
When executed, it changes the pin mode to output, for output-capable GPIO pins.
|
|
"
|
|
"
|
|
``LongPulse,<GPIO>,<state>,<duration>``
|
|
|
|
``LongPulse,<GPIO>,<state>,<duration high>,<duration low>``
|
|
|
|
``LongPulse,<GPIO>,<state>,<duration high>,<duration low>,<nr of repeats>``
|
|
|
|
GPIO: All GPIO pins with output capabilities
|
|
|
|
State: 1/0
|
|
|
|
Duration low/high: 1 ... 999 S
|
|
|
|
Nr of Repeats: ``-1`` = continous repeat, ``0`` = only single pulse
|
|
","
|
|
**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.
|
|
|
|
Changed: 2022/10/15
|
|
|
|
- Added ``<duration low>`` and repeat functionality
|
|
- On ESP8266 it now uses the way more accurate ``startWaveform`` function for high/low durations upto 15 seconds.
|
|
|
|
Example: ``longpulse,2,1,1,1,-1`` Continuous blinking of the onboard LED at 0.5 Hz. (50% duty cycle)
|
|
"
|
|
"
|
|
``LongPulse_mS,<GPIO>,<state>,<duration>``
|
|
|
|
``LongPulse_mS,<GPIO>,<state>,<duration high>,<duration low>``
|
|
|
|
``LongPulse_mS,<GPIO>,<state>,<duration high>,<duration low>,<nr of repeats>``
|
|
|
|
GPIO: All GPIO pins with output capabilities
|
|
|
|
State: 1/0
|
|
|
|
Duration low/high: 1 ... 15000 msec
|
|
|
|
Nr of Repeats: ``-1`` = continous repeat, ``0`` = only single pulse
|
|
","
|
|
**To send a (non blocking) *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.
|
|
|
|
Changed: 2022/10/15
|
|
|
|
- Added ``<duration low>`` and repeat functionality
|
|
- On ESP8266 it now uses the way more accurate ``startWaveform`` function for high/low durations upto 15 seconds.
|
|
|
|
Example: ``longpulse_ms,2,1,500,500,-1`` Continuous blinking of the onboard LED at 1 Hz. (50% duty cycle)
|
|
"
|
|
"
|
|
``Pulse,<GPIO>,<state>,<duration>``
|
|
|
|
GPIO: All GPIO pins with output capabilities
|
|
|
|
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>``
|
|
|
|
ESP8266 GPIO: 0 ... **15**
|
|
|
|
ESP32 GPIO: All GPIO pins with output capabilities
|
|
|
|
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 ID>,<GPIO>,<position>``
|
|
|
|
ESP8266 GPIO: 0 ... **15**
|
|
|
|
ESP32 GPIO: All GPIO pins with output capabilities
|
|
|
|
Servo: 1/2
|
|
|
|
Position: -180 ... 180 (see warning below)
|
|
","
|
|
**To control a servo motor.**
|
|
Builds before 2020/11/22 only supported a maximum of 2 servos. Later builds allow more and no longer need the ``servo ID`` as a new ID is generated based on the GPIO pin used.
|
|
To remain compatible with existing rules, the number of parameters has not changed.
|
|
|
|
.. 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,G,<GPIO>``
|
|
|
|
GPIO: 0 ... <max supported GPIO pin>
|
|
","
|
|
**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.
|
|
"
|
|
"
|
|
``UnMonitor,G,<GPIO>``
|
|
|
|
GPIO: 0 ... <max supported GPIO pin>
|
|
","
|
|
**To cancel the monitor of a GPIO state.**
|
|
By the use of the command you will stop receiving events when the GPIO state of that pin is changed from 1 to 0 and from 0 to 1.
|
|
"
|
|
"
|
|
``Status,G,<GPIO>``
|
|
|
|
GPIO: 0 ... <max supported GPIO pin>
|
|
","
|
|
**Returns the status of a pin.**
|
|
By the use of the command you will receive the status of the relevant pin.
|
|
"
|