Report - Team2 - Tiếng Anh
Report - Team2 - Tiếng Anh
Embedded Systems
3
- Diverse wireless communication: The ESP32 supports a variety of wireless
communications such as Wi-Fi, Bluetooth Classic, and Bluetooth Low Energy (BLE),
allowing for flexible networking application design.
- Low Power Consumption: The ESP32 is designed to be energy efficient, capable of
operating in low consumption mode, and good power management.
- Large Memory: The ESP32 has a larger Flash memory than the ESP8266, allowing
for larger storage of program code and data.
- SPI, I2C, UART Protocols: The ESP32 supports popular communication protocols
such as SPI, I2C, and UART, making it easy to connect and control peripherals.
- Diverse GPIOs: The ESP32 offers multiple GPIO pins that allow connection to
peripheral devices such as sensors, LEDs, monitors, etc.
- Supports OTA (Over-the-Air) Updates: The ESP32 allows for software updates over a
Wi-Fi network, making it easy to deploy updates or fix bugs remotely.
- Built-in peripherals: ESP32 integrates many features such as temperature sensor,
temperature and humidity sensor, optical stand, etc.
- Supports multiple programming languages: The ESP32 supports multiple
programming languages such as C++, MicroPython, Arduino IDE, and many others.
- Reasonable price: The ESP32 is affordable, making it a good choice for DIY and
commercial projects.
4
- GPIO5 (D5): typically used to connect to the CS (Chip Select) pin of a microSD card.
CS is used to select or deselect microSD cards when communicating over the SPI
protocol.
- GPIO18 (D18): typically used to connect to the SCK (Serial Clock) pin of both the
microSD card and the ST7789 monitor. SCK is the clock signal for the SPI protocol,
which synchronizes the data transmitted over the SPI communication.
- GPIO19 (D19): typically used to connect to the MISO (Master In Slave Out) pin of
the mocroSD card. MISO is a signal used to transmit data from a peripheral device
(slave) to a microcontroller (master) in the SPI protocol.
- GPIO23 (D23): typically used to connect to the MOSI (Master Out Slave In) pin of
both the microSD card and the ST7789 monitor. MOSI is a signal used to transmit
data from the master to the peripheral device (slave) in the SPI protocol.
- GPIO2 (D2): typically used to connect to the DC (Data/Command) pin of the ST7789
monitor. The DC pin is used to determine whether the transmitted data is image data
or command.
- GPIO4 (D4): typically used to connect to the RST (Reset) pin of the ST7789 monitor.
RST is a reset signal used to restart the screen.
b. PAM8403
PAM8403 is a digital audio amplifier module with 3W output power per channel (left channel
and right channel). It is a popular choice for audio DIY projects due to its compact size, high
performance, and low power consumption. This module is commonly used with audio
sources such as DFPlayer Mini, mobile phones, tablets, or computers.
5
c. DFPlayer Mini
DFPlayer is a circuit that plays mp3 audio from a microSD card with a simple output
connected directly to the speaker. DFPlayer mini can be used directly with batteries, speakers,
buttons, or in combination with Arduino, ESP32,...
6
An IR receiver is a sensor that detects and receives infrared signals emitted from an IR
remote. It has 3 legs
VCC: connect to ESP32
GND: connect to ESP32
OUT: output, connected to the input pin on the ESP32
e. OLED
The 0.96-inch Oled screen communicates I2C for beautiful, clear daytime visibility and
maximum power saving at a reasonable cost, the screen uses I2C communication for stable
transmission quality and is very easy to communicate with only 2 GPIO pins.
7
2.2. Complete pairing of embedded systems
PAM8403 Loa
RO- SPK
RO+ SKP
8
To interact between ESP32 and DFPlayer, we use the following libraries:
o The "SoftwareSerial.h" library is used to create additional serial ports (UARTs) on the
ESP32. This library allows you to communicate with multiple devices using the
UART protocol without having to use the ESP32's default UART ports. This is useful
when you need to connect multiple serial devices at the same time.
To connect the OLED display to the ESP32 via the I2C protocol, we need to connect as
follows:
ESP32 OLED
GND GND
3V3 VDC
D22 SCL
To interact between the ESP32 and the OLED display, we use 2 libraries:
#include<Wire.h>
The "Wire.h" library is used to control communication over the I2C (Inter-Integrated Circuit)
protocol between the ESP32 and other peripherals such as sensors, OLED displays, and many
other modules. The I2C protocol consists of basic signals such as SDA (Serial Data) and SCL
(Serial Clock), which are used to transmit data between devices.
#include<Adafruit_SSD1306.h>
The "Adafruit_SSD1306.h" library is used to work with 128x64 pixel OLED screens using
SSD1306 drivers. This library provides functions for initializing screens, writing text,
drawing images, and graphics on OLED screens. OLED displays are often used to display
text or graphic information in applications such as watches, embedded systems, and IoT
devices.
#include <Adafruit_GFX.h>
9
The "Adafruit_GFX.h" library is a general graphic library used to draw basic shapes such as
lines, circles, rectangles, and display text on the screen. This library supports a variety of
screen types and provides a simple API for drawing graphics.
10
delay(100);
switch (command)
{
case 0xBB44FF00: // PREV SONG
if (isPause == 0)
player.previous();
break;
case 0xBF40FF00: // NEXT SONG
if (isPause == 0)
player.next();
break;
case 0xBC43FF00: // pause/play
isPause = !isPause;
if (isPause == 1)
{
player.pause();
}
else if (isPause == 0)
player.start();
break;
case 0xF807FF00: // volume -
player.volumeDown();
break;
case 0xEA15FF00: // volumn +
player.volumeUp();
break;
case 0xE916FF00:
page = !page;
break;
default:
break;
}
IrReceiver.resume();
}
11
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
// drawSetting();
display.display();
// End OLED setup
// Start communication with DFPlayer Mini
delay(3000); // DFPlayer take about 2s to init the system
Serial.println("System is running...");
player.volume(25); // Set volume of speaker
player.enableDAC();
player.randomAll(); // Play randomly all songs
}
void loop()
{
Serial.begin(9600);
if (digitalRead(IR_BUSY) == 1 && isPause == 0)
{
Serial.println(" play ");
player.randomAll(); // Play randomly all songs
}
if (digitalRead(PAGE_CONVERT_PIN) == 0)
page = !page;
if (digitalRead(PAUSE_PIN) == 0)
{
isPause = !isPause;
if (isPause == 1)
{
player.pause();
}
else if (isPause == 0)
player.start();
}
if (digitalRead(PREV_SONG_PIN) == 0 && isPause == 0)
{
delay(100);
player.previous();
}
if (digitalRead(NEXT_SONG_PIN) == 0 && isPause == 0)
{
delay(100);
player.next();
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
if (page == 1)
{
display.clearDisplay();
12
drawSetting();
// display.display();
}
else
{
display.clearDisplay();
drawTrack();
}
Setting for DFPlayer Mini:
static const uint8_t PIN_MP3_TX = 26; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 27; // Connects to module's TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
DFRobotDFPlayerMini player;
// Start communication with DFPlayer Mini
delay(3000); // DFPlayer take about 2s to init the system
Serial.println("System is running...");
player.volume(25); // Set volume of speaker
player.enableDAC();
player.randomAll(); // Play randomly all songs
void loop()
{
Serial.begin(9600);
if (digitalRead(IR_BUSY) == 1 && isPause == 0)
{
Serial.println(" play ");
player.randomAll(); // Play randomly all songs
}
}
4. Division of work
- Lan Anh:
o Tìm hiểu ESP32, OLED, IR remote
13
o Participate in circuit pairing
o Join Code
o Write a report
- Constant:
o Tìm hiểu DFPlayer mini, IR remote
o Participate in circuit pairing
o Join Code
o Write a report
- Precious:
o Learn about ESP32, PAM8403, DFPlayer mini
o Participate in circuit pairing
o Performing module soldering
o Join Code
14