Tag Archives: esp2866

28BYI-48 stepper motor with Wifi - final setup

Controlling a 28BYI-48 stepper motor with Wifi for less than 10$ USD by using an esp2866 12-q

For low cost robots, remote controlled laser pointers, cat or fish feeding machines I found a really cheap way to move things by programmable wifi. The already handy usable 28BYJ-48 coming small motor driver i board is  available in china for about 2$. It additionally needs to be driven by a fast micro controller like the Arduino or the much more capable Raspberry Pi.  As I was experimenting with the esp2866 12-Q recently, the combination of this two useful things seemed more than obvious.  Therefore I decided to give it a try.

Unfortunately the stepper motor and its driver chip the ULN2003a need at least 5Vs to run, a voltage the esp2866 would by killed by as its maximum rating is about 3.6. in conclusion two power circuits or two power sources would be required. I tried to keep things simple by using an 5V-12V power source and step down converting it to 3.3V with an lm2655 based step down circuit. This setup allows an efficiency about 95% and avoids producing high amounts of heat as linear step down converters would have done. Overall the motor and the controllers consume 0.35 Amps at 5V therefore about 1.75 Watts.

Parts

  • 2$ 28BYJ-48 with ULN2003a motor driver
  • 2$ esp8266
  • 2$ step-down-converter
  • > 0,5$ breadboard 2.5 mm adapter for the esp8266
  • > 0,.5$  for15 cm of additional cables low diameter
  • soldering equipment and an 3.3V FTDI Adapter for flashing the esp2866

Steps to build your own:

  1. solder the esp2866 on the adapter board
  2. reverse the in1 in2 in3 in4 pins to the other side of the motor driver ULN2003a  board
  3. put the breadboard adapter on this pins starting with vcc followed by in1 to in4
  4. connect the v_out of the step down circuit with vcc of the breadboard adapter
  5. connect v_in of the step down circuit to the vcc of the motor driver board
  6. connect all GNDs together
  7. add pins on the breadboard adapter for flasingh the esp2866, GND, VCC, TX and RX
  8. flash the esp2866 with
    https://github.com/PaulPetring/esp2866-28BYJ-48-motor-control/blob/master/simple.ino
  9. test solderinng and apply between 5V an 12V connected to the motor driver board
  10. have fun 🙂

Wiring concept

Video on Youtube

https://github.com/PaulPetring/esp2866-28BYJ-48-motor-control

Controlling ws2812b with an esp8266 by open-pixel-control protocol

Harder than it looks but controlling an 5m led stripe using the esp8266 by the open pixel control protocol took me a night (and might be the reason for extra bad english as i write this post directly after it). But it’s real fun!

There are several ways to make the controller blink, the easiest way is shown here:

while true; do ( echo -en '\x00\x00\x02\xA6'; dd if=/dev/urandom bs=678 count=1 status=none ) | ncat --send-only --udp 172.22.99.155 2342; sleep 0.1; done

For the duration of infintiy, it sends the static header consisting of 4 bytes ( prio, command and checksum) followed by 8bit red 8bit green and 8bit blue for each led of the stripe. It gets the blinking values by asking the source of random in linux.  It lacks a bit of white as my power source got to its limits, so if you reimplement this use 5V and 1A per 30 leds.

Another thing to mention is the data length field which are bytes 3-4 of the header or \x02\xA6 as in the command above. This length needs to equal the amount of leds times three, so in this example 226 Leds where controlled as the bytes in network order end up to be 678.

This results in that little animation:

Youtube Video

Another possibility is to send these packets by a small python script like that:

import socket
import time

from struct import *

HOST = 'your-hostname'    
PORT = 2342              
colors = [(255,255,255), (255,0,0) ,(0,0,255), (0,255,0)  ]


for color in colors:
        print "sending color {} {} {}".format(color[0],color[1],color[2])
        data = [pack('b',0),pack('b',0), pack('!h',678)];

        for i in range(0,226):
                data.append(pack('BBB',color[0],color[1],color[2]))

        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)


        for i in range(0,1024):
                s.sendto("".join(data),(HOST,PORT))

        time.sleep(0.5)
        s.close()

import pdb; pdb.set_trace()

Code for the controller at github.