I looked but didn’t find where you turn off the motor after reaching target position before I hook up could you update whether or not this is needed?
I, im completely lost with this proyect.
I have tried different settings, code, etc, but I can’t get the stepper motor to work.
Hardware:
- A4988 stepper motor driver (A4988 DRV8825 Stepper Motor Driver With Heat sink 3D Printer Parts StepStick Carrier Reprap RAMPS 1.4 1.5 1.6 MKS GEN V1.4 board|3D Printer Parts & Accessories| - AliExpress)
- Stepper motor Nema 17 (US-17HS4023) (Titan Extruder Stepper Motor 4 lead Nema 17 22mm 42 Motor for 3D Printer A20 dropshipping|Stepper Motor| - AliExpress)
- ESP32-WROOM-32D (ESP32-DevkitC-V4) (ESP 32S ESP WROOM 32 ESP32 ESP 32 Bluetooth and WIFI Dual Core CPU with Low Power Consumption MCU ESP 32|Integrated Circuits| - AliExpress)
- Power AC/DC: Input 200-240v 0.4A, Output 12V 1.5A
Using ESPHome, the code is:
esphome:
name: esp32_01
platform: ESP32
board: nodemcu-32s
wifi:
ssid: "my-ssid"
password: "my-password"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp 1 Fallback Hotspot"
password: "my-password"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
services:
- service: control_stepper
variables:
target: int
then:
- stepper.set_target:
id: my_stepper
target: !lambda 'return target;'
ota:
web_server:
port: 80
switch:
- platform: gpio
name: "Rele1"
pin: 19
stepper:
- platform: a4988
id: my_stepper
step_pin: GPIO25
dir_pin: GPIO27
max_speed: 250 steps/s
# Optional:
sleep_pin: GPIO26
acceleration: inf
deceleration: inf
The automation code:
- id: '1609846797785'
alias: Write Stepper Value to ESP
description: ''
trigger:
- platform: state
entity_id: input_number.stepper_control
condition: []
action:
- service: esphome.esp32_01_control_stepper
data_template:
target: '{{ trigger.to_state.state | int }}'
mode: single
Helper input number:
input_number:
stepper_control:
name: Stepper Control
initial: 0
min: -1000
max: 1000
step: 1
mode: slider
When I change the input number value, the step_pin (GPIO25) value is ~004-001, if I change the direction, dir_pin (GPIO27) the values are 0v (left), 3.2v (right). While the action is being executed, the sleep_pin (GPIO26) value is 3.2v. But the stepper motor does not move.
I dont know what to do to make the engine rotate.
The scheme is similar to this:
Thanks
Were you able to solve this problkem? Can you share your yaml configuration.
This is my set up. Not roller blinds, but some ideas may help. I built this in the first few weeks when the pandemic hit. Its been working since on the upstairs and downstairs blinds. Im about to upgrade it again as there’s things im not happy about. For example I want to use ESPHome/ node red, at the minute im using blynk and node red. Also feel I can maybe cut down on some parts and wires by using a Esp32 rather than a Esp8266 and servo controller, though not sure if thats advisable?
The way its set up, I have a small power transformer that runs at 5v and 5a which powers the 5 seperate servos. All micro servos (sg90). This takes up one plug. A usb plug runs the esp8266 which is connected to a PCA9685 (servo controller.) The transformer is pluged into this.
From here I run a 8 core wire, a seperate wire goes into each servo and a shared live and nutural. The Servos are fixed into the blind and are connected directly to the metal rod via servo coupler, then tied in place with cable ties and belive it or not, LEGO. (this isnt very elegant and I know i can improve this now i have a 3d printer. Im sure it will be hard work on the servos an have some better ideas for this, but at the time, these servos were so cheap i didnt care.
I signed up to a free account with Blynk to operate them, this was a decision earlier on as i found good docuemntation to get it working and to sync it up with google home. the servos are continuios rotation servos as i found it tricky with degree rotation ones. In the code of the Esp if i remember right i use a signal of 100 to turn the servos one way, then 250 for the other. To stop them running was the trickiest part especially when i had no clue with code or electronics at the time. but it was a simple signal of 4095 to detach the servos. Which I know Esphome can do.
Most of these are all put into Home assistant with Node Red with http resuest nodes. All the blinds do work together, but the downstairs ones struggled even though the set up was mostly the same. Must have been the transformer. So I programmed them to quickly open and detach one after the other. Also because they were continuious servos and cheap, all opened slightly different degrees. To get around that in node red i manually changed the length detach would be sent. All work fine.
As a safety messure, as i didnt want to leave the transformer on all the time (it gave a very quite high pitched hum, barely noticable but it annoyed me) I attached a wifi switch to auto turn on and off when i press open or close on the blinds in home assistant. There’s definitly things that need fixing and improving and probably more that im doing wrong. If so please feel free to point it out.
Trying parts of your code. Are you able to manually select the slider and set the position? Does that actuate?
Hey, here is the snippet for setting the position:
position_action:
- globals.set:
id: temp_position
value: !lambda 'return float(float(id(open_position)) * pos);'
- stepper.set_speed:
id: blind_stepper
speed: !lambda |-
if (id(temp_position) >= id(blind_stepper).current_position) {
return 400;
} else {
return 800;
}
- stepper.set_target:
id: blind_stepper
target: !lambda |-
if (id(temp_position) >= id(blind_stepper).current_position) {
return id(temp_position) + id(open_position_offset);
} else {
return id(temp_position);
}
- while:
condition:
lambda: |-
return id(blind_stepper).current_position != id(temp_position) && id(blind_stepper).current_position != (id(temp_position) + id(open_position_offset));
then:
- cover.template.publish:
id: kitchen_blind
current_operation: !lambda |-
if(id(temp_position) >= id(blind_stepper).current_position) {
return COVER_OPERATION_OPENING;
} else {
return COVER_OPERATION_CLOSING;
}
position: !lambda 'return (float(float(id(blind_stepper).current_position) / float(id(open_position))));'
- delay: 1000 ms
- cover.template.publish:
id: kitchen_blind
current_operation: IDLE
position: !lambda 'return (float(float(id(blind_stepper).current_position) / float(id(open_position))));'
- stepper.report_position:
id: blind_stepper
position: !lambda "return id(temp_position);"
- stepper.set_target:
id: blind_stepper
target: !lambda "return id(temp_position);"
- globals.set:
id: current_position
value: !lambda "return id(temp_position);"
- output.turn_on: builtin_led
has_position: true
It also includes the part to lower the blind with a faster speed, and open it with a slower speed.
Where should this snippet be located? I have asked my question more specific here:
I can’t get it to work “that” way (to control the slider form within homeassistant)
Not sure if I’m understanding what you ask for, but this works with a slider as long as you have continous mode enabled it also updates in realtime.
It is the code for the position_action
. The initial code contains the open_action
, close_action
and stop_action
. Just put it there after those actions.
Hi, l like your dual motor setup and would like to try it out. Could you post a link to these stl files.
Thanks Brad
Were you able to get the DRV8825 to work? I’m trying to get this driver working using the a4988 platform thinking they are similar. But I can’t get the stepper motor working. If you got the DRV working, can you tell me how did you wire yours and what script did you use to get it working?
Thanks.
I’ve been working on this for a while and today finally installed it. The challenge is that the blind is very heavy, blackout type, 2.8 m wide and 1.2 m vertically.
No choice but to use a NEMA 17 for torque. The issue is that, as we know, these motor spin freely when the coils aren’t powered. I didn’t want to use the original brake so came up with own, over engineered solution. It’s a 3 part assembly, consisting of a base plate, a motor mount and in between, a height adjustable plate. I used the code from @RoadkillUK and adapted it for the A4988 platform (trivial to do). I’m using a TCM2208 driver for silent operation.
The system was designed around aluminium pulleys and a belt used in 3D printers and therefore readily available. I’m using a bunch of m3 bolts and one M5 to help with rigidity of the middle plate so that I can tension the belt and it provides the adjustable friction to overcome gravity when the motor is idle. I spent way too much time on this as I learned fusion 360 on this project.
That almost worked. I had to remove the weight bar at the bottom of the blind, and even then I can’t pull it all the way to the bottom due to either the motor skipping steps or the belt skipping. Back tot he drawing board for now…
I am new to esp and HA.
my plan is to use a NEMA 17, D1 mini and A4988.
So i wonder if any can be kind and share ther code, as easy as
possible to esp? i am still trying to get it all wired up.
i need 2 things to start withe.
- sett a stop rmp
- sett speed
BONUS if some one have a code for sett timer on it.
Best Regard Daniel
can I use Nema 17 motors connected directly to the roller shade’s tube? without power, would the nema17 slip, auto releasing the shade? how come all the STL files on thingiverse have gears in them? i am really curious why i cant use the motor to drive directly. please help
hello, I have made a prototype using another board, and now I got different a4988 shield boards. Don’t know how to use it.
Iam using esp8266, 28byj-48 12v step motors, esphome code which needs only 3 pins - ST,DIR and EN.
which pin-row (S,V,G) should I use for STEP, EN, DIR pins?
I would to use a4988 driver which is putted into that stepper driver shield but I have connected it to yellow-row ( marked as “S” ) and that doesn’t worked.
regards
Hope that Ive found the meaning of S,V,G rows
S is for signal and pins are not connected together
V is for VCC and all 3 pins are connected
G is for GND and all 3 pins are connected
this guy is using a big DC motor and counted the time, not steps, to keep track of positions. anyone else doing the same thing? his mount is 3d printed for the side of the window as seen in the purple part. has anyone use the same setup but mount onto the red side as seen here?
You could stop/lock the gear with a solenoid the motor stops.
Like these: Dc12v24v Solenoid Magnetic Solenoid Push-pull Solenoid Ly-1264 Long Stroke 30mm Open Frame Electromagnet - Electromagnet - AliExpress
The youtube video: DIY Motorized roller blind - YouTube