Smart Display Board based on IoT and Google Firebase

by Dec 4, 2020Projects

Introduction

In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD.

Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are frequently used to display messages, notices, or for advertisement purposes. However, it is a tedious task to change it every day. So, here is the Smart Display Board. This project aims to develop a wireless display board that displays messages sent via an Android Application (Smart Display Board App). Whenever a user sends a message, it publishes in the Firebase Realtime Database. Whenever the message changes in the firebase, the NodeMCU fetches it from the firebase and displays it on the LCD screen.

Also, there are two modes in which you can send your message to LCD. The first one is Text Mode, and the second is Speech mode. In-text mode, you have to type your message manually in the app and hit the send button. Whereas in speech mode, you can vocalize your message, it will automatically send it to the firebase.

Components Required

  • NodeMCU ESP8266
  • Potentiometer
  • 16*2 LCD
  • MicroUSB Cable
  • Jumper Wires (Male-to-Female and Male-to-Male)

NodeMCU ESP8266 Pin Diagram

This is the pin diagram of NodeMCU ESP8266. For more details about NodeMCU, you can click here.

Source: https://components101.com/development-boards/nodemcu-esp8266-pinout-features-and-datasheet

16*2 LCD(Liquid Crystal Display) Pin Diagram

Source: https://create.arduino.cc/

Circuit Diagram

The circuit of our project is quite simple. Only, you need to join the NodeMCU8266 with the potentiometer and the 16*2 Liquid Crystal Display. Furthermore, you can refer to the circuit diagram given below. In this project, we are using interfacing 16*2 LCD with Node MCU without I2C.

The adjoining table shows the pins of Liquid Crystal Display which are to be connected to the Node MCU.

LCDNodeMCU
Register Select (RS)D3 (GPIO0)
Read/ Write (R/W)GND
Enable (EN)D4 (GPIO2)
D4D5 (GPIO14)
D5D6 (GPIO12)
D6D7 (GPIO13)
D7D8 (GPIO15)

Architecture

In the architecture, the software part contains the Google Firebase and Smart Display Board App, whereas LCD and NodeMCU are the hardware components.

MIT App Inventor

MIT App Inventor is a powerful tool to make android applications without prior knowledge of Java or Android Studio. Above all, it is an open-source tool to make efficient apps. Moreover, it requires only a logical block programming approach rather than actual programming. The below images are a few snippets from the app. You can download the code and app here.

You can click here to learn more about MIT App Inventor.

Google Firebase

Google Firebase provides two types of databases, the Real-time database, and the Cloud Firestore. The Firebase real-time Database lets you store and sync data between your users in realtime. The Cloud Firestore is a more intuitive data model than Realtime Database. And, Cloud Firestore is richer, faster, and more scalable than the Realtime Database.

In this project, we are using the real-time database. Since there is real-time communication between the software and the hardware.

ESP8266 Code

This is the NodeMCU Code for our project

// Created by Anupama Koley


#include "FirebaseESP8266.h"
#include<LiquidCrystal.h>
#include<ESP8266WiFi.h>

const int rs = 0, en = 2, d4 = 14, d5 = 12, d6 = 13, d7 = 15;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

#define firebase_host "https://pythonmydb.firebaseio.com/"
#define auth_key "your_authentication_key"

#define wifi_ssid "your_wifi_name"      
#define wifi_pass "your-wifi_password"

FirebaseData fbdata;

void setup() 
{
  Serial.begin(115200);

  WiFi.begin(wifi_ssid, wifi_pass);
  Serial.print("Connecting to ");
  Serial.print(wifi_ssid);

  while(WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }

  Serial.println();
  Serial.print("Connected to ");
  Serial.println(wifi_ssid);
  Serial.print("IP Address is: ");
  Serial.println(WiFi.localIP());

  Firebase.begin(firebase_host, auth_key); 
  Firebase.reconnectWiFi(true);
  
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Smart Display");
}

void loop() 
{
  if (Firebase.getString(fbdata, "DisplayBoard/Message"))
  {
   String message = fbdata.stringData();
   Serial.println(message);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print(message);
   
   for (int positionCounter = 0; positionCounter < 13; positionCounter++) 
   {
    lcd.scrollDisplayLeft();                // scroll one position left:
    delay(350);                             // wait a bit:
   }

  // scroll 29 positions (string length + display length) to the right
  // to move it offscreen right:

  for (int positionCounter = 0; positionCounter < 29; positionCounter++) 
  {
    lcd.scrollDisplayRight();               // scroll one position right:
    delay(100);                             // wait a bit:
  }

  // scroll 16 positions (display length + string length) to the left
  // to move it back to center:

  for (int positionCounter = 0; positionCounter < 16; positionCounter++) 
  {
    lcd.scrollDisplayLeft();                // scroll one position left:
    delay(350);                             // wait a bit:
  }

 }
 else
 {
    Serial.print("Error in getInt, ");
    Serial.println(fbdata.errorReason());
  }  
}

Code Explanation

#include "FirebaseESP8266.h"
#include<LiquidCrystal.h>
#include<ESP8266WiFi.h>

Firstly, we need to include the most suitable libraries as per our requirements. Here, the FirebaseESP8266.h library provides the most reliable operations for read, store, update, delete, backup, and restore the Firebase Realtime Database data. To use this library, you first need to install it. For installation, go to Tools -> Manage Libraries then, search FirebaseESP866 library. LiquidCrystal.h allows us to control the LCD, and this is a pre-installed library. Also, for enabling the wifi connection, we are using ESP8266WiFi.

const int rs = 0, en = 2, d4 = 14, d5 = 12, d6 = 13, d7 = 15;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

Then, do the initialization of the library with the LCD interfacing pin with NodeMCU.

#define firebase_host "https://pythonmydb.firebaseio.com/"
#define auth_key "your_authentication_key"

#define wifi_ssid "your_wifi_name"      
#define wifi_pass "your-wifi_password"

FirebaseData fbdata;

By using #define macros, we are declaring all credentials. The macros are constant values that we use throughout the code. An object of FirebaseESP8266 is also created here for sending and receiving data.

Inside setup() function

void setup() 
{
  Serial.begin(115200);

  WiFi.begin(wifi_ssid, wifi_pass);
  Serial.print("Connecting to ");
  Serial.print(wifi_ssid);

  while(WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }

Inside the setup function, baud rate is fixed to 115200 baud and the WiFi Connection is established.

  Serial.println();
  Serial.print("Connected to ");
  Serial.println(wifi_ssid);
  Serial.print("IP Address is: ");
  Serial.println(WiFi.localIP());

When we run this code a message will be displayed on the serial monitor about the information of WiFi network with NodeMCU’s Local IP.

  Firebase.begin(firebase_host, auth_key); 
  Firebase.reconnectWiFi(true);

Then the conncetion of NodeMCU’s is being established with Google Firebase by passing Firebase Credentials as argument in function Firebase.begin(). The Firebase.reconnectWiFi() is enabled so that it will auto reconnect to the WiFi when connection is lost.

  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Smart Display");

Here, the LCD’s number of columns and rows are being setup. lcd.clear function clears the LCD screen if there is any previous character or text is present. Then, the setCursor function sets the cursor to 0,0 position of LCD. A message “Smart Display” then prints on the LCD screen.

Inside loop() function

if (Firebase.getString(fbdata, "DisplayBoard/Message"))
  {
   String message = fbdata.stringData();
   Serial.println(message);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print(message);
   

With the help of, Firebase.getString() function, we are fetching the data from firebase. Inside this function, we are passing the object of FirebaseESP8266 and the path of the firebase as an argument. Afterward, we are storing the data, fetched from the firebase with the stringData() function, inside the message variable of type String .and prints on the LCD Screen.

   for (int positionCounter = 0; positionCounter < 13; positionCounter++) 
   {
    lcd.scrollDisplayLeft();                
    delay(350);                            
   }

  for (int positionCounter = 0; positionCounter < 29; positionCounter++) 
  {
    lcd.scrollDisplayRight();               
    delay(100);                             
  }

  for (int positionCounter = 0; positionCounter < 16; positionCounter++) 
  {
    lcd.scrollDisplayLeft();                 
    delay(350);                             
  }

We are using these for loops to shift the whole string of the LCD Display. The scrollDisplayLeft() and scrollDisplayRight() functions are moving a single character left and right respectively. When we run this code, then the characters will appear as they are moving continuously, because we are using a small delay inside every for loop.

else
 {
    Serial.print("Error in getInt, ");
    Serial.println(fbdata.errorReason());
  }  

Lastly, an error message with error reason prints on the serial monitor, in case the establishment of a connection between NodeMCU and GoogleFirebase fails.

Demo Video

Here is my demo video of my project.

I hope you all enjoyed a lot throughout this project ;). If you have any doubt, feel free to comment.

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

How to Simulate IoT projects using Cisco Packet Tracer

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

How to design a Wireless Blind Stick using  nRF24L01 Module?

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

How to implement Machine Learning on IoT based Data?

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Gardening System – GO GREEN Project

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....

How to build a Safety Monitoring System for COVID-19

How to build a Safety Monitoring System for COVID-19

It is expected that the world will need to battle the COVID-19 pandemic with precautious measures until an effective vaccine is developed. This project proposes a real-time safety monitoring system for COVID-19. The proposed system would employ an Internet of Things...

Air Quality Monitoring using NodeMCU and MQ2 Sensor – IoT

Air Quality Monitoring using NodeMCU and MQ2 Sensor – IoT

There have been many incidents like explosions and fire due to certain gases leakage. Such incidents can cause dangerous effects if the leakage is not detected at an early stage. Therefore, Measurement and control of these types of toxic gases present in the...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....