Stepper Motor [NodeMCU,B4R]

Experimenting with the ESP8266 micro controller.
Site Admin
Posts: 224
Joined: 07 Oct 2017, 12:16

Stepper Motor [NodeMCU,B4R]

Postby rwblinn » 11 Oct 2017, 10:21

Controlling a Stepper Motor (via B4R program) connected to a NodeMCU.

Parts Needed
  • 1x ESP8266 - NodeMCU used for this experiment
  • 1x Stepper Motor - 28BYJ48 5V DC
  • 1 x ULN2003 Motor Driver
ULN2003 - NodeMCU
IN1 - Pin D1 (GPIO5)
IN2 - Pin D5 (GPIO14)
IN3 - Pin D2 (GPIO4)
IN4 - Pin D6 (GPIO12)


Download Source Code

Additional Libraries
rStepper v1.00

  • Control the stepper motor via MQTT using B4J application and B4A app
  • Connect the stepper motor to a RasPi and control via Node-RED and Domoticz
  • Build the motor into a Duplo Train



NodeMCU Pin Table Mapping

Code: Select all

Private D0 As Int = 16      'ignore
Private D1 As Int = 5      'ignore
Private D2 As Int = 4      'ignore
Private D3 As Int = 0      'ignore
Private D4 As Int = 2      'ignore
Private D5 As Int = 14      'ignore
Private D6 As Int = 12      'ignore
Private D7 As Int = 13      'ignore
Private D8 As Int = 15      'ignore
Private D9 As Int = 3      'ignore
Private D10 As Int = 1      'ignore

Motor Full Round
Make a full round by 4 times 512 StepsPerRevolution = 2048 steps (each step is 11.25°)
The Arduino "Stepper Library" runs in 4-step mode.
Example B4R Code (with short delay after each Step)

Code: Select all

Sub StepRound(u As Byte)
End Sub

Return to “ESP8266”

Who is online