# STS-Pi & Explorer Hat Pro - PWM issues using Flask

**URL:** <https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938>\
**Category:** Support\
**Created:** [October 16, 2019, 7:57am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938 "2019-10-16T07:57:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Baker](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Will\_Baker](https://forums.pimoroni.com/u/Will_Baker)\
**Post date:** [October 16, 2019, 7:57am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/1 "2019-10-16T07:57:43Z")

</div>

Hi, I’m using Flask to host a web page that can control the STS-Pi. I have got as far as the controls with out the web cam, but…  
The problem I have is that the motors already don’t run smoothly or consistently…from the research I’ve done, I am fairly certain it is because of the “software PWM” not operating correctly due to the PI3 B+ not being fast enough for the load  
Does anyone have any suggestions on how I can solve this problem (note: I am not an expert). I think there are a few options which might work, but I’m not sure how to achieve them yet  
1) change to hardware PMW, I have seen some info on this in relation to “pigpio” but it looks complicated  
2) turn off the PMW and just have full speed and stop  
3) use something other than Flask as the server (as long as it is simple)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [October 16, 2019, 8:24am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/2 "2019-10-16T08:24:49Z")

</div>

How are the motors wired to the Pi?  
What are you using for a motor controller?  
I ask because you should have an H Bridge or something between the motors and the GPIO pins. And its not obvious, to me anyway, how your doing it from what you posted.

---

<div class="post-metadata">

**Author:** ![Will\_Baker](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Will\_Baker](https://forums.pimoroni.com/u/Will_Baker)\
**Post date:** [October 16, 2019, 9:00am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/3 "2019-10-16T09:00:22Z")

</div>

The explorer Hat Pro is being used as the motor controller (it is built into it)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [October 16, 2019, 11:25am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/4 "2019-10-16T11:25:14Z")

</div>

Ok, on the product page its show as “other things that could come in handy” so I figured I better double check if you had it.  
I have a couple of two wheel rovers built around the explorer phat and a Pi Zero. Start stop is fine for me, using the Pimoroni explorer phat python code. I only run into issues when trying to run a motor at reduced speed for slow turns etc. Anything above half speed seems OK, below that sometimes a motor will stall and stop.

---

<div class="post-metadata">

**Author:** ![Will\_Baker](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Will\_Baker](https://forums.pimoroni.com/u/Will_Baker)\
**Post date:** [October 16, 2019, 12:47pm UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/5 "2019-10-16T12:47:14Z")

</div>

Yes, it works fine if I take Flask out of the picture and just run a python program to control the motors…I think using Flask / a web server is creating to much load on the pi and it is not able to keep up with the software driven PWM for the motor speed?

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [October 16, 2019, 7:01pm UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/6 "2019-10-16T19:01:52Z")

</div>

Sounds plausible. I’ve only ever used a wireless keyboard to control my rovers remotely.

---

<div class="post-metadata">

**Author:** ![Will\_Baker](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Will\_Baker](https://forums.pimoroni.com/u/Will_Baker)\
**Post date:** [October 17, 2019, 2:40am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/7 "2019-10-17T02:40:56Z")

</div>

I don’t think that will reach Australia from the UK 😁

---

<div class="post-metadata">

**Author:** ![Will\_Baker](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Will\_Baker](https://forums.pimoroni.com/u/Will_Baker)\
**Post date:** [October 17, 2019, 9:02am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/8 "2019-10-17T09:02:15Z")

</div>

Did a bit more looking it to this and found this on the RPi.GPIO library which is used by the Explorer Hat Pro…ouch!! maybe I can hack the explorerhat code to use pigpio instead?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/1/19f1613b461583f6d505bc2b82780e76af4ff940.png)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [October 17, 2019, 10:30am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/9 "2019-10-17T10:30:45Z")

</div>

Thats for sure above my skill level. I do hope you figure out a working solution. I’m thinking your going to have delays no matter how you do it, if through the Internet.

---

<div class="post-metadata">

**Author:** ![Will\_Baker](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Will\_Baker](https://forums.pimoroni.com/u/Will_Baker)\
**Post date:** [October 23, 2019, 2:49am UTC](https://forums.pimoroni.com/t/sts-pi-explorer-hat-pro-pwm-issues-using-flask/11938/10 "2019-10-23T02:49:44Z")

</div>

If anyone is interested in this, the solution is effectively outlined here:

> **[Pololu DRV8835 Dual Motor Driver Kit for Raspberry Pi B+](https://core-electronics.com.au/pololu-drv8835-dual-motor-driver-kit-for-raspberry-pi-b.html#)**
>
> This compact expansion board plugs directly into the GPIO header on a Raspberry Pi B+ and provides an easy and low-cost solution for driving a pair of small brushed DC motors. Its integrated DRV8835 dual motor driver allows it to operate from 1.5 V...
