28BYJ-48 – 5V not working with esp8266

Hi All,
After watching the following video of Hollow Clock:

I decided to try building one of my own.
All items were bought according to what we see in the video :
1.Node MCU(8266)
2. DC DC Boost Step Up Converter 2.6-5.5V to 5V
3. Stepper Motor 28byj 48 Uln2003 5v

Everything were wired according to the following scheme :

Below is the code loaded to the card:

// Hollow Clock improved by SnowHead, Mart 2021
//
// Thanks to:
// shiura for stepper motor routines
// SnowHead for Internet-Time

#include "WTAClient.h"

#define ROTATION_PERIOD_IN_SEC   1
#define CREEPING_HANDS			 0		// set to 1 for smooth hands movement (needs more current, motor becomes hotter)

extern unsigned long askFrequency;

// Motor and clock parameters
#define STEPS_PER_ROTATION 4096L 		// steps of a single rotation of motor (motor: 64 steps/rotation, gear: 1/64)
#define RATIO 				   5		// minutes per a rotation (minutes wheel: 120 teeth, motors pinion: 10 teeth)
// wait for a single step of stepper
#define HIGH_SPEED_DELAY	   3		// minimal delay for highest speed, delay is calculated from steps and period
unsigned int delaytime;

//=== CLOCK ===
WTAClient wtaClient;
unsigned long locEpoch = 0, netEpoch = 0, start_time;

#define LED		16
#define PHASES  8

// ports used to control the stepper motor
// if your motor rotate to the opposite direction,
// change the order to {15, 13, 12, 14};
// ESP	 Stepper
// D5 -> IN1
// D6 -> IN2
// D7 -> IN3
// D8 -> IN4

int port[4] =
{ 14, 12, 13, 15 };

int seq[PHASES][4] =
#if (PHASES == 4)
{
{ HIGH, LOW,  HIGH,  LOW },
{ LOW,  HIGH, HIGH, LOW },
{ LOW,  HIGH, LOW,  HIGH },
{ HIGH, LOW,  LOW,  HIGH },
#else
// sequence of stepper motor control
{
{ LOW,  HIGH, HIGH, LOW },
{ LOW,  LOW,  HIGH, LOW },
{ LOW,  LOW,  HIGH, HIGH },
{ LOW,  LOW,  LOW,  HIGH },
{ HIGH, LOW,  LOW,  HIGH },
{ HIGH, LOW,  LOW,  LOW },
{ HIGH, HIGH, LOW,  LOW },
{ LOW,  HIGH, LOW,  LOW },
#endif
};

void rotate(int step)
{
	static int phase = 0;
	int i, j;
	int delta = (step > 0) ? 1 : 7;
#if DEBUG
	unsigned long ts = millis();

	Serial.print("rotating steps: ");
	Serial.println(step);
#endif

	step = (step > 0) ? step : -step;
	for (j = 0; j < step; j++)
	{
		phase = (phase + delta) % PHASES;
		for (i = 0; i < 4; i++)
		{
			digitalWrite(port[i], seq[phase][i]);
		}
#if DEBUG
		digitalWrite(LED, j & 1);
#endif
#if CREEPING_HANDS
		delay(delaytime);
#else
		delay(HIGH_SPEED_DELAY);
#endif
	}
	// power cut

    for (i = 0; i < 4; i++)
	{
		digitalWrite(port[i], LOW);
	}

#if DEBUG
	digitalWrite(LED, 1);
	Serial.print("needed milliseconds: ");
	Serial.println(millis()-ts);
#endif
#if ! CREEPING_HANDS
	if(digitalRead(0))
	{
		delay(100);
	}
#endif
}

long calc_step(int sec)
{
	long steps;
	static double round_accu = 0.0;
	double fsteps = (double)STEPS_PER_ROTATION * sec / 60.0 / (double)RATIO;
	double tsteps;

	round_accu += modf(fsteps, &tsteps);
	steps = (long)tsteps;
	round_accu = modf(round_accu, &tsteps);
	steps += (long)tsteps;

#if CREEPING_HANDS
	if(steps)
	{
		delaytime = ((ROTATION_PERIOD_IN_SEC * 1000L) - 250) / labs(steps);
		if(delaytime < HIGH_SPEED_DELAY)
		{
			delaytime = HIGH_SPEED_DELAY;
		}
	}
#endif
	return steps;
}

void setup()
{
	start_time = millis();

	pinMode(port[0], OUTPUT);
	pinMode(port[1], OUTPUT);
	pinMode(port[2], OUTPUT);
	pinMode(port[3], OUTPUT);
	pinMode(0, INPUT_PULLUP);
#if DEBUG
	pinMode(LED, OUTPUT);
	digitalWrite(LED, 1);
#endif

	Serial.begin(115200);
	wtaClient.Setup();
	askFrequency = 50;
}

void loop()
{
#if ! DEBUG
	if(!digitalRead(0))
	{
		delaytime = HIGH_SPEED_DELAY;
		while(!digitalRead(0))
		{
			rotate(1);
			Serial.println("teststep");
			delay(200);
		}
	}
#endif

#if (ROTATION_PERIOD_IN_SEC == 1)
	while(((netEpoch = wtaClient.GetCurrentTime()) == locEpoch) || (!netEpoch))
#else
	while(((netEpoch = wtaClient.GetCurrentTime()) % ROTATION_PERIOD_IN_SEC) || (!netEpoch))
#endif
	{
		delay(100);
	}
	askFrequency = 60 * 60 * 1000;
	if(locEpoch)
	{
		wtaClient.PrintTime();
		if(start_time)
		{
			delay(1000);
			locEpoch -= (millis() - start_time) / 1000;
			start_time = 0;
		}
		rotate(calc_step(netEpoch - locEpoch));
	}
	else
	{
		delay(1000);
	}
	locEpoch = netEpoch;
}

I don't know if this is related to the problem, but at the end of uploading the code I received a message "Leaving.... Hard resetting via RTS pin"

The four lamps of the engine does not light up at all, and likewise the engine does not rotate at all. I tried everything.
I would appreciate your help on this matter.

does it run every minute or continuously?

it is very weird idea to create 5v from 3V despite that 5V is already on board present.

Hi,
As I wrote, it doesn't work at all.

I moved your topic to an appropriate forum category @elhananyak.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

And the added current needed.

@elhananyak do you have a DMM? Digital Mulitimeter.

The 3V3 may not be able to produce the current needed, in fact thinking about it, it won't be able to cope with that lod.

Tom.. :smiley: :+1: :coffee: :australia:

This output is a normal part of a successful upload. It is not related to the problem you are experiencing.

Nice frizzy picture but it is a wiring diagram at best not a schematic. Nice blue lines that blob together. No power source(s) indicated. Sorry I do not read frizzies.

Hi,
This frizzy picture is intended for beginners, for simple and easy understanding.
The connections are below:
D5 > IN4
D6 > IN3
D7 > IN2
D8 > IN1

The power source is 5V by connecting to USB.

I checked with a multimeter and the voltage converter outputs 5v to the motor.

While the motor is running?

The motor is connected but does not rotate and the control lights on the card do not light up. The voltage output to the motor is 5v. The engine doesn't run at all, that's exactly my problem.

Is the code that you posted in your first post the only code that you have tried? Have you tried with a code that only tests the motor?

Please indicate, on your diagram, where you placed the DMM probes to measure the voltage.

You should use specific pins, that don't interfere with the working of the processor.
See the table on this page.
D8 is not a good choice.
Leo..

D5 on what to IN4 on what, ..etc. Sorry word problems do not have the needed information. I have probably a hundred boards with to hose designators and IN4 could also indicate interrupt #4. If that is easy to understand for beginners Schematics should be a Breeze! Realize I and many others may not know what those pictures are. Schematics is the language of electronics.

Hi, @elhananyak

What about the 3V3 input to the DC-DC.

Remove the stepper from the driver, the LEDs will tell you if there is any switching is occurring.

Tom.. :smiley: :+1: :coffee: :australia:

I previously tried to upload a code for the experiment without success.
Could it be that it didn't work because there is already some code on the card? What happens in the situation where I uploaded some code, and then I upload another code? Does the new code supersede the old code? In any case, I would appreciate it if you could guide me on how to upload a test code to see if the engine works.
The voltage measurement was performed at the output of the voltage converter, see marked in red:


The result I got is 5.10V.

The point is that the code was written by someone else, who activated the same code on a similar card and everything works (according to what we see in the video) so logically it should work for me too without any changes to the wiring or the code.

When I turn off the engine, still no lamp lights up on the card.
In fact, the lights on the card never came on.
I should mention that I tried to replace the engine with a new one, without change.

Hi,
You need to write your own code to verify that you can control the motor for a start.

Tom... :smiley: :+1: :coffee: :australia:

What happens in the situation where I uploaded some code, and then I upload another code? Does the new code supersede the old code?
Can I upload a new code or does it require deleting what is on the card first?
Can you give me the code to perform the basic test?