2021-02-25 08:52:48 +00:00
|
|
|
# Usermod Animated Staircase
|
2022-12-10 15:12:55 +00:00
|
|
|
This usermod makes your staircase look cool by illuminating it with an animation. It uses
|
2021-02-25 08:52:48 +00:00
|
|
|
PIR or ultrasonic sensors at the top and bottom of your stairs to:
|
|
|
|
|
2022-12-11 17:03:35 +00:00
|
|
|
- Light up the steps in the direction you're walking.
|
2021-02-25 08:52:48 +00:00
|
|
|
- Switch off the steps after you, in the direction of the last detected movement.
|
|
|
|
- Always switch on when one of the sensors detects movement, even if an effect
|
2022-12-10 15:12:55 +00:00
|
|
|
is still running. It can gracefully handle multiple people on the stairs.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
The Animated Staircase can be controlled by the WLED API. Change settings such as
|
2022-12-10 15:12:55 +00:00
|
|
|
speed, on/off time and distance by sending an HTTP request, see below.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
## WLED integration
|
2024-01-03 20:08:02 +00:00
|
|
|
To include this usermod in your WLED setup, you have to be able to [compile WLED from source](https://kno.wled.ge/advanced/compiling-wled/).
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
Before compiling, you have to make the following modifications:
|
|
|
|
|
|
|
|
Edit `usermods_list.cpp`:
|
|
|
|
1. Open `wled00/usermods_list.cpp`
|
|
|
|
2. add `#include "../usermods/Animated_Staircase/Animated_Staircase.h"` to the top of the file
|
|
|
|
3. add `usermods.add(new Animated_Staircase());` to the end of the `void registerUsermods()` function.
|
|
|
|
|
2022-12-10 15:12:55 +00:00
|
|
|
You can configure usermod using the Usermods settings page.
|
|
|
|
Please enter GPIO pins for PIR or ultrasonic sensors (trigger and echo).
|
2021-05-07 10:41:39 +00:00
|
|
|
If you use PIR sensor enter -1 for echo pin.
|
2022-12-10 15:12:55 +00:00
|
|
|
Maximum distance for ultrasonic sensor can be configured as the time needed for an echo (see below).
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
## Hardware installation
|
2022-12-10 15:12:55 +00:00
|
|
|
1. Attach the LED strip to each step of the stairs.
|
|
|
|
2. Connect the ESP8266 pin D4 or ESP32 pin D2 to the first LED data pin at the bottom step.
|
2021-02-25 08:52:48 +00:00
|
|
|
3. Connect the data-out pin at the end of each strip per step to the data-in pin on the
|
2022-12-10 15:12:55 +00:00
|
|
|
next step, creating one large virtual LED strip.
|
2021-02-25 08:52:48 +00:00
|
|
|
4. Mount sensors of choice at the bottom and top of the stairs and connect them to the ESP.
|
|
|
|
5. To make sure all LEDs get enough power and have your staircase lighted evenly, power each
|
|
|
|
step from one side, using at least AWG14 or 2.5mm^2 cable. Don't connect them serial as you
|
|
|
|
do for the datacable!
|
|
|
|
|
|
|
|
You _may_ need to use 10k pull-down resistors on the selected PIR pins, depending on the sensor.
|
|
|
|
|
|
|
|
## WLED configuration
|
2023-12-14 02:52:06 +00:00
|
|
|
1. In the WLED UI, configure a segment for each step. The lowest step of the stairs is the
|
2021-02-25 08:52:48 +00:00
|
|
|
lowest segment id.
|
|
|
|
2. Save your segments into a preset.
|
|
|
|
3. Ideally, add the preset in the config > LED setup menu to the "apply
|
|
|
|
preset **n** at boot" setting.
|
|
|
|
|
|
|
|
## Changing behavior through API
|
|
|
|
The Staircase settings can be changed through the WLED JSON api.
|
|
|
|
|
|
|
|
**NOTE:** We are using [curl](https://curl.se/) to send HTTP POSTs to the WLED API.
|
|
|
|
If you're using Windows and want to use the curl commands, replace the `\` with a `^`
|
|
|
|
or remove them and put everything on one line.
|
|
|
|
|
|
|
|
|
|
|
|
| Setting | Description | Default |
|
|
|
|
|------------------|---------------------------------------------------------------|---------|
|
|
|
|
| enabled | Enable or disable the usermod | true |
|
2021-04-09 15:50:26 +00:00
|
|
|
| bottom-sensor | Manually trigger a down to up animation via API | false |
|
|
|
|
| top-sensor | Manually trigger an up to down animation via API | false |
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
To read the current settings, open a browser to `http://xxx.xxx.xxx.xxx/json/state` (use your WLED
|
|
|
|
device IP address). The device will respond with a json object containing all WLED settings.
|
2022-12-10 15:12:55 +00:00
|
|
|
The staircase settings and sensor states are inside the WLED "state" element:
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"state": {
|
|
|
|
"staircase": {
|
|
|
|
"enabled": true,
|
2021-04-09 15:50:26 +00:00
|
|
|
"bottom-sensor": false,
|
2022-12-10 15:12:55 +00:00
|
|
|
"top-sensor": false
|
2021-02-25 08:52:48 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Enable/disable the usermod
|
|
|
|
By disabling the usermod you will be able to keep the LED's on, independent from the sensor
|
2022-12-10 15:12:55 +00:00
|
|
|
activity. This enables you to play with the lights without the usermod switching them on or off.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
To disable the usermod:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
curl -X POST -H "Content-Type: application/json" \
|
|
|
|
-d {"staircase":{"enabled":false}} \
|
|
|
|
xxx.xxx.xxx.xxx/json/state
|
|
|
|
```
|
|
|
|
|
|
|
|
To enable the usermod again, use `"enabled":true`.
|
|
|
|
|
2021-05-17 10:52:27 +00:00
|
|
|
Alternatively you can use _Usermod_ Settings page where you can change other parameters as well.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
2021-05-17 10:52:27 +00:00
|
|
|
### Changing animation parameters and detection range of the ultrasonic HC-SR04 sensor
|
2023-12-14 02:52:06 +00:00
|
|
|
Using _Usermod_ Settings page you can define different usermod parameters, including sensor pins, delay between segment activation etc.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
2021-05-17 10:52:27 +00:00
|
|
|
When an ultrasonic sensor is enabled you can enter maximum detection distance in centimeters separately for top and bottom sensors.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
2022-12-10 15:12:55 +00:00
|
|
|
**Please note:** using an HC-SR04 sensor, particularly when detecting echos at longer
|
|
|
|
distances creates delays in the WLED software, _might_ introduce timing hiccups in your animation or
|
2021-05-17 10:52:27 +00:00
|
|
|
a less responsive web interface. It is therefore advised to keep the detection distance as short as possible.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
### Animation triggering through the API
|
2022-12-10 15:12:55 +00:00
|
|
|
In addition to activation by one of the stair sensors, you can also trigger the animation manually
|
|
|
|
via the API. To simulate triggering the bottom sensor, use:
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
curl -X POST -H "Content-Type: application/json" \
|
2021-04-09 15:50:26 +00:00
|
|
|
-d '{"staircase":{"bottom-sensor":true}}' \
|
2021-02-25 08:52:48 +00:00
|
|
|
xxx.xxx.xxx.xxx/json/state
|
|
|
|
```
|
|
|
|
|
2022-12-10 15:12:55 +00:00
|
|
|
Likewise, to trigger the top sensor:
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
curl -X POST -H "Content-Type: application/json" \
|
2021-04-09 15:50:26 +00:00
|
|
|
-d '{"staircase":{"top-sensor":true}}' \
|
2021-02-25 08:52:48 +00:00
|
|
|
xxx.xxx.xxx.xxx/json/state
|
|
|
|
```
|
2021-05-17 10:52:27 +00:00
|
|
|
**MQTT**
|
|
|
|
You can publish a message with either `up` or `down` on topic `/swipe` to trigger animation.
|
2022-12-10 15:12:55 +00:00
|
|
|
You can also use `on` or `off` for enabling or disabling the usermod.
|
2021-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
Have fun with this usermod.<br/>
|
|
|
|
www.rolfje.com
|
2021-05-07 10:41:39 +00:00
|
|
|
|
2021-05-17 10:52:27 +00:00
|
|
|
Modifications @blazoncek
|
|
|
|
|
2021-05-07 10:41:39 +00:00
|
|
|
## Change log
|
|
|
|
2021-04
|
2022-12-10 15:12:55 +00:00
|
|
|
* Adaptation for runtime configuration.
|