I have an issue where I set the speed in steps/sec but speed is not very smooth, kinda glitches a few times a sec (auditable). Also, when I go into ESPHome log, the stepper speed drops by about 20%. I believe this is happening because of increased processor load and it is not able to keep up with processing the stepper library.
Lastly, I have not been able to just perform a simple run command without setting the position. You will see in the code I have to set the position to a very high positive or negative number to get it to run.
api:
encryption:
key: "********************"
services:
- service: control_stepper
variables:
speed: float
then:
- globals.set:
id: stepper1_speed
value: !lambda 'return speed;'
- logger.log:
format: "New speed= %.1f"
args: ['id(stepper1_speed)']
- stepper.set_speed:
id: my_stepper1
speed: !lambda 'return speed;'
- stepper.set_target:
id: my_stepper1
target: !lambda |-
if (id(stepper1_speed) > 0) {
return 10000000.0;
}
else if (id(stepper1_speed) < 0) {
return -10000000.0;
}
else {return 0.0;}
ota:
password: "*******************"
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
- ssid: !secret wifi_ssid_2
password: !secret wifi_password_2
- ssid: !secret wifi_ssid_3
password: !secret wifi_password_3
- ssid: !secret wifi_ssid_4
password: !secret wifi_password_4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Aqrecycle Fallback Hotspot"
password: "*************"
captive_portal:
web_server:
port: 80
include_internal: true
globals:
- id: stepper1_speed
type: float
restore_value: no
initial_value: '0'
stepper:
- platform: a4988
id: my_stepper1
step_pin: GPIO27
dir_pin: GPIO33
max_speed: 5000 steps/s