Transcript for:
ESP Home and Stepper Motors

[Intro] ... then just see what  googly eyes that I stole a land   from my daughter. I would be really happy  if you find something, some inspiration. Hey there, Buschi here. In the last few  projects I was focusing a lot on Home   Assistant and how to enhance it using  ESPHome, which is a software suite to   produce custom-built firmware for the ESP chip  families. I used it to create, for example,   this light in a short and detailed how I did  it and how it's built and how it's created. I created and made a video on this light, which  I created from scratch, using keypad to produce   my own PCB and put an ESP module on the backside  of the PCB, which then controls the light strips. In the recent video I created a light sensor  for my father, who has also a Home Assistant at   home. And I remember now that I never gave him  the sensor that I built for him in this video,   explaining it in this video. Sorry that  you will get it soon if you see that. So in short, I'm a big fan of Home Assistant  and I'm a big fan of ESPHome and to be able   to tinker with things and mix and match  the small building blocks that ESP offers   you and put it all together and it compiles  a new firmware and you flash it and you get   something new that is your own from  scratch. And you know how the saying   goes and all good things need to come to  an end, but not so fast and not today. Does it even say where did it come from? Anyway,  all good things need to come to an end, but not   yet and not so fast because today I want to use  ESPHome and tinker a little bit to steer stuff in   the real world using stepper motors. If you're not  familiar with what a stepper motor is, it's this. Usually in this bulky form, quite  common in 3D printers these days, in the simplest form they have two coils. So this one has for example six pins, but  you can control it in a two coil fashion.   And if you reverse for example the polarity  of one of the coils, that is called a step.   It moves by a bit and that is actually not a  huge amount, but for the NEMA standard stepper   motor it's 1.8 degrees, which means that  for a full revolution you need 200 steps. And now as such a motor as you can imagine  draws quite an amount of power, you need special   circuitries to control it. And for example this  one, so they get really small but they can still   drive quite an amount of amp, quite a high amount  of amps. And in recent years they got really   sophisticated. What I mean by that is that now you  cannot only do full steps or half steps or quarter   steps, a single step can be subdivided by for  example 256 steps. And due to the subdivision also   steps got really quiet. So in the good old days  those things or rather the motors were singing really singing as if they were performing  a... Ah, you again. What does it say? Ah,   now. Now I can read it. Yeah, I like it. Do  that. And nowadays you can barely hear them   working at all. So without further ado I would  say let's jump in and see how this can be done   with an ESP home module and how difficult it  is to set it up actually. And as a... Come on! Okay, I can definitely read it  now, but this font is not so   sophisticated in my opinion. So I hope  the next time it's a nicer font. Yeah,   let's see what is actually needed  to use a stepper motor in ESP home. If you have no idea why I do this video and why  tinkering with motors is actually interesting then   just see what googly eyes that I stole land from  my daughter do to an otherwise mundane disc from   an earlier project. Isn't that cute? Motors  always fascinated me. Don't know why. Well,   I do. Because you can change something in the  real world almost as if it was magic. Anyway,   let's go back to the topic. As you can see there  is not much to see really. There is the motor,   the driver I see, and the ESP module carrier  board plus power and power. The stepper motor   driver has a few important inputs. Let's start  with the power supply for the logic ground and   VIO. VIO gets the same 3.3 logic level as the ESP  to communicate on an I level, meaning the same   logical voltage level. Then come the functional  pins, step and direction pins. You guessed it,   those are important. Step for advancing one  step forwards or backwards controlled by the   direction pin. If you want to let the motor stay  in sleep mode during motions there is this enable   line. Careful here, it is driven in inverted  mode, meaning that a low level means enabled.   Then I also hooked up the MCS1 to high level.  They have a built-in pull down resistor so MCS2   is pulled down. According to the datasheet  this is giving us a half step configuration,   which explains why I need to step 400 times  before a full revolution is finished as opposed   to 200 steps with a full step configuration  or the default of the motor itself. Finally I   hooked up power to the motor and the four motor  lines for the two coils. That's it. Let's have   a small glimpse onto the config code. Okay,  that's maybe a bit too small. Let's increase   the size and ignore the boilerplate setup code  that ESPHome adds for you and that I have shown   multiple times before in other videos. We begin  our tour at the stepper component. I have set up   three pins for the step, the direction and the  sleep pin and then three values for Mach speed,   acceleration and deceleration. The latter two are  not strictly necessary but a motor that gently   starts and stops instantly levels up to level  three on the coolness scale. Why level three   and not four? I don't know. Go figure. That's  already it for the motor. And then to be able to   control the steps as an input variable from Home  Assistant I added a number template with a range   of possible values between zero and two thousand  with a set action that sets the corresponding   input steps via lambda function to the stepper  component. And that's it. Again, so simple. I'm in the last steps of cutting up this video and  I realized that I've never shown the contraption   that was holding the pulleys that lowered and  assigned gently in and out of the frame. And as   this is quite impressive to look at, I thought  it's a nice touch to show to you. So that's it. This thing was looming and hanging over  my head the entire time. It consists of   two pulleys that are attached to magic arms and  those magic arms, so those are the magic arms,   are attached to this big boom arm over here that  is coming from a different project. An earlier one   which is actually a camera stand. You can see  the tripod head there. I linked you the video   because I was building that and that's also  a 3D printed part. I was never afraid that it   might come crashing down onto my head because the  PTG and the 3D printed parts are so strong and so   nice and I love them. It was working just fine  and I could position it in all possible ways.   When you loosen the screws, it's moving in all  possible directions and then only this pulley,   not this this disc would go onto the stepper  motor, turning and moving the two strings   together. And then this was moving the sign up and  down. So no big deal, but in my opinion this is. And that brings us to the end of this  video. I had a lot of fun tinkering with   ESP Home again and in that case changing  stuff in the real world using a stepper   motor. ESP Home still amazes me and I find  it astonishing how many different building   blocks there are and what you can actually  all do in your own DIY projects to achieve   things that would be otherwise really hard  to achieve. And if you like this video and   you found it interesting then do this. And  if you could leave a thumbs up for example,   I would be really appreciating it. I leave  you to it, have a good one, see you soon. Bye!