Story of a light bulb

Short Story

I made a simple internet-connected table lamp that blinked when you visited this page. It will blink again if you click on the below button. See a better playground here.

Love for lights

I get attracted to lights very easily. My shelf, windows, and drawer are almost filled up with different types of LED bulbs and fairy lights. This interest hit me long back when I was in 5th grade and one of the seniors named Riya brought a battery and bulb for the school science exhibition. That was the first time I came to know that a battery and wire can light up a bulb. That day I returned home and pulled out batteries from the TV remote control, and started trying out the same. I was so happy when it worked for the first time. I knew nothing about battery and bulb, but it just worked. Even now, when I make something with the bulb, I remember her.

From zero

Fast forward to 2022. It was a boring rainy weekend and I had a ton of time to kill. Like everyone else, I have a dozen of DIY project ideas on my bucket list. I wanted to finish at least one of them per month. One of the ideas was to make a mood light that stays on my table and should be more than just a light at the same time.

The initial thought I had in my mind was to hack the IoT bulbs I already have (so that I don’t have to build one). But most commonly available IoT bulbs don’t have public APIs. I have even reached out to the Smitch and Syska team regarding this, but no hope. Reverse engineering their protocol is a headache.

I decided to build one. These things happened over the night.


Why should I do this ? For fun. Yeah, that’s the first priority.

I like to get notifications that won’t disturb me. Notifications are supposed to be disturbing, but I wanted to make them friendlier. Notifications from the calendar, social media, chat, GitHub hooks, and whatnots.

Choosing the stack

My interest in electronics (and obviously bulbs) grew up with me (no, I still don’t know how to use a multimeter properly). I used to disassemble and repair electronic gadgets in my house (and damaged most of them for some mysterious reasons). I chose computer science as my main subject in 12th grade. I learned some programming concepts. Then I came to know about Arduino boards (programmable microcontrollers), and started playing with them.

I have a couple of RaspberryPi boards but it will be an overkill for this tiny little project. Even RaspberryPi Zero would be too much. RaspberryPi Pico is ok, but I would have to wire up additional esp-01 with it for the WiFi connectivity. RaspberryPi Pico W is perfect but it’s not available in stores at the time of writing this.

A couple of years back, I bought some NodeMCUs (think of them as Arduino + WiFi) but way cheaper. It was like 2$ when I purchased it. I also bought some sensors and relays to make hobby projects out of it.

Finally, I decided to use the NodeMCU.


We all know about LEDs, they are awesome. Think of LED strips(LED bulbs connected to each other), they are super cool. Think of led strips in which each LED can make more than 10000 colors(combinations of red, green, and blue), superb. Now think about controlling each LED and its color individually, that’s heaven! NeoPixel is the one. There was no doubt about using addressable LEDs like WS2812B. The one I chose is the rounded WS2812B with 24 LEDs.


Even though this is going to be on my table all day, I’m hesitant to power it with a wired adapter of any sort. I had a plan to use a few 18650 batteries I have, but the charging modules and voltage regulators are going to complicate things. Then I thought that I will use my old Mi power bank, but since it doesn’t have a low power mode, it will turn off if a minimum amount of power is not consumed from it. NodeMCU only draws around 110 mA when idle.

Finally, I bought the Mi pocket power bank pro, which is considerably small and has a low power mode.

Software and services

Deno is used to build the backend REST API and WebSocket server. Deployed on deno deploy. Glitch is also a good alternative, but it sleeps when no requests are made for 5 mins or so.

Logic in NodeMCU is written in Arduino (a framework built on top of C++).

How it works

I have deployed the REST API and a web socket server in deno edge. The REST API can be used as a hook API. The server accepts messages and broadcasts to all the connected web socket clients. NodeMCU is subscribed to the above-mentioned WebSocket server and handles incoming requests whenever a message event occurs.

Future plans

Tagged in :