Nodemcu esp8266 : Driving a 28BYJ-48 stepper using ULN2003


I needed a simple LUA module (with callbacks) that I can use to drive the cheap 28BYJ-48 & ULN2003 Combo for automating a Candy Jar. I did search online around to see if there is a readymade one available. when I couldn’t find any exact matches, Just wrote a Lua module based on bits and pieces I found online. Hope you find it useful. Feel free create an issue in Github project or get in touch with me for any feature requests.


With this Lua module, you can drive a stepper motor in 3 lines like this

stepper  = require ('stepper')
stepper.init({5,6,7,8}) --pin numbers to which the uln2003 is connected
stepper.rotate(stepper.FORWARD,2500,5,0,function () print('Rotation done.') end)

As you can see, this is an async module. your code should trigger rotate and let the module asynchronously and trigger your callback after completing the rotation.


Any nodemcu gpio pins should work. here is the combination that worked for me.

D5 IN1
D6 IN2
D7 IN3
D8 IN4

Fig : Connection Diagram for 28BYJ-48 Stepper motor using ULN2003 driver with nodemcu esp8266


Here are two good links that helped me understand how to get the stepper working


Monitoring Raspberry Pi temperature over mqtt

Hello, My dear fellow Raspberry Pi fan! hope your Pi-iot-hacking is going well.

Here is one from my side, read on…

I run so many things on my poor little raspberry pies and they often get heated up with all the burden I put on them. Since they are running headless, I don’t really know if it is on the verge of getting fried till it is too late. so after a couple of overheating instances, I started thinking, … How do I solve this issue?

As a first step, I came up with this simple hack which is a short nodejs script to monitor raspberry pi CPU temperature remotely.

Here is the link : pi_temp_logger

This runs as an autostarting Linux(Raspbian) service on raspberry pi which measures CPU temperature and posts to a configured MQTT broker topic Note: you can configure your broker and topic in

I use mqtt-spy to monitor and generate the graphs. feel free to get in touch with me if you are having any issues with using this by opening an issue.

Here is a screenshot of my Pi temperature increasing because of the dd command I used to stress the CPU [ awesome plots you see here are the courtesy of mqtt-spy ].

For detailed instructions on how to install the project, you can head to the git repo.

But it is not enough to know that it is heating up. We need to act on it, so for that part, I am planning to attach a fan to the raspberry pi and run it when the temperature goes beyond a particular threshold. Apart from the temperature, I believe knowing which process is loading the CPU is might help so I am thinking it might be a good idea to add the top 3 processes by CPU usage to the MQTT message. which might look something like this …

   "temperature" : "32.2",
   "units" : "celsius",
   "processes": [
               "command":"/usr/bin/dd ...",

what do you think? any suggestions? feel free to use the comments section to let me know. thanks for stopping by.

16 IoT youtube channels for serious IoT hobbyists

Since there are not enough structured courses on IoT in universities which really focus on the practical aspects of it, after blogs, Youtube became my defacto learning source for IoT. which is almost as good as quality college education without the pain of rules and rigidity of academic institutions.

Below are some of the youtube channels I currently follow. you might want to check them out. Being a computer science masters grad, I had a lot of trouble with electronics basics and these channels are a key part of filling the gaps in my knowledge and accelerating my learning process. Please note that this is no way an exhaustive list but these are just my favorites. 

 Adafruit   Andreas Spiess  CNLohr    EEVblog           electronupdate        GreatScott!   

 Hak5    Julian Ilett    Ludic Science   MickMake      

 Make:  mikeselectricstuff  NYC CNC    Pete B        

 Roman UrsuHack   



Hope you find it useful. Feel free to let me know your C&C using the comments section or contact form. Have a nice day.


My soldering woes with esp8266 esp12

The beginning of a new era in IoT:

Like most of the IoT enthusiasts, I also got excited when I first came across esp8266 from the espressif chip maker. Like any good student, I started with the nodemcu dev boards instead of trying to DIY-ing development boards. These dev boards were simply magical when compared to AT89s52 [8051 family] or Arduino that I used in past. Don’t even get the wrong impression that I don’t love Arduino but the fact that turnaround time for trying out things got greatly reduced with nodemcu made me get addicted to this platform.

Nodemcu dev boards v0.9(left) v1.0 (right)

This huge gain in productivity is partially due to the crisp documentation of the platform and modules available and also due to the fact that coding in Lua language is pure fun compared to C. One of the main reasons for that is the asynchronous event-driven programming model needed for Lua nodemcu whereas good old C language puts me in procedural auto-pilot mode which IMO, is not at all suitable for embedded system development. You can take my word when I say “it becomes very easy to learn async model in nodemcu Lua if one got used to similar event-driven async programming paradigm in past in any other language” ( like nodejs or any desktop or web UI programming Ex: Java AWT or something so common as js ajax).

Believe it or not, it simply brought tears of joy to write an internet-controlled-led program and get it working in a few minutes compared to blinking a led in 8051 which took a few days the first time [When I started learning 8051].

For example, this is how much code it takes to run a “Hello, World!” HTTP server on the wifi microcontroller!

    conn:send("<h1> Hello, NodeMcu.</h1>")

Source: Nodemcu website

Harsh Reality of economics:

But now comes the moment of truth,… you cannot go beyond blinking LEDs and few other fancy tricks with dev boards due to their size, cost and power requirements. which triggered my quest to find a suitable replacement minimal microcontroller circuit for prototypes. something that has below qualities

  1. small enough to fit on a PCB or prototype board without adding too much thickness
  2. cheap enough to leave in a project
  3. easy enough to write code for [I used nodemcu]

esp8266 has several variations based on the size and shape esp01 to esp12, 13, 32… the list goes on. I tried esp01 as it looked like a standalone dev board but

  • it was too sensitive to any interference and would reset very frequently.
  • not breadboard friendly

The infamous esp01 [$2 wifi mcu] from espressif that rocked IoT maker world

Lovely ray of the sunshine:

Finally, then I found the lovely ray of the sunshine in a dark realm of hobby electronics ………  Bang!  esp12 !!! which fits my previous list of requirements very nicely…


A hindering Problem:

but one thing I always found hard was soldering esp12 as its 2mm pin spacing is much less than that of a breadboard or prototype board (usually 2.54mm).

Here is how my initial attempts looked like…

Note: I am aware of my lousy soldering skills .. please don’t trouble yourself talking about it again 😛

The Solution that I stumbled upon:

Then came to my rescue the “ESP 07 and 12 Adapter plate” ….. TADA! available for 22 cents a piece ( which is RS 15 for me when I bought from India) in Ali express.  It made life so much easier and happy when I did not have to solder esp on a prototype board and it felt just like when became old enough in childhood and realized that killer clowns from outer space most likely are not a real thing and I can stop worrying about 😀

Adapter plate front face


Adapter plate back face

Final Result: Esp12 soldered on the adapter plate

Want to give it a try?

Here is the product link if you want to give it a try…

on a second thought, have you done anything similar and found any better alternative ? can you please graciously share it in below comments to reduce future trial and error frustration time for me. 🙂

My future plans:

Next thing I want to try is to create a proper PCB with SMD components for situations where I get into space constraints and this adapter proves to be too space consuming.

Have a nice day!