• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 S3 motor control with DRV8871

Q&A Forum › Category: ESP32 › ESP32 S3 motor control with DRV8871
0 Vote Up Vote Down
Will Damerell asked 1 day ago

Hi ,
      Im using a DRV8871 with an ESP32 S£ I originally was following the example on the course untill I relised that a DRV8871 does nt have an enable pin and I need to control speed and direction. 
My code uses digitalWrite(direction1,HIGH) then

  analogWrite(speed1, speedValue) ,  the output is 0-255  and 255-0 depending on High to Low settings.

 
Is this the best way to do it ,  Im driving a 12V motor pulling 1 A and liked the ability in theory of setting frequency  which I would have been able to do using the LED** commands as per the course , but  having no enable pin I cant work out how I can use these commands or can I set frequency on the analog pin ?? 

Question Tags: ESP32 S3 DRV8871
3 Answers
0 Vote Up Vote Down
Will Damerell answered 1 day ago

Sorry should read ESP32 S3 typo!!!

0 Vote Up Vote Down
Will Damerell answered 1 day ago

OK  I had a play and have answered my own question with the DRV chip just treat the second input as the enable and it works using the LED code as per below .

if ( strcmp(EspCmd, BSPEEDINC) == 0 )
    {
          digitalWrite(direction1,HIGH);
           if ( speedValue > 20 )
           {
             speedValue=speedValue-20;  
              ledcWrite(speed1, speedValue) ;  
           // analogWrite(speed1, speedValue);
            Serial.println(“Speeding Up “) ;        
            Serial.println(speedValue) ;
          }                
    }

You can apply the parameters as per the course notes using , where in my example enable pin is speed1
 

  ledcAttachChannel(enable1Pin, freq, resolution, pwmChannel);
0 Vote Up Vote Down
Sara Santos Staff answered 10 hours ago

Hi.
Great.
I’m glad you found the solution.
Can I mark this issue as resolved?
If you need further help, you just need to open a new question in our forum.
 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Smart Home with Raspberry Pi, ESP32, and ESP8266 Version 1.7 November 28, 2025
  • [eBook Updated] Smart Home with Raspberry Pi, ESP32, and ESP8266 V1.6 September 9, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.