Professional Documents
Culture Documents
Final Espua 5 Assignment - Removed
Final Espua 5 Assignment - Removed
Final Espua 5 Assignment - Removed
ASSIGNMENT
Integrating Display Systems with ESP32
Microcontroller for Embedded System
05 Projects: Understanding Compatibility
and Integration with LCD, OLED, and
Seven-Segment Displays
Aim:
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects:
Understanding Compatibility and Integration with LCD, OLED, and Seven-Segment
Displays
Objectives:
1) Introduce the ESP32 microcontroller and its features.
1.1 Discuss the key features and capabilities of the ESP32 microcontroller, such as its
processing power, wireless connectivity, and peripheral support.
2.1 Understand the concept of LCD displays and their applications in embedded
systems.
✓ Define the basic principles of 16 x 2-character LCD display operation and its
components/pinout.
✓ Discuss the advantages and limitations of using LCD displays in embedded
systems.
✓ Identify the common applications of LCD displays in various projects.
2.2 Test and adjust the LCD display for optimal performance.
✓ Demonstrate the process of connecting and powering the LCD display with
ESP32.
✓ Perform testing procedures to ensure the LCD display is functioning correctly.
✓ Adjust the contrast settings using a potentiometer to achieve optimal readability
of the LCD display.
2.3 Displaying text such as 'Hello World!' and 'ESPUA LCD' on a 16x2 Character LCD:
Arduino Sketch Implementation using ESP32 Microcontroller.
✓ Demonstrate how to include the LiquidCrystal library in the sketch for LCD
control.
✓ Initialize the LCD display and set the appropriate configuration parameters for a
16x2 character display.
✓ Write code to display the message "Hello World!" on the first line of the LCD
display.
✓ Write code to display the message "ESPUA LCD" on the second line of the LCD
display.
✓ Upload the sketch to the ESP32 microcontroller and verify that the messages are
correctly displayed on the LCD.
2.4 Implement calculator functionality on the LCD display.
3.1 Introducing Configure and interface an I2C LCD display with ESP32
✓ Demonstrate how to create and display custom characters on the I2C LCD
display.
✓ Implement graphical elements and symbols (such as Heart, Bell, Alien, Check,
Speaker, Sound, Skull, and Lock) on the I2C LCD display as per needs.
4) Interfacing the DHT11 Temperature and Humidity Sensor with ESP32 and I2C LCD:
Familiarization, Wiring, and Real-Time Data Display.
✓ Explain the working principle of the DHT11 sensor and its ability to measure
temperature and humidity.
✓ 1.2 Describe the key features and specifications of the DHT11 sensor, including
its measurement range and accuracy.
✓ 1.3 Discuss the applications and uses of the DHT11 sensor in various embedded
systems.
4.2 Interfacing the Temperature and Humidity Sensor (DHT11) with ESP32:
✓ Explain the process of connecting the DHT11 sensor to the ESP32 microcontroller.
✓ Identify the necessary pins on the ESP32 for interfacing with the DHT11 sensor.
✓ Demonstrate the correct wiring connections between the DHT11 sensor and the
ESP32 microcontroller.
✓ Discuss the communication protocol or library required for retrieving data from
the DHT11 sensor.
4.3 Interfacing the Temperature and Humidity Sensor (DHT11) with ESP32 and I2C
LCD:
✓ Explain the process of connecting both the DHT11 sensor and the LCD display to
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
the ESP32 microcontroller.
✓ Discuss the necessary wiring connections and pin assignments for simultaneous
interfacing of the DHT11 sensor and I2C LCD display.
✓ Describe any additional considerations or modifications required to
accommodate both the DHT11 sensor and I2C LCD display simultaneously.
✓ Demonstrate the integration of the DHT11 sensor and I2C LCD display by
displaying temperature and humidity readings on the LCD.
5) Exploring OLED Display Modules: Wiring, Library Installation, 'Hello World!'
Example, Advanced Functionality, and Graphic Capabilities with ESP32.
✓ Identify the necessary pins on the ESP32 for connecting an OLED display module.
✓ Explain the wiring connections between the OLED display module and the ESP32
microcontroller.
✓ Discuss any additional components or resistors required for proper operation.
✓ Provide guidance on avoiding common wiring mistakes and ensuring reliable
connections.
✓ Identify the appropriate library for controlling the OLED display module with an
ESP32.
✓ Demonstrate the process of installing the OLED library in the Arduino IDE.
✓ Explain the purpose of the library and the functions it provides for controlling
the display.
5.3 Displaying Text on an OLED Display Module: "Hello World!" and “ESPUA
OLED” Example with different font size.
✓ Write an Arduino sketch to display the message “!Hello World!" and “ESPUA
OLED” on the OLED display with different font size in center position of OLED
screen also.
✓ Explain the code structure and key functions used to control the OLED display
module.
✓ Upload the sketch to the ESP32 microcontroller and verify the successful display
of the message on the OLED.
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
5.4 Exploring Advanced Functionality of OLED Displays: Numeric Bases, ASCII
Symbols, Text Scrolling, and Partial Display Scrolling with ESP32.
✓ Explain the methods and techniques for scrolling text horizontally on the
OLED display, allowing longer messages to fit within the limited screen
width.
✓ Demonstrate the implementation of horizontal text scrolling in an
Arduino sketch, showcasing the smooth transition and readability of the
scrolling text.
✓ Discuss the considerations and limitations when scrolling text vertically
on the OLED display, including potential memory constraints and visual
effects.
5.4.4 Partial Display Scrolling:
✓ Explain the method for drawing circles on the OLED display, utilizing a
center point and radius.
✓ Demonstrate how to draw both outlined circles and filled circles on the
OLED display.
✓ Discuss the usage of circles in various applications, such as visual
indicators and circular representations.
5.5.4 Drawing Triangles and filled triangles:
✓ Discuss the process of drawing triangles on the OLED display using three
specified points or coordinates.
✓ Demonstrate how to draw both outlined triangles and filled triangles on
the OLED display.
✓ Highlight the application of triangles in geometric representations and
graphical elements.
6) Mastering 7-Segment Displays with ESP32: Wiring, Library Integration, Sequential
Counting from 0 to 9 and Electronic Dice Roller Project.
✓ Explain the basic structure and functionality of a 7-Segment display, including its
arrangement of individual segments and common pin configurations.
✓ Differentiate between Common Cathode (CC) and Common Anode (CA) types
of 7-Segment displays, highlighting their electrical characteristics and wiring
requirements.
✓ Describe how a 7-Segment display works, including the concept of segment
activation and decoding to display different numbers and characters.
✓ Discuss the importance of current-limiting resistors in controlling the brightness
and preventing excessive current flow through the display.
6.2 Interfacing a 7-Segment Display Module to an ESP32 and Writing an Arduino
Sketch to Count from 0 to 9.
✓ Explain the concept and purpose of the electronic dice roller project, which
automates the dice rolling process for fun dice games.
✓ Discuss the advantages and convenience of using an electronic dice roller
compared to traditional dice.
6.3.2 Triggering the Dice Roll with the Tactile Switch:
✓ Connect the 7-Segment display to the appropriate ESP32 pins based on the
defined segment pins in the code.
✓ Establish the wiring connections for the tactile switch (push button) and
assign it to the specified pin in the code.
✓ Read the state of the tactile switch using the digitalRead() function within
the loop().
✓ If the button state is HIGH (pressed), generate a random number between
1 and 6 using the random() function.
✓ Set the generated number as the new value to be displayed on the 7-
Segment display using sevseg.setNumber().
✓ Refresh the display to show the rolled dice number using
sevseg.refreshDisplay().
The experiment covered topics such as the features and capabilities of the ESP32 microcontroller,
display system principles, LCD and I2C LCD display configuration, interfacing sensors with
ESP32 and LCD, exploring OLED display functionalities, and understanding the working
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
principle of 7-segment displays. Practical examples and Arduino sketches were provided to
demonstrate the implementation and usage of these components.
One of the specific projects covered in the experiment was the construction of an electronic dice
roller using a 7-segment display and ESP32. The project aimed to automate dice rolls for fun
games, utilizing a tactile switch to trigger the roll. When the switch was pressed, a random
number between 1 and 6 was generated, and the corresponding value was displayed on the 7-
segment display.
Overall, the experiment provided a comprehensive guide to working with ESP32, different
display systems, sensors, and specific projects, offering a range of outcomes such as
understanding microcontroller features, configuring and controlling displays, integrating
sensors, and building interactive applications.
Pre-Lab Questionnaire:
1) What are the key features and capabilities of the ESP32 microcontroller?
2) Explain the architecture of the ESP32 microcontroller and its different components.
3) How does the processing power of the ESP32 compare to other microcontrollers?
5) Describe the peripheral support of the ESP32 and its compatibility with sensors and
actuators.
6) Discuss the advantages and limitations of the ESP32 microcontroller compared to other
microcontrollers.
9) Compare and contrast the characteristics and applications of LCD, OLED, and seven-
segment displays.
10) What are the advantages and limitations of using LCD, OLED, and seven-segment
displays in embedded systems?
11) What is the role of an I2C LCD adapter in interfacing an LCD display with the ESP32
microcontroller?
12) Explain the significance of addressing in I2C communication and how it is relevant to
the configuration of an I2C LCD display with ESP32.
14) How does the DHT11 sensor measure temperature and humidity?
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
15) What are the key features of the DHT11 sensor?
16) Name some applications where the DHT11 sensor is commonly used in embedded
systems.
17) Which pins on the ESP32 are used for interfacing with the DHT11 sensor?
18) What communication protocol or library is required to retrieve data from the DHT11
sensor?
23) Identify two necessary pins on the ESP32 for connecting an OLED display module.
24) Name the appropriate library for controlling the OLED display module with an ESP32.
25) What function is used to display text on the OLED display module?
26) Explain the basic structure of a 7-Segment display and how individual segments are
arranged to form numbers or characters.
27) Differentiate between Common Cathode (CC) and Common Anode (CA) types of 7-
Segment displays in terms of their electrical characteristics and wiring requirements.
28) Describe the concept of segment activation and decoding in a 7-Segment display to
display different numbers or characters.
29) Discuss the role of current-limiting resistors in controlling brightness and preventing
excessive current flow through the display.
30) Explain the concept and purpose of the electronic dice roller project and its advantages
over traditional dice for fun dice games.
31) Explain the process of generating a random number between 1 and 6 using the random()
function when the button is pressed.
32) Demonstrate how to set the generated number as the value to be displayed on the 7-
Segment display using the SevSeg library's setNumber() function.
33) Explain how to refresh the display to show the rolled dice number using the SevSeg
library's refreshDisplay() function.
Objective 1
Introduce the ESP32 microcontroller and its features.
1.1 Discuss the key features and capabilities of the ESP32 microcontroller, such as its
processing power, wireless connectivity, and peripheral support.
Figure 1.1: Schematic of blink the onboard LED of ESP32 microcontroller board.
Code
1.1 Blink the onboard LED of ESP32 microcontroller board.
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Set built-in LED pin as an output
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // Turn on the LED
delay(1000); // Wait for 1 second
digitalWrite(LED_BUILTIN, LOW); // Turn off the LED
delay(1000); // Wait for 1 second
}
Observation
Figure 1.1.1: Simulation based blink the onboard LED of ESP32 microcontroller board.
Objective 2
Comprehensive Guide to Interface and Control LCD Displays with ESP32: Including Testing,
Customization, Calculator Functionality, and Sensor Integration.
2.1 Understand the concept of LCD displays and their applications in embedded
systems.
✓ Define the basic principles of 16 x 2-character LCD display operation and its
components/pinout.
✓ Discuss the advantages and limitations of using LCD displays in embedded
systems.
✓ Identify the common applications of LCD displays in various projects.
2.2 Test and adjust the LCD display for optimal performance.
✓ Demonstrate the process of connecting and powering the LCD display with
ESP32.
✓ Perform testing procedures to ensure the LCD display is functioning correctly.
✓ Adjust the contrast settings using a potentiometer to achieve optimal readability
of the LCD display.
2.3 Displaying text such as 'Hello World!' and 'ESPUA LCD' on a 16x2 Character LCD:
Arduino Sketch Implementation using ESP32 Microcontroller.
✓ Demonstrate how to include the LiquidCrystal library in the sketch for LCD
control.
✓ Initialize the LCD display and set the appropriate configuration parameters for a
16x2 character display.
✓ Write code to display the message "Hello World!" on the first line of the LCD
display.
✓ Write code to display the message "ESPUA LCD" on the second line of the LCD
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
display.
✓ Upload the sketch to the ESP32 microcontroller and verify that the messages are
correctly displayed on the LCD.
2.4 Implement calculator functionality on the LCD display.
Figure 2.1: Schematic of test and adjust the LCD display for optimal performance.
Figure 2.2: Schematic of Interface and Control LCD Displays with ESP32: Including Customization,
Calculator Functionality, and Sensor Integration.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define LCD_ADDRESS 0x27
#define LCD_COLUMNS 16
#define LCD_ROWS 2
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);
int num1 = 0;
int num2 = 0;
char operation;
bool isNum1Set = false;
bool isNum2Set = false;
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
lcd.setCursor(0, 0);
lcd.print("Calculator:");
}
void loop() {
if (!isNum1Set) {
getInput(&num1, "Num1:");
isNum1Set = true;
}
if (!isNum2Set) {
getInput(&num2, "Num2:");
isNum2Set = true;
}
getResult();
}
void getInput(int* num, String prompt) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(prompt);
while (!Serial.available()) {} // Wait for input
*num = Serial.parseInt(); // Read input as integer
lcd.setCursor(0, 1);
lcd.print(*num);
}
void getResult() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Result:");
int result;
switch (operation) {
case '+':
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
result = num1 / num2;
break;
default:
lcd.print("Invalid operation");
return;}
lcd.setCursor(0, 1);
lcd.print(result);
}
Figure 2.2.1: Simulation based test and adjust the LCD display for optimal performance.
Figure 2.2.2: Hardware Implementation based test and adjust the LCD display for optimal performance.
Figure 2.3.1: Simulation based displaying text such as 'Hello World!' and 'ESPUA LCD' on a 16x2
Character LCD: Arduino Sketch Implementation using ESP32 Microcontroller.
Figure 2.4.1: Simulation based implementing calculator functionality on the LCD display.
Figure 2.4.2: Hardware Implementation based implementing calculator functionality on the LCD
display.
3.1 Introducing Configure and interface an I2C LCD display with ESP32
✓ Explain the concept of an I2C LCD adapter and its role in simplifying the
connection between ESP32 and the LCD display.
✓ Identify the I2C address of the LCD display and discuss the significance of
addressing in I2C communication.
✓ Provide the pinout information for wiring an I2C LCD display to the ESP32
microcontroller.
✓ Demonstrate the correct wiring connections between the I2C LCD adapter,
ESP32, and the LCD display.
✓ Adjust the LCD contrast settings for optimal visibility.
✓ Install the required library for controlling the I2C LCD display in the Arduino
IDE.
✓ Determine the I2C address of the LCD display using code or other methods.
✓ Implement a basic example code, such as "Hello World!" and "ESPUA LCD", to
test the communication and functionality of the I2C LCD display.
3.2 Customize the I2C LCD display for specific project requirements.
✓ Demonstrate how to create and display custom characters on the I2C LCD
display.
✓ Implement graphical elements and symbols (such as Heart, Bell, Alien, Check,
Speaker, Sound, Skull, and Lock) on the I2C LCD display as per needs.
Figure 3.1: Schematic of configuring and interfacing an I2C LCD Display with ESP32: Addressing,
Wiring, Contrast Adjustment, Library Installation, and “! Hello World!” and “ESPUA LCD”.
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
Code
3.1 Implementing a basic example code, such as "Hello World!" and "ESPUA LCD", to test
the communication and functionality of the I2C LCD display
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address
#define LCD_ADDRESS 0x27
#define LCD_COLUMNS 16
#define LCD_ROWS 2
// Initialize the LCD object with the LCD address and dimensions
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);
void setup() {
// Initialize the serial communication for debugging
Serial.begin(9600);
// Initialize the LCD display
lcd.init();
lcd.backlight(); // Turn on the backlight
lcd.setCursor(0, 0); // Set cursor to the first row
// Print "Hello World!" on the LCD
lcd.print("Hello World!");
// Wait for 2 seconds
delay(2000);
// Clear the LCD display
lcd.clear();
// Print "ESPUA LCD" on the LCD
lcd.setCursor(0, 0); // Set cursor to the first row
lcd.print("ESPUA LCD");
// Wait for 2 seconds
delay(2000);
}
void loop() {
// No action needed in the loop
}
3.2 Implementing graphical elements and symbols (such as Heart, Bell, Alien, Check,
Speaker, Sound, Skull, and Lock) on the I2C LCD display as per needs.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define LCD_ADDRESS 0x27
#define LCD_COLUMNS 16
#define LCD_ROWS 2
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);
void setup() {
lcd.init();
lcd.backlight();
// Create custom characters
byte heartSymbol[8] = {
Figure 3.2.1: Simulation based implementing a basic example code, such as "Hello World!" and "ESPUA
LCD", to test the communication and functionality of the I2C LCD display
Figure 3.2.2: Hardware Implementation based implementing a basic example code, such as "Hello
World!" and "ESPUA LCD", to test the communication and functionality of the I2C LCD display
Figure 3.3.2: Hardware Implementation based implementing graphical elements and symbols (such as
Heart, Bell, Alien, Check, Speaker, Sound, Skull, and Lock) on the I2C LCD display as per needs.
Objective 4
Interfacing the DHT11 Temperature and Humidity Sensor with ESP32 and I2C LCD:
Familiarization, Wiring, and Real-Time Data Display.
✓ Explain the working principle of the DHT11 sensor and its ability to measure
temperature and humidity.
✓ 1.2 Describe the key features and specifications of the DHT11 sensor, including
its measurement range and accuracy.
✓ 1.3 Discuss the applications and uses of the DHT11 sensor in various embedded
systems.
4.2 Interfacing the Temperature and Humidity Sensor (DHT11) with ESP32:
✓ Explain the process of connecting the DHT11 sensor to the ESP32 microcontroller.
✓ Identify the necessary pins on the ESP32 for interfacing with the DHT11 sensor.
✓ Demonstrate the correct wiring connections between the DHT11 sensor and the
ESP32 microcontroller.
✓ Discuss the communication protocol or library required for retrieving data from
the DHT11 sensor.
4.3 Interfacing the Temperature and Humidity Sensor (DHT11) with ESP32 and I2C
LCD:
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
✓ Explain the process of connecting both the DHT11 sensor and the LCD display to
the ESP32 microcontroller.
✓ Discuss the necessary wiring connections and pin assignments for simultaneous
interfacing of the DHT11 sensor and I2C LCD display.
✓ Describe any additional considerations or modifications required to
accommodate both the DHT11 sensor and I2C LCD display simultaneously.
✓ Demonstrate the integration of the DHT11 sensor and I2C LCD display by
displaying temperature and humidity readings on the LCD.
Figure 4.1: Schematic of interfacing the Temperature and Humidity Sensor (DHT11) with ESP32
Figure 4.2: Schematic of interfacing the Temperature and Humidity Sensor (DHT11) with ESP32 and
I2C LCD
Code
4.2 Interfacing the Temperature and Humidity Sensor (DHT11) with ESP32
4.3 Interfacing the Temperature and Humidity Sensor (DHT11) with ESP32 and I2C LCD
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16 chars and 2 line
display
void setup() {
Serial.begin(9600);
dht.begin();
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
}
void loop() {
delay(2000); // Wait 2 seconds between measurements
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
lcd.clear(); // Clear the LCD display
lcd.setCursor(0, 0); // Set cursor to the first row
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print("C");
lcd.setCursor(0, 1); // Set cursor to the second row
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("%, Temperature: ");
Serial.print(temperature);
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
Serial.println("°C");
}
Observation
Figure 4.2.1: Simulation based interfacing the Temperature and Humidity Sensor (DHT11) with ESP32
Figure 4.2.2: Hardware Implementation based interfacing the Temperature and Humidity Sensor
(DHT11) with ESP32
Figure 4.3.1: Simulation based interfacing the Temperature and Humidity Sensor (DHT11) with ESP32
and I2C LCD
Objective 5
Exploring OLED Display Modules: Wiring, Library Installation, 'Hello World!' Example,
Advanced Functionality, and Graphic Capabilities with ESP32.
✓ Identify the necessary pins on the ESP32 for connecting an OLED display module.
✓ Explain the wiring connections between the OLED display module and the ESP32
microcontroller.
✓ Discuss any additional components or resistors required for proper operation.
✓ Provide guidance on avoiding common wiring mistakes and ensuring reliable
connections.
✓ Identify the appropriate library for controlling the OLED display module with an
ESP32.
✓ Demonstrate the process of installing the OLED library in the Arduino IDE.
✓ Explain the purpose of the library and the functions it provides for controlling
the display.
5.3 Displaying Text on an OLED Display Module: "Hello World!" and “ESPUA
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
OLED” Example with different font size.
✓ Write an Arduino sketch to display the message “!Hello World!" and “ESPUA
OLED” on the OLED display with different font size in center position of OLED
screen also.
✓ Explain the code structure and key functions used to control the OLED display
module.
✓ Upload the sketch to the ESP32 microcontroller and verify the successful display
of the message on the OLED.
5.4 Exploring Advanced Functionality of OLED Displays: Numeric Bases, ASCII
Symbols, Text Scrolling, and Partial Display Scrolling with ESP32.
✓ Explain the methods and techniques for scrolling text horizontally on the
OLED display, allowing longer messages to fit within the limited screen
width.
✓ Demonstrate the implementation of horizontal text scrolling in an
Arduino sketch, showcasing the smooth transition and readability of the
scrolling text.
✓ Discuss the considerations and limitations when scrolling text vertically
on the OLED display, including potential memory constraints and visual
effects.
5.4.4 Partial Display Scrolling:
✓ Explain the method for drawing circles on the OLED display, utilizing a
center point and radius.
✓ Demonstrate how to draw both outlined circles and filled circles on the
OLED display.
✓ Discuss the usage of circles in various applications, such as visual
indicators and circular representations.
5.5.4 Drawing Triangles and filled triangles:
✓ Discuss the process of drawing triangles on the OLED display using three
specified points or coordinates.
✓ Demonstrate how to draw both outlined triangles and filled triangles on
the OLED display.
✓ Highlight the application of triangles in geometric representations and
graphical elements.
Figure 5: Schematic of exploring OLED Display Modules: Wiring, Library Installation, 'Hello World!'
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
Example, Advanced Functionality, and Graphic Capabilities with ESP32.
Code
5.3 Displaying Text on an OLED Display Module: "Hello World!" and “ESPUA OLED”
Example with different font size.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Define the OLED reset pin
#define OLED_RESET -1
Adafruit_SSD1306 display(OLED_RESET);
// Define screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
void setup() {
// Initialize serial communication
Serial.begin(115200);
// Initialize the display
if (!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
// Clear the display buffer
display.clearDisplay();
// Set text size, color, and cursor position for "Hello World!"
display.setTextSize(2); // Set text size to 2
Observation
Figure 5.3.1: Simulation based displaying Text on an OLED Display Module: "Hello World!" and
“ESPUA OLED” Example with different font size.
Figure 5.3.2: Hardware Implementation based displaying Text on an OLED Display Module: "Hello
World!" and “ESPUA OLED” Example with different font size.
Figure 5.4.1.2: Hardware Implementation based displaying Numbers with Different Bases (Hex, Dec)
Figure 5.4.3.1: Simulation based displaying Horizontal and Vertical Text Scrolling
Figure 5.4.3.2: Hardware Implementation based displaying Horizontal and Vertical Text Scrolling
Figure 5.5.2.1: Simulation based drawing Round Rectangles and filled round rectangles
Figure 5.5.3.2: Hardware Implementation based drawing Circles and filled Circles
Figure 5.5.4.2: Hardware Implementation based drawing Triangles and filled triangles
Objective 6
Mastering 7-Segment Displays with ESP32: Wiring, Library Integration, Sequential Counting
from 0 to 9 and Electronic Dice Roller Project.
✓ Explain the basic structure and functionality of a 7-Segment display, including its
arrangement of individual segments and common pin configurations.
✓ Differentiate between Common Cathode (CC) and Common Anode (CA) types
of 7-Segment displays, highlighting their electrical characteristics and wiring
requirements.
✓ Describe how a 7-Segment display works, including the concept of segment
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
activation and decoding to display different numbers and characters.
✓ Discuss the importance of current-limiting resistors in controlling the brightness
and preventing excessive current flow through the display.
6.2 Interfacing a 7-Segment Display Module to an ESP32 and Writing an Arduino
Sketch to Count from 0 to 9.
6.3 Building an Electronic Dice Roller with 7-Segment Display and ESP32:
Automating Dice Rolls for Fun Games.
✓ Explain the concept and purpose of the electronic dice roller project, which
automates the dice rolling process for fun dice games.
✓ Discuss the advantages and convenience of using an electronic dice roller
compared to traditional dice.
6.3.2 Triggering the Dice Roll with the Tactile Switch:
✓ Connect the 7-Segment display to the appropriate ESP32 pins based on the
defined segment pins in the code.
✓ Establish the wiring connections for the tactile switch (push button) and
assign it to the specified pin in the code.
✓ Read the state of the tactile switch using the digitalRead() function within
the loop().
✓ If the button state is HIGH (pressed), generate a random number between
1 and 6 using the random() function.
✓ Set the generated number as the new value to be displayed on the 7-
Segment display using sevseg.setNumber().
✓ Refresh the display to show the rolled dice number using
sevseg.refreshDisplay().
Figure 6.2: Schematic of interfacing a 7-Segment Display Module to an ESP32 and Writing an Arduino
Sketch to Count from 0 to 9.
Figure 6.3: Schematic of building an Electronic Dice Roller with 7-Segment Display and ESP32:
Automating Dice Rolls for Fun Games.
Code
6.2 Interfacing a 7-Segment Display Module to an ESP32 and Writing an Arduino Sketch to
Count from 0 to 9.
#include "SevSeg.h"
const int segmentPins[] = {13, 12, 14, 27, 26, 25, 33}; // Segment pins A to G
const int commonPin = 32; // Common pin
EMBEDDED SYSTEM ARDUINO PROJECT (MEL 4109)
Integrating Display Systems with ESP32 Microcontroller for Embedded System Projects: Understanding Compatibility and
Integration with LCD, OLED, and Seven-Segment Displays
SevSeg sevseg; // Create SevSeg object
void setup() {
sevseg.begin(COMMON_CATHODE, 1, segmentPins, commonPin); // Initialize display type
and pins
sevseg.setBrightness(90); // Set display brightness
}
void loop() {
for (int i = 0; i <= 9; i++) {
sevseg.setNumber(i); // Display number i
sevseg.refreshDisplay(); // Refresh the display
delay(1000); // Wait for 1 second
}
}
6.3 Building an Electronic Dice Roller with 7-Segment Display and ESP32: Automating Dice
Rolls for Fun Games.
Figure 6.2.1: Simulation based interfacing a 7-Segment Display Module to an ESP32 and Writing an
Arduino Sketch to Count from 0 to 9.
Figure 6.2.2: Hardware Implementation based interfacing a 7-Segment Display Module to an ESP32
and Writing an Arduino Sketch to Count from 0 to 9.
Figure 6.3.2.2: Hardware Implementation based triggering the Dice Roll with the Tactile Switch
Precautions:
2) What is the I2C address of the LCD display used in the experiment?
3) How many wires are required to connect an I2C LCD display to the ESP32?
5) If the contrast of the I2C LCD display is too low, what component should be adjusted?
6) How many custom characters can be created on a standard 16x2 I2C LCD display?
7) How many bytes of RAM does each custom character occupy on an I2C LCD display?
8) If an I2C LCD display has an address of 0x3F, what is the decimal equivalent of this address?
9) What is the voltage level required for the VCC pin of the I2C LCD display?
10) If the I2C LCD display has an operating current of 2mA and is powered by a 5V source, what is
the power consumption of the display?
11) The I2C bus supports a maximum data rate of 400kHz. If the bus clock frequency is 1MHz, what
is the duty cycle of the clock signal?
12) How many wires are required to connect multiple I2C devices to the same I2C bus?
13) If an I2C LCD display operates at an I2C bus speed of 100kHz and has an I2C address of 0x27,
what is the time required to transmit a single byte of data?
14) The I2C protocol supports a maximum of 8 bits for addressing. How many different devices can
be connected to a single I2C bus using the 8-bit addressing scheme?
15) The I2C bus allows for multi-master communication. If two devices simultaneously try to transmit
data on the bus, causing a collision, what mechanism is used to resolve the collision?
16) What is the measurement range of the DHT11 sensor for temperature and humidity?
17) What is the accuracy of the DHT11 sensor for temperature and humidity measurements?
18) The DHT11 sensor provides a temperature reading of 25.6 degrees Celsius. Convert this
temperature to Fahrenheit.
19) The DHT11 sensor reports a humidity level of 62%. Express this humidity as a decimal.
20) The DHT11 sensor has an accuracy of ±2°C for temperature measurements. If the actual
temperature is 28°C, what is the maximum and minimum possible temperature reading by the
sensor?
22) The DHT11 sensor has a power supply voltage of 3.3V. If the sensor draws a current of 2.5mA,
what is the power consumption?
23) The DHT11 sensor takes 2 seconds to provide a stable reading after power-up. If the sensor is
powered on at 10:00 AM, at what time will the reading be stable?
24) The I2C LCD display operates at an I2C bus speed of 400kHz. Calculate the time required to
transmit 1 byte of data.
25) The DHT11 sensor has a response time of 1 second. If the sensor is queried every 5 seconds, what
percentage of the time is the sensor actively providing readings?
26) The DHT11 sensor reports a temperature of 20.5°C and a humidity of 42.8%. Convert the
temperature to Fahrenheit and round it to the nearest whole number.
27) The DHT11 sensor has an accuracy of ±5% for humidity measurements. If the actual humidity is
60%, what is the maximum and minimum possible humidity reading by the sensor?
28) The DHT11 sensor has a measurement range of 20°C to 40°C for temperature readings. If the
sensor reports a temperature of 18°C, is it within the measurement range?
29) The DHT11 sensor requires a pull-up resistor of 10kΩ for communication. If a 5V power supply
is used, what is the power dissipated by the pull-up resistor?
30) The I2C LCD display has an operating voltage of 5V and draws a current of 20mA. What is the
power consumption of the LCD display?
31) The DHT11 sensor has a sampling rate of 1Hz. If the sensor has been running for 2 minutes, how
many readings has it taken?
32) The I2C LCD display has a display size of 16x2 characters. If each character is represented by 5x8
pixels, how many pixels are there on the display?
33) Calculate the total number of pixels in an OLED display module with a resolution of 128x64.
34) Interfacing an OLED Display Module to an ESP32: a) If the VCC pin of the OLED display module
requires a voltage of 3.3V and the ESP32 provides 5V, calculate the value of the resistor required
for voltage level conversion using Ohm's Law (V = IR).
35) Displaying Text on an OLED Display Module: a) If the OLED display module has a screen size of
128x32 pixels and the desired text is "Hello, World!", calculate the maximum number of characters
that can fit on a single line, assuming each character occupies 8 pixels.
36) Suppose you want to display a hexadecimal value "0xDEAD" on the OLED display. Convert this
value to decimal and display it.
37) Exploring Graphic Capabilities of OLED Displays: a) Calculate the circumference of a circle with
a radius of 10 pixels.
39) Interfacing an OLED Display Module to an ESP32: a) The OLED display module requires a current
of 20mA for proper operation. If the supply voltage is 3.3V, calculate the value of the current-
limiting resistor using Ohm's Law (R = V/I).
40) Displaying Text on an OLED Display Module: a) If the OLED display module supports a font size
of 8x16 pixels per character and you want to display the message "Hello" on the screen, calculate
the width and height required to display the entire message.
41) Suppose you want to display the ASCII code of the character 'A' on the OLED display. Calculate
the decimal ASCII value of 'A' and display it.
42) Calculate the area of a rectangle with dimensions 20 pixels (width) and 10 pixels (height).
43) The ESP32 is connected to a Common Cathode (CC) 7-Segment display. The forward voltage drop
across each segment is 2.1V, and the desired segment current is 10mA. The power supply voltage
is 5V. Calculate the value of the current-limiting resistor required for each segment.
44) The 7-Segment display is connected to an ESP32 using multiplexing. The display is multiplexed
at a frequency of 500Hz. Calculate the time duration for each segment to be ON in one complete
cycle.
45) The 7-Segment display is multiplexed with a refresh rate of 1kHz. Each digit consists of 7
segments. Calculate the time it takes to refresh all the digits on the display.
46) Write an Arduino sketch to display a floating-point number, such as 3.14, on a 7-Segment display
using the SevSeg library. Ensure that the decimal point is properly displayed.
47) The 7-Segment display is multiplexed with a frequency of 1kHz. Each digit consists of 7 segments.
Calculate the duty cycle of each segment.
48) A Common Anode (CA) 7-Segment display is used, and the supply voltage is 3.3V. Determine the
voltage levels required to turn ON a segment and turn OFF a segment.
49) A Common Cathode (CC) 7-Segment display is used, and the supply voltage is 5V. The forward
voltage drop across each segment is 1.8V, and the current flowing through each segment is 15mA.
Calculate the value of the current-limiting resistor required for each segment.