Hi learners! I hope you are doing great. Today, I am going to share the second version(V2.0) of the LCD library for Proteus. We have already shared the LCD V1.0 Library on our blog. Along with appreciation, we also get some complaints/suggestions about that library. So, we have designed a better version of the LCD library by keeping the suggestions in mind.
Version 2.0 has error-free working, better pinout prints, and is identical to the real-world LCD. We have also removed our website link from the LCD. This library includes two alphanumeric LCDs in it i.e. LCD 16x2 and LCD 20x4.
If you don't have any experience with the LCD, no need to worry as we will guide you from scratch. Before installing the LCD, let's first have a look at its brief introduction:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | Resistor | Amazon | Buy Now | |
3 | LCD 16x2 | Amazon | Buy Now | |
4 | LCD 20x4 | Amazon | Buy Now | |
5 | PIR Sensor | Amazon | Buy Now | |
6 | Arduino Uno | Amazon | Buy Now |
Let's have a look at the pinout of LCD:
Both of these LCDs(16x2 and 20x4) have similar pinouts and a simple basic circuit needs to be designed in order to operate them. There are a total of 16 pins present in LCD used for different purposes. The below table has the complete description of LCD Pinout:
Serial |
Pin |
Functionality |
Description |
1 |
VSS |
Ground |
This pin is connected to the ground terminal of the circuit. |
2 |
VDD |
Power Supply |
It is connected to the positive voltage(+5V) and is responsible for the power supply to all pins. |
3 |
VEE |
Voltage Emitter |
It is used to control the contrast of LCD. it applies the negative voltage and thus controls the electric field of the LCD. |
4 |
RS |
Register Select |
It selects the LCD register. LCD has two registers: an instruction register and a data register. |
5 |
RW |
Read or write |
The read-and-write operation is done through this pin. if set to HIGH then LCD is in reading mode and LOW means it is writing the data. |
6 |
E |
Enable |
Enables the working of LCD. If HIGH then allow the display and if LOW then disable it. |
7-14 |
D0-D7 |
Data bits (Pins to deal with the data) |
Data is sent to the LCD in a parallel manner. These pins send this data and out of these, D0 is the least significant and D7 is the most significant. |
The installation of the LCD V2.0 is simple. The first step is to download the library files. I believe you have Proteus installed. So, click the below button to download the Proteus Library zip file.
The zip file also contains the project, where we simply connected both the LCDs with Arduino, so that you could check their working. Moreover, code is also present in the file.
Once the Library is installed, you need to open your Proteus software. If it's already open, you have to restart it. Now follow the instructions.
I have installed both versions therefore, I am getting four options. I will choose the LCD 20X4 V2.0 and LCD 16X2 V2.0.
Click on the components and simply place them on the working sheet of Proteus, it will appear as shown below:
Now, let's design an LCD simulation in Proteus:
Now, let's design a simple LCD simulation, where we will interface it with an Arduino UNO board. We will display our website's link on the LCD. So, let's design the circuit:
Go to the pick library and select the following components:
Now let's design the Arduino code to display data on these LCDs:
Now, open your Arduino software, I hope you have it installed. Paste the below code in it, I have also added this code in the zip file.
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(1,0);
lcd.print("www.TheEngineering");
lcd.setCursor(4,1);
lcd.print("Projects.com");
}
void loop() {
}
The next step is to get the Hex File from Arduino IDE and add in the Proteus. For this, follow these steps:
If you have followed all the steps, I am sure your project will run successfully. I hope it was helpful to you. You must practice it more and try to make different projects. So, that was all for today, will meet you guys in the next tutorial. Take care!!!
Hello friends, I hope you all are having fun. In today's tutorial, I am going to share a new Proteus library for Raspberry Pi 2. We have already shared the Proteus Libraries of other Raspberry Pi modules i.e. Raspberry Pi 4, 3, Pico etc. and we discussed that these Pi modules won't be able to read the Python code. We have just designed the external appearance of these modules and you can use these Pi modules for circuit designing and project presentations.
We have also added the Arduino firmware in these boards, which is just to provide a bit of interaction with these boards. We have given these boards an unofficial title "Arduino Pi".
So, let's have a look at How to simulate Raspberry Pi in Proteus:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | LEDs | Amazon | Buy Now | |
3 | Resistor | Amazon | Buy Now | |
4 | LCD 16x2 | Amazon | Buy Now | |
5 | LCD 20x4 | Amazon | Buy Now | |
6 | PIR Sensor | Amazon | Buy Now |
Raspberry Pi 2 Library for Proteus
Note: For a better understanding, you should read How to Add a New Library File in Proteus.
Note: Its design is quite similar to that of Raspberry Pi 3, although we added the name to differentiate between the two.
As mentioned above, this Pi board won't be able to read the Python code. So, we have added the Arduino firmware in it to make it a bit more interactive. So, let's blink an LED with this Raspberry Pi 2 module in Proteus:
So, that was all for today. I hope you have enjoyed these Raspberry Pi simulated modules. IF have any questions, please ask in the comments. Thanks for reading.
Hello friends, I hope you all are doing great. As we are working on Raspberry Pi libraries for Proteus these days, so today, I am going to share another awesome library i.e. Raspberry Pi Zero W Libary for Proteus. We have already shared the Raspberry Pi Pico, Raspberry Pi 3 & Raspberry Pi 4 Libraries for Proteus, I hope you have already installed these libraries.
We have only designed the exterior look of this module, it won't be able to read the Python code. You can use this module to design circuit diagrams of your projects or to demonstrate your project in the presentation. Although, just for fun, we have added the Arduino UNO firmware to it. So, you can add the Arduino hex file in it. Something is better than nothing.
So, let's install the Proteus Library and simulate Raspberry Pi Zero:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | LEDs | Amazon | Buy Now | |
3 | Resistor | Amazon | Buy Now | |
4 | Raspberry Pi Zero | Amazon | Buy Now |
Raspberry Pi Zero W Library for Proteus
Note: For a better understanding, you should read How to Add a New Library File in Proteus.
As I mentioned earlier, this RPi Zero module in Proteus won't be able to read the Python code. So, just for fun, we have added the Arduino firmware inside. I know it's not that helpful but that's all we have right now. I hope we will design the real Raspberry Pi Zero simulator one day. So, let's add the Hex File in Raspberry Pi Zero W:
Let's clear this thing up one last time, we can't add Python code in this simulated Raspberry Pi Zero, so just to have some interaction, we have added the Arduino Hex file in it. So, we need to get the Arduino hex file.
So, that was all for today. I hope you will enjoy this Raspberry Pi Zero W Library for Proteus. If having any difficulty, ask in the comments. Thanks for reading. Have a good day.
Hello friends, I hope you all are doing great. Today, I am going to share the Raspberry Pi 4 Library for Proteus. In our previous tutorial, we shared the Raspberry Pi 3 Library for Proteus and as we mentioned in that tutorial, these Raspberry Pi libraries will have dummy modules i.e. We have just designed the exterior but these boards won't be able to read the Python code. Although just for fun, we have added the Arduino firmware in these boards, so we can upload the Arduino code in it. As the legends say, something is better than nothing. We have given these boards an unofficial name "Arduino Pi".
You can use these Pi boards to design your circuit diagram or can also use it in your presentation/demonstration of your projects. I hope you will enjoy these simulated Raspberry Pi boards. Before going forward, let's first have a brief overview of Raspberry Pi 4:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | LEDs | Amazon | Buy Now | |
3 | Resistor | Amazon | Buy Now | |
4 | Raspberry Pi 4 | Amazon | Buy Now |
So, now let's have a look at How to add this Proteus library and simulate Raspberry Pi 4 in Proteus.
Raspberry Pi 4 Library for Proteus
Now let's design the Simulation of Raspberry Pi 4 in Proteus. As I mentioned earlier, we can't feed Python code to this RPi4 board. So, we have added the Arduino firmware to it. Thus, we need to upload the Arduino hex file in it. Let's attach an LED with Raspberry Pi 4:
So, that was all for today. I hope you will enjoy this Raspberry Pi 4 Library for Proteus and will use it in your projects. Let me know your feedback. Have a good day. Take care!!!
Hello friends, I hope you all are doing great. In today's tutorial, I am going to share a new Proteus Library for Raspberry Pi 3 module. In my previous tutorial, I shared the Raspberry Pi Pico Library for Proteus. Similar to Pico Library, this RPi3 LIbrary won't operate on the Python code. We have just designed the front look to use in the circuit design. Although, we can upload Arduino code to these simulated Raspberry Pi boards.
This Raspberry Pi Proteus Library will have only the Raspberry Pi 3 board in it. We will design the other Pi boards soon. So, let's have a look at How to simulate Raspberry Pi in Proteus:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | LEDs | Amazon | Buy Now | |
3 | Resistor | Amazon | Buy Now | |
4 | Raspberry Pi 3 | Amazon | Buy Now |
First of all, we need to download the Raspberry Pi library files, by clicking the below button:
Raspberry Pi 3 Library for Proteus
Note: Look at How to add a new Library in Proteus 8, if you are having any issues.
Now we are going to simulate this Raspberry Pi 3 board in Proteus. We will attach a simple LED to one of its pins. As I told earlier, we have just designed the exterior of this board. It won't read the Python code. We can use it to design circuit diagrams for our project. But just for fun, we have added the Arduino firmware to it. So, we can upload the Arduino hex file in this Pi board.
Now, let's run our simulation to get the results:
So, that was all for today. I hope you will use this Raspberry Pi Library to design your projects. In the next tutorial, I will share the Raspberry Pi 4 Proteus Library. Till then, take care. Have fun!!!
Hello friends, I hope you all are fine. In today's tutorial, I am going to share the Raspberry Pi Pico Library for Proteus. It's a dummy library, we have just designed the display. We can't add the Python Code to it, but we can make it work with Arduino code. A mixture of Arduino and Raspberry Pi, I have given it an unofficial name "Arduino Pi". It's better to have something than nothing. You can design circuit diagrams using this library and can also demonstrate your project in presentations by designing simulations.
So, let's have a look at How to simulate Raspberry Pi Pico by adding this Proteus Library:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | LEDs | Amazon | Buy Now | |
3 | Resistor | Amazon | Buy Now | |
4 | Raspberry Pi Pico | Amazon | Buy Now |
Raspberry Pi Pico Library for Proteus
Note: Look at How to add a new Library in Proteus 8, if you are having any issues.
We have tried to keep it small in size so that other components could get more space.
As I told earlier, we can't program this Pico board with Python, which is the actual programming language of this board. But just for fun, we have enabled it to read the Arduino code. Let's design a simple blink example to see how it works:
Now let's run our simulation to check the results:
So, that was all for today. I hope you will enjoy this Raspberry Pi Pico Library for Proteus and will use it in your simulations. If you have any suggestions, use the below comment form. Thanks for reading. Take care!!!
Hello friends, I hope you all are doing well. In today's tutorial, I am going to share a new Proteus Library of ESP32 embedded module. ESP32 is a microcontroller board used mostly in IoT projects. It's a successor of ESP8266 or NodeMCU. We have already shared the NodeMCU Library for Proteus and I hope you guys have enjoyed it.
Proteus software is not capable of handling WiFi or BLE technology, thus we can't implement these technologies in the ESP32 board. Though, you can use its input/output pins to interface embedded sensors and modules. You can also use it to design the Circuit Diagram of your Project.
So, let's have a look at How to simulate ESP32 board in Proteus:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | LEDs | Amazon | Buy Now | |
3 | Resistor | Amazon | Buy Now | |
4 | ESP32 | Amazon | Buy Now |
Note: Look at How to add new Library in Proteus 8, if you don't know already.
So, using this ESP32 Library, we have added the board in Proteus software. Now, let's simulate ESP32 in Proteus:
We are going to simulate the ESP32 board by running Blink LED Example. As I told earlier, we can't add WiFi and BLE capabilities in this simulated ESP32 board. So, we are going to select Arduino UNO in the board section of Arduino IDE to get the hex file.
So, that was all for today. I hope you have enjoyed simulating ESP32 board in Proteus software. If you have any questions, ask in the comments. Till the next tutorial, take care. Have fun !!!
Hello friends, I hope you all are doing great. In today's tutorial, I will share a Proteus Library of another embedded module i.e. NodeMCU. NodeMCU is a microcontroller board and if you are new to this board, you should read Introduction to NodeMCU to get your hands dirty. NodeMCU is not present in the components library of Proteus and using this library you can easily simulate NodeMCU in Proteus.
We can't add WiFi and BLE capabilities to our module in the Proteus software, that's why it will just perform the basic functions i.e. sensors interfacing, PWM, I/O control etc. So, you can use it for simple code testing and can also use it to design circuit diagrams of your projects.
So, let's have a look at How to download NodeMCU Proteus Library and simulate it:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | LEDs | Amazon | Buy Now | |
3 | Resistor | Amazon | Buy Now | |
4 | ESP8266 | Amazon | Buy Now |
Note: Look at How to add new Library in Proteus 8, if you don't know already.
So, we have successfully added the NodeMCU module to our Proteus software. Now let's simulate NodeMCU and for that, I am going to use the blink example:
Note: As you can see in the above code, we have selected Arduino UNO in the boards' section. As I have told earlier, this NodeMCU module is only going to use its pins, we can't add WiFi or BLE capabilities in the Proteus software. So, while compiling the code, select Arduino UNO board. Something is better than nothing.
So, that's how you can easily simulate NodeMCU in the Proteus software. If you have any questions, please ask in the comments. I will resolve them as soon as possible. In the next tutorial, we will share the ESP32 Library for Proteus. Till then take care and have fun!!!
Keywords
ESP32, IoT, Temperature sensor, Humidity sensor, Pressure sensor, Altitude sensor, Arduino IDE, ThingSpeak.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | ESP32 | Amazon | Buy Now |
The evolving generation of wireless technology has made human life a lot easier. Where everything is online and automatic we can easily monitor multiple things virtually from anywhere in the world. The WSN (wireless sensor networks) and Internet of things or IoT play an important role in implementing and accessing these wireless technologies. Smart homes, smart cities and smart weather monitoring systems are examples of such technologies where things are quite simpler or easier.
In this web-server based weather monitoring system, the weather data (from the surrounding environment or of a particular location) like temperature, humidity, pressure etc. is measured with the help of some sensors and then the collected data will be stored on a server after being processed by a microcontroller. Our daily activities are inseparable from weather conditions and various environmental factors. The real-time data collected can be used in research and analysis and the results can be helpful in human life and for improving environmental conditions as well.
The Internet of Things is a system made up of multiple inter-related computing devices. The main factor ‘things’ in IoT is designated to a component that is capable of communicating data over a network (IoT), the thing could be animals, a digital machine, a sensor, a human being etc. Each component of the Internet of Things network is given an individual or a distinct identity and the ability to communicate data or information over a wireless network that is too without the intervention of a human or a computer [8].
An interface medium capable of collecting, controlling, and communicating data among transmitter and recipient electronic equipment or servers is required to build the IoT network[9].
The ESP32 microcontroller series was developed by Espressif Systems. This module (the ESP32) includes a 2.4GHz Wi-Fi chip, memory, a 32-bit Tensilica microcontroller, an antenna, peripheral interfacing abilities, power management modules, and more. This ESP32 module is excellent for the Internet of things because of all of its technological and infrastructural aspects [10].
DHT11 and BMP280 sensors are used to collect the data from their surrounding environment and then communicate the data to the ESP32 module over a particular protocol [11].
The application of this weather monitoring system can also play an important role in the field of agriculture[12 ] to increase productivity, research application, and reducing manpower (by reducing the need to manually monitor the field status). Sometimes in a particular agricultural zone that is hazardous for a human beings, it is quite difficult to manually (offline) monitor the environment or weather conditions. In such cases, this web server based or online weather monitoring system can be of great importance.
Fig. 1
The list and quantity of the components required to implement the web server based weather monitoring system are shown in Table1.
Table: 1
Fig. 2 DHT11 sensor
DHT11 sensor (or temperature and humidity sensor) is a sensor module used to measure humidity and temperature from its surrounding. This sensor module is responsible for monitoring the ambient temperature and humidity of a given area. An NTC (negative temperature co-efficient) temperature sensor and a resistive type humidity sensor make up the sensor. An 8-bit microcontroller is also included. The microcontroller performs ADC (analogue to digital conversion) and outputs a digital signal via the single wire protocol [13].
Some of the technical specifications of the DHT11 sensor are:
Table:2 DHT11 technical specifications
DHT11 sensors can also be used to create a wired sensor system with up to 20 meters of cable.
To measure temperature and humidity, two DHT modules (DHT11 and DHT22) are available on the market. Both modules serve the same purpose, but they have different specifications. The DHT22 sensor, for example, has a wider range of temperature and humidity sensitivity. However, DHT22 is more expensive than DHT11. As a result, you can choose to use any of the modules as per your needs.
Table.3 Interfacing DHT11 with ESP32
Another sensor we are using is the BMP280. The BMP280, also known as the barometric pressure sensor, is a temperature, pressure, and altitude sensor. This sensor's small size and low power consumption make it suitable for mobile applications, GPS modules, and battery-powered devices, among other things[15].
The Bosch BMP280 is based on Bosch's validated ‘Piezo-resistive pressure sensor technology’, which features high accuracy, long-term stability, linearity, and EMC robustness.
The barometric pressure sensor (280) is the successor to the BMP180 sensor, and it is mostly preferred in all areas where precise temperature and pressure measurements are required.
Fig.3 BMP280 Sensor
Fitness, indoor navigation, and GPS refinement are all new technologies which require relative accuracy, and the BMP280 is ideal for them. This module is preferred over the other available modules for temperature records or measurement because of its low TCO (Temperature coefficient of Offset).
The temperature measured with the BMP280 sensor is more accurate than the DHT11 sensor. BMP80 provides a 0.01°C accuracy rate.
Some technical specifications of the BMP280 sensor are:
Table:4 BMP280 Technical specifications
A web server is a place where one can store data online and can access that data at any time and from anywhere in the world [16]. A real-time data is created with the help of a web-server. There are various web services available to store real-time data for research and analysis like AWS (Amazon Web Service), Azure, Firebase etc.
We are using the ThinSpeak web service provided by MathWorks which allows us to send sensor readings/data to the cloud. The ThingSpeak is an open source data platform for the Internet of Things (IoT) applications. We can also visualize and act on or access the data (calculate the data) sent to the ThingSpeak server from ESP32. Two different types of channels are available to store data on the ThingSpeak server namely ‘Public Channel’ and ‘Private Channel’ and one can use either of the available channels to store and display data [17].
ThingSpeak is frequently used for IoT prototyping and proof-of-concept systems that require analytics[18].
We need to give instructions to our ESP32 module so that it can interface, read data from DHT11 and BMP280 sensors and then finally publish the collected data to the ThingSpeak server. Arduino IDE is an integrated development environment used to write, compile and debug the program for the ESP32 module[19].
Fig. Arduino IDE
The process flow of our weather monitoring system is shown below in Chart 1. The process starts with the initialization of ESP32 module which is acting as an interface medium between the sensor modules and the web-server. The ESP32 wi-fi module is continuously searching for the network credentials as per the instruction provided. After connecting to the internet the sensor modules will be initialized and the real-time data [22] collected from the surrounding environment will be pushed to the ThingSpeak web server[23].
Flow Chart: 1
The results observed from the implemented weather monitoring system are shown below. We observed four different environmental conditions which include temperature, humidity, pressure and altitude. The sensor data collected by ESP32 from DHT11 and BMP280 sensors is published to the ThingSpeak web server. On ThingSpeak we have created a channel that contains four fields to store four different environmental factors temperature, humidity, pressure and altitude.
Fig. Hardware
In fig. 4 we can see the ‘Field 1’ which is containing the temperature readings published or communicated from the ESP32 module and saved on the ThingSpeak server.
Similarly, fields 2, 3, and 4 are displaying the humidity, pressure and altitude respectively.
Fig. 4 Temperature (°C)
Fig. 5 Humidity
Fig. 6 Pressure (hPa)
Fig. 7 Altitude
Each factor is monitored at different intervals of time to observe the variations in various environmental factors. From table 5 we can see the various environmental factors and their values at different time intervals for the approximate duration of 24hrs.
Table 5 Variations in weather conditions
We observed the weather conditions (that includes temperature, humidity, pressure and altitude) with our “Web-server based weather monitoring system using ESP32”. The observed real time data is stored on the ThingSpeak server which can be accessed globally. The different values of each (mentioned earlier) environmental factor at different intervals in time are also observed (given in table 5) and the observed result clearly shows the changes in the weather conditions for a full day cycle. Hence, we have successfully implemented and tested the web server based weather monitoring system with ESP32 and ThingSpeak web server.
Internet of Things is a system of multiple inter-related computing devices. The factor ‘thing’ in IoT is designated to an entity capable of communicating data over a network (IOT), which can be a digital machine, sensor, human being, animals etc. Each component that is included in IoT network is assigned with an unique identity called UID and the ability to communicate data over IoT network without any external human or computer intervention.
Hello readers, I hope you all are doing great. In our previous tutorial, we discussed how to upload data to Firebase Real-time Database using ESP32. In this tutorial, we will learn how to read the data stored on the Firebase Database with ESP32.
We can access the data stored in Firebase database from anywhere in the world, which makes this preferable in IoT applications.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | ESP32 | Amazon | Buy Now |
In our previous tutorial, we learnt how to upload an integer value (for demonstration) to Firebase real-time database. So, in this tutorial we will learn how to fetch or receive those integer values from Firebase database.
To access real-time data, we are using two ESP boards where one is used to upload/store the real-time data to the Firebase database and another to read the data stored on the firebase.
Although, it is not required to use two ESP boards, we can also access the previously saved data on the Firebase database with only a single ESP32/ESP8266 board.
We can use the same code for both ESP32 and ESP8266 but we need to make some changes like some of the libraries will be different for ESP8266 and the selection of ESP8266 development board while uploading the code with Arduino IDE.
Fig. 1 Reading data from firebase
Google's Firebase real-time database is a development platform that includes a number of services for managing and authenticating data.
Firebase is a mobile and web app development platform (that also works well with Android APIs) that includes features such as Firebase Cloud, real-time data, and Firebase authentication, among others.
According to Firebase's official documentation (https://firebase.google.com/docs/database), when a user creates a cross-platform application using JavaScript SDKs for Android or Apple, all clients share a single database.
Fig. 1 Firebase Real-time database and ESP32
The following are the main features of the Firebase Real-time database:
The Internet of Things, also known as IoT, is the interconnection of physical objects or devices with sensors and software accessing capabilities in order to communicate data or information over the internet.
We need an interface medium that can fetch, control, and communicate data between sender and receiver electronics devices or servers in order to build an IoT network.
The Firebase real-time database gives you a place to store data from sensors on your level device. With Android APIs, Firebase performs admirably.
Firebase is especially useful for storing data from sensors and syncing it between users in real-time in data-intensive Internet of things (IoT) applications. For the sake of simplicity and clarity, we can say that it is a Google cloud service for real-time collaborative apps.
We are using Arduino IDE to compile and upload code into the ESP32 module. You must have ESP32 board manager installed on your Arduino IDE to program the ESP32 module. To know more about Arduino IDE and how to use it, follow our previous tutorial i.e., on ESP32 programming series. The link is given below:
https://www.theengineeringprojects.com/2021/11/introduction-to-esp32-programming-series.html
Fig. 2 manage libraries
Fig. 3 Install Firebase ESP Client Library
We have already posted a tutorial on our website on getting started with Firebase real-time database and how to post or upload data to Firebase database from ESP32. Where we discussed, how to create a project on Firebase real-time database, authentication, how to access the API key and project URL etc.
So now we do not need to create a new project, we are using the same project and hence same API key and project URL to read or download the data from Firebase real-time database.
Fig. 4 Project Setting
Fig. 5 Project API key
Fig. 6 Project URL
//--add necessary header files
#include <WiFi.h>
#include <Firebase_ESP_Client.h>
#include "addons/TokenHelper.h" //Provide the token generation process info.
#include "addons/RTDBHelper.h" //Provide the real-time database payload printing info and other helper functions.
// Insert your network credentials
#define WIFI_SSID "ssid"
#define WIFI_PASSWORD "password"
// Insert Firebase project API Key
#define API_KEY "replace this with your project API key"
// ----Insert real-time database URL
#define DATABASE_URL "replace this with your project URL"
//Define Firebase Data object
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;
unsigned long sendDataPrevMillis = 0;
int read_data;
bool signupSuccess = false;
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(200);
}
Serial.println();
Serial.print("Connected to... ");
Serial.println(WiFi.localIP());
Serial.println();
// Assigning the project API key
config.api_key = API_KEY;
//Assign the project URL
config.database_url = DATABASE_URL;
/// check signup statue
if (Firebase.signUp(&config, &auth, "", "")) {
Serial.println("ok");
signupSuccess = true;
}
else {
Serial.printf("%s\n", config.signer.signupError.message.c_str());
}
// Assign the callback function for token generation task
config.token_status_callback = tokenStatusCallback;
Firebase.begin(&config, &auth);
Firebase.reconnectWiFi(true);
}
void loop()
{
if (Firebase.ready() && signupSuccess && (millis() -
sendDataPrevMillis > 8000 || sendDataPrevMillis == 0))
{
sendDataPrevMillis = millis();
if (Firebase.RTDB.getInt(&fbdo, "/test/int"))
{
if (fbdo.dataType() == "int")
{
read_data = fbdo.intData();
Serial.print("Data received: ");
Serial.println(read_data); //print the data received from the Firebase database
}
}
else
{
Serial.println(fbdo.errorReason()); //print he error (if any)
}
}
}
Fig. 7 Header files
Fig. 8 Helper libraries
Fig. 9 Insert API key
Fig. 10 RTDB URL
Fig. 11 Firebase Data Objects
Fig. 12 Enter Network credentials
Fig. 13 Initialize wifi module
Fig. 14 Fetch/obtain the IP address
Fig. 15 configuring API key
Fig. 16 configuring database URL
Fig. 17 sign up status
Fig. 18
Fig. 19 Fetch data from Firebase RTDB
Fig. 20
Fig. 21 Select development board and COM port
Fig. 22 Data sent Vs Data Received
This concludes the tutorial. I hope you found this of some help and also hope to see you soon with a new tutorial on ESP32.