How to get started with IoT using NodeMCU Devkit and Firebase database

How to get started with IoT using NodeMCU Devkit and Firebase databaseJibin ThomasBlockedUnblockFollowFollowingApr 24Photo by Tim Käbel on Unsplash“The Internet will disappear.

There will be so many IP addresses, so many devices, sensors, things that you are wearing, things that you are interacting with, that you won’t even sense it.

It will be part of your presence all the time.

Imagine you walk into a room, and the room is dynamic.

And with your permission and all of that, you are interacting with the things going on in the room.

”Nowadays many devices that we use day to day are connected to the internet like Television, smart speakers, refrigerators, etc.

These devices extend their primary functions which allows them to interact with other devices on the internet and to be controlled remotely.

You can build your own IoT devices using some sensors and microcontrollers.

There are many development boards that will help you get started with IoT like Arduino, NodeMCU, Raspberry Pi, etc.

You can automate your home by building from these devices.

In this post, we will be using NodeMCU devkit and Firebase for turning on and off LED remotely.

NodeMCU devkit and Firebase are the best combinations to get started with building some IoT projects.

NodeMCU is cheap and has built-in wifi for internet connectivity, and the Firebase free plan is more than enough.

Setting up Development Environment1.

We will be using Arduino IDE for writing code and we will flash the code to the device.

Download the latest version of the IDE here.


Since we are using NodeMCU which is not officially supported by Arduino IDE, we have to add the JSON file of the device.

In Arduino IDE add this URL inOpen File > Preferences > Additional Board Manager URLshttp://arduino.




Select your Board fromTools > Board > NodeMCU 1.


To use firebase database in NodeMCU you need to download the firebase-arduino library which abstracts the REST API of the firebase.

Download firebase-arduino here.


Include the downloaded zip file on Arduino IDE.

Sketch > Include library > Add .

zip > Select zip file6.

You also need to install the ArduinoJson library which can be downloaded from Arduino IDE itself.

Note: The library version should not be 6.


x — use the latest 5.


xSketch > Include library > Manage Libraries > Search for ArduinoJson by Benoit BlanchonSetting up Firebase Database7.

Create a new firebase project from the console and head towards the database section.

Select the firebase real-time database.


Copy the database secret for authentication from Settings Panel > Service accounts.

Database secret9.

Add a led node to the firebase database.

This value will decide whether to turn on or off the LED.

Configuring Arduino IDE and firebase database to work togetherNow that all the setup procedures are done let’s start coding.

You need to create a macro for your database URL and firebase secret which you had copied in Step 8.

#define FIREBASE_HOST “yourfirebasedatabase.


com”#define FIREBASE_AUTH “*****”For simplicity, we will write a simple code for turning on and off LED remotely10.

The positive of the LED should be connected to the D1 pin and negative pin to the ground pin of NodeMCU.


Upload your code from Arduino IDE.

Sketch > Upload12.

Now try changing the database value to true and false.

The led should now start turn on and off.

Additionally, you can extend this project by creating a web app that will toggle the LED instead of manually changing the value in the database.

So now that you understand the basics of how to go about connecting NodeMCU to the internet and controlling it remotely, start hacking some new projects with it.


. More details

Leave a Reply