loading

Overview

Surprisingly, you can run a powerful stepper motor (via motor controller) from the Adafruit Huzzah ESP8266 WiFi module and thus control the stepper via browser or web service, turning your stepper into an Internet of Things (IoT) device. This makes for a compact and low-cost remotely controlled motor, good for robots, mechanical arms and more.

Step 1: Requirements

I used the following Adafruit components for the Stepper Motor and ESP8266 right out of the box. Otherwise, you would need to add regulators and related components to make the voltages compatible.

IMPORTANT NOTE! The power regulator on the Adafruit HUZZAH ESP8266 board has CHANGED. It no longer can handle 12v DC. A 5VDC power supply to feed the V+ and a 12v supply for the Stepper now required!

Older HUZZAH ESP8266's included a 3-16v regulator, so are unaffected.

Hardware

Software

Step 2: Important Initial Setup of Huzzah ESP8266

Before beginning the modification, you should become familiar with the Adafruit HUZZAH board and programming it using the Arduino IDE. The best way is to use the excellent Adafruit tutorial:

https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/overview

You must be able to program your ESP8266 and connect wirelessly to it via browser.

Once completed, THEN continue to next step.

Step 3: Software

First you should program and test the ESP8266 before adding its hardware wiring:

  1. STOP! Be sure you have already completed the preliminary software setup of the Arduino IDE and tested the ESP8266 with your WiFi network as described in the Initial Setup above!
  2. Ok, download the ESP8266_stepper software from GitHub https://github.com/rgrokett/ESP8266_stepper/
  3. Copy the StepperWebServer.ino program to your Arduino library area.
  4. Using Arduino IDE, edit the StepperWebServer.ino and insert your SSID and PASSWORD into the appropriate places.
  5. Compile and Upload the program using the FTDI or USB console cable just like shown in the Adafruit tutorial.
  6. When the program finishes loading, open a Serial Monitor, set to 115,200 baud, and press the ESP8266 RESET button to restart the program running.
  7. It should display the IP address once connected to your Wifi.
    Also, the onboard Red LED should blink 4 times signifying it’s successfully connected.
  8. Use a browser to go to http://{your_ip_addr}/stepper/stop
    This should respond back with “OK: MOTORS OFF” in browser
    Go to http://{your_ip_addr}/stepper/rpm?1 and see “OK: RPM = 1”
    Go to http://{your_ip_addr}/stepper/steps?10 and see “OK: STEPS = 10”
    Go to http://{your_ip_addr}/stepper/start and see the onboard LED blink once
    NOTE: If you have a Linux machine, you can use cURL to do these commands as well
  9. Unplug your ESP8266 and remove the FTDI/USB cable. It’s now programmed.

Step 4: Hardware Wiring

  1. Connect up the Stepper Motor to the TB6612 Driver board:
    • Hook one stepper motor coil to Motor A (red and yellow)
    • Hook the second coil to Motor B (green and gray/brown).
    • Connect VMotor V+ to +12V Power
    • Connect VMotor GND to 12V Ground
  2. Next, wire up the Huzzah ESP8266 board to the TB6612 Driver board (see Wiring Table and Circuit diagrams)

  3. Connect up the 5v DC power supply to GND and V+ pins on the side of the Huzzah board (same side that the FTDI USB programming cable connected to in the software load, above.)

NOTE ON POWER REQUIREMENTS:

If your power supply in insufficient, you could cause the ESP8266 to reboot repeatedly or not be able to drive the Stepper Motor.

Also, Steppers can get really hot w/o current limiting.

Be sure to send a “STOP” command (see below) to switch the TB6612 to standby which removes power from the Stepper. Use “START” command to reapply power.

Step 5: Testing

I used the built-in Arduino Stepper Library https://www.arduino.cc/en/Reference/Stepper to control the stepper motor. I added this to a simple HTTP control web server to provide remote control of the stepper.

Use a PC with web browser or Linux cURL command to try the functions below:

Functions available:

  • http://{your_ip}/stepper/steps?5 -- Step 5 steps forward (values 1 to 200)
  • http://{your_ip}/stepper/steps?-10 -- Step 10 steps backwards (-1 to -200)
  • http://{your_ip}/stepper/rpm?6 -- Run at 6 RPM (1 to 50)
  • http://{your_ip}/stepper/stop -- Stop the stepper motor (Removes power)
  • http://{your_ip}/stepper/start -- Start the stepper motor (Restores power)

If you have a Linux machine (such as a Raspberry Pi) you can use the following simple automation example:

$ nano example.sh

Change ESP_IP to your ESP8266’s IP address.

$ bash example.sh 

Have Fun!

<p>IMPORTANT NOTE! The power regulator on the Adafruit HUZZAH ESP8266 board has CHANGED. It no longer can handle 12v DC. </p><p>A 6VDC 2amp power supply to feed the V+ and the Stepper now required! </p><p>The lower voltage will drop the torque, but will still step. </p><p>Alternately, use separate 12v for stepper and 3.3v to 6v for ESP8266.</p><p>I will update the docs here.</p><p>Older HUZZAH ESP8266's included a 3-12v regulator, so are unaffected.</p>
<p>nice.. so how can i make the functions as a button to trigger the stepper</p>
<p>Nice job.. But how comes the ESP stops responding after a couple of minutes? After RESET it works for another couple of minutes.. Is it MEMORY getting full or something?</p><p>Harry</p>
<p>Had a similar issue with powering a stepper on one of these. I ended up using a microstepping library I found online and modifying it slightly. I noticed the device would reset and have a kinds of crazy errors if I tried to do more than 30 steps at a time. So I added a delay(1) to the code every 30 steps. This has 100% resolved issues with resets and errors driving steppers from the esp8266 chipset.</p>
<p>Here is the microstep library: http://printplussupport.be/microstep.html</p>
<p>No, the web server on the ESP shouldn't run out of memory. I've been running a similar application (Space Station (ISS) Tracker<br><a href="https://github.com/rgrokett/ESP8266_ISSPointer" rel="nofollow">https://github.com/rgrokett/ESP8266_ISSPointer </a> ) <br>for many months without a reset. </p><p>My best guess is that the power supply is insufficient or a loose connection. If the stepper vibrates the wiring, it can intermittently break a connection causing the ESP to hang. I had this problem until I soldered all the connections. </p>
<p>Hello,</p><p>im looking into this thread and i'd like to implement it into Domoticz as blinds controller ... but im not able to buy here in my country Adafruit TB6612...so do you think i can switch it for this one?<br><a href="https://www.sparkfun.com/products/9457" rel="nofollow">https://www.sparkfun.com/products/9457<br><br></a>and still use your code?<br>thanks for answer master. :)</p>
<p>Can you apply the same to run two stepper motors?</p>
The Adafruit TB6612 can only run 1 stepper. But it looks like this one: https://www.adafruit.com/products/2927 could run 2. And the description says it will work with an ESP8266 (though, might be just the ESP8266 Feather (https://www.adafruit.com/products/2821)
<p>Hey thanks for the instructable I am looking forward to get this working and playing with it.</p><p>When I try uploading the sketch it complains that Blink(), getvalue() and printusage are all undeclared.</p><p>Thanks</p>
<p>finally got the test page off adafruit, don't know how just kept playing</p><p>connecting to <a href="http://www.adafruit.com" rel="nofollow"> www.adafruit.com</a><br>Requesting URL: /testwifi/index.html<br>HTTP/1.1 200 OK<br>Date: Mon, 04 Jan 2016 20:06:15 GMT<br>Content-Type: text/html<br>Transfer-Encoding: chunked<br>Connection: close<br>Set-Cookie: __cfduid=df46de64de054aeeeb2ea71b1283fbc691451937975; expires=Tue, 03-Jan-17 20:06:15 GMT; path=/; domain=.adafruit.com; HttpOnly<br>Accept-Ranges: bytes<br>Access-Control-Allow-Credentials: true<br>Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Accept-Encoding, Authorization, Referer, User-Agent<br>Access-Control-Allow-Methods: GET, POST, OPTIONS<br>Access-Control-Max-Age: 1728000<br>Cf-Railgun: direct (starting new WAN connection)<br>Last-Modified: Thu, 27 Jun 2013 14:13:27 GMT<br>Vary: Accept-Encoding<br>Server: cloudflare-nginx<br>CF-RAY: 25f9901854ad3060-YYZ<br><br>4a<br>This is a test of the CC3000 module!<br>If you can read this, its working :)<br><br>0<br><br><br>closing connection<br>connecting to <a href="http://www.adafruit.com" rel="nofollow"> www.adafruit.com</a><br>Requesting URL: /testwifi/index.html</p><p>is that a true internet connection? how do i control a simple web blink?</p>
<p>I assume you have installed and tested the Adafruit ESP8266WiFi library into your Arduino IDE, and are using version 1.6.5 or higher of the IDE? </p><p>You also need to select Tools -&gt; Boards -&gt; &quot;Adafruit HUZZAH ESP8266&quot; in the IDE.</p><p>The sketch also uses the &quot;Stepper.h&quot; library that comes built into the Arduino IDE package.</p><p>If all of above is true and you can successfully compile and use the Adafruit HUZZAH ESP8266 breakout examples <a href="https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout">https://learn.adafruit.com/adafruit-huzzah-esp8266...</a> then I would suspect a missing close bracket } character in your copy of the sketch. Maybe re-download or cut/paste the RAW version of the ino sketch file into the Arduino IDE window and try a recompile. (You should see the blink(), printUsage() and getValue() functions in the bottom of the sketch.) </p><p>P.S.&gt; You do not need a ESP8266 board plugged in to recompile, but you do have to select the Adafruit board. </p>
<p>Hi rgrokett,</p><p>While I really have no idea why, I got it working after moving blink(), printUsage() and getValue() functions from the bottom of the sketch to just above the setup() function. So I will go play with it now.</p><p>Thanks!!</p>
<p>Hi rgrokett,</p><p>Thanks for the reply. All your assumptions are correct. I did run through and tested things o the Adafruit site and I am using the latest 1.6.6 (Ihave heard others having issue with this version and I am considering trying 1.6.5) IDE. I have also successfully compiled and ran a couple stepper Arduino stepper examples.</p><p>I also just downloaded (https://github.com/rgrokett/ESP8266_Stepper/archiv... and extracted your .ino file and tried compiling it with out editing a thing and got the same results (see screenshot).</p><p>If anything else comes to mind please let me know I think I will go through everything at Adafruit again and now that I see where those functions are defined I will review that as well. I will keep at it and hopefully figure it out.</p><p>Thanks again</p>
<p>can't get my huzzah to connect to my linksys wrt54g2, what router you use?</p>
<p>Take a look at this and see if it matches your issue or gives you some clues...<br>http://forum.arduino.cc/index.php?topic=366642.0</p>

About This Instructable

15,458views

47favorites

License:

More by rgrokett:BOINC SETI@HOME for Raspberry Pi Don't Forget your Raspberry RF ID Card! The Cat Has Left the Building - ESP8266 PIR Monitor 
Add instructable to: