# Roborock door with homeyduino ESP8266, L298N and Nema 17

**URL:** <https://community.homey.app/t/roborock-door-with-homeyduino-esp8266-l298n-and-nema-17/77412>\
**Category:** Devices\
**Created:** [March 9, 2023, 6:57pm UTC](https://community.homey.app/t/roborock-door-with-homeyduino-esp8266-l298n-and-nema-17/77412 "2023-03-09T18:57:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gisle\_Johnsen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/gisle_johnsen/32/9720_2.png) [@Gisle\_Johnsen](https://community.homey.app/u/Gisle_Johnsen)\
**Post date:** [March 9, 2023, 6:57pm UTC](https://community.homey.app/t/roborock-door-with-homeyduino-esp8266-l298n-and-nema-17/77412/1 "2023-03-09T18:57:42Z")

</div>

Hello.  
I am currently making an automated garage door for my max v6 roborock under the kitchen cabinets  
I am very close but something is wrong with the code I believe.  
I am using esp8266, L298N driver and a Nema 17 stepper motor.  
I implement to Homey by using the Homeyduino -

> include \<Homey.h\>

I paired it to Homey and it showes up witouht problems.  
But, the motor does not behave as it should. It vibrates and tries, but dosent turn as it should.  
As I am not that good at coding I hoped someone could take a look at the code and maybe see what is wrong.  
I have followed this description as the hardware and wirering goes…

 ![esp](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/b/ab27bc4af0439f475c2f933c60950a3b144a81c3.jpeg)

This is the code I used:

> #include \<ESP8266WiFi.h\>  
> #include \<WiFiClient.h\>  
> #include \<Homey.h\>
> 
> unsigned long previousMillis = 0;  
> const unsigned long interval = 2000; //Interval in milliseconds for reading setpoint from Homey
> 
> #include \<Stepper.h\>  
> #define stepsPerRevolution 2040  
> Stepper stepper(stepsPerRevolution, 5, 14, 12, 4); //This are PIN D1 D5 D6 D2 on the ESP8266
> 
> int Relais = 13; //PIN D7 on ESP8266 Relay for put on and off stepper motor
> 
> float PositionFloat = 0; //Setpoint from Homey
> 
> int steps1; //Stepcounter  
> int stepsHomey; //Setpoint from Homey changed to stepper total
> 
> void wifi() { //This loop is for connecting to WiFi  
> if (WiFi.status() != WL\_CONNECTED) {  
> Serial.print(“Connecting with WiFi “);  
> WiFi.begin(“xxxxxxxxx”, “xxxxxxxx”);  
> uint8\_t timeout = 30;  
> while (WiFi.status() != WL\_CONNECTED) {  
> delay(500); Serial.print(”.”);  
> if (timeout\<1) break;  
> }  
> if (WiFi.status() == WL\_CONNECTED) {  
> Serial.println(" ");  
> Serial.println(“Connected to WiFi!”);  
> }  
> }  
> }
> 
> void setup() {  
> Serial.begin(9600);  
> Homey.begin(“VacuumRobotDoor”); //The name of your project, every project needs another name!  
> Homey.setClass(“blinds”); //Put here the device class, in this case Blinds  
> Homey.addCapability(“windowcoverings\_set”, ValHomey); //Put here the capability  
> Homey.setCapabilityValue(“windowcoverings\_set”, ValHomey);  
> steps1 = 0;  
> }
> 
> void loop() {  
> Homey.loop();  
> wifi();  
> steppert();  
> unsigned long currentMillis = millis();  
> if(currentMillis - previousMillis \> interval) {  
> previousMillis = currentMillis;  
> ValHomey ();  
> }  
> }
> 
> void steppert(){  
> stepsHomey = (PositionFloat \* 9180); //[9180] Is the total ammount of steps wich i need to be taken  
> if (stepsHomey != steps1){ //To activate relais before steps will be made!  
> digitalWrite (Relais, HIGH); //Relay activated  
> }
> 
> if (stepsHomey == steps1){ //To deactivate relais before when stepper motor is not in use  
> digitalWrite (Relais, LOW); //Relay not activated  
> }
> 
> if (stepsHomey \> steps1){ //Circuit for turning CW  
> stepper.setSpeed(14); //Stepper speed  
> stepper.step(1); //Steps per time  
> steps1++; //Stepcounter  
> }
> 
> if (stepsHomey \< steps1){ //Circuit for turning CCW  
> stepper.setSpeed(14); //Stepper speed  
> stepper.step(-1); //Steps per time  
> steps1–; //Stepcounter  
> }  
> }
> 
> void ValHomey (){  
> PositionFloat = Homey.value.toFloat(); //number 0.00 - 1.00  
> Serial.print ("Setpoint from the Homey: "); Serial.println(stepsHomey);  
> Serial.print ("Actual position of the steppermotor: "); Serial.println(steps1);  
> }

And here is the mechanism I am printing at work in a few days…

> **[Nema 17 gearing with lifting arm by mika2de](https://www.thingiverse.com/thing:4817927?fbclid=IwAR3k4KKXw94sYt23gd9AD3swuA2Pq4WXvwVF2ot1Z3cStyFBNod5OVKz8mk)**
>
> A gearing mechanism to lift a kitchen skirting board up and down and hide my vacuum cleaner robot under the kitchenette. I designed this gearing for higher torque as the wooden board is pretty heavy for a small nema 17. 
> Project description on...

---

<div class="post-metadata">

**Author:** ![Homey\_Lampje](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/homey_lampje/32/10392_2.png) [@Homey\_Lampje](https://community.homey.app/u/Homey_Lampje)\
**Post date:** [March 9, 2023, 10:32pm UTC](https://community.homey.app/t/roborock-door-with-homeyduino-esp8266-l298n-and-nema-17/77412/2 "2023-03-09T22:32:28Z")

</div>

Trouble shoot your code without the intergration with homeyduino/homey.

Google is your best friend for this kind of projects…. [https://lastminuteengineers.com/stepper-motor-l298n-arduino-tutorial/](https://lastminuteengineers.com/stepper-motor-l298n-arduino-tutorial/)

---

<div class="post-metadata">

**Author:** ![Gisle\_Johnsen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/gisle_johnsen/32/9720_2.png) [@Gisle\_Johnsen](https://community.homey.app/u/Gisle_Johnsen)\
**Post date:** [March 10, 2023, 7:53am UTC](https://community.homey.app/t/roborock-door-with-homeyduino-esp8266-l298n-and-nema-17/77412/3 "2023-03-10T07:53:40Z")

</div>

> [@Homey\_Lampje](#):
>
> omeyduino/homey

Thank you. I will have a look this weekend to see if I can solved it. 🙂
