0% found this document useful (0 votes)
17 views14 pages

Report - Team2 - Tiếng Anh

Uploaded by

hoai170706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views14 pages

Report - Team2 - Tiếng Anh

Uploaded by

hoai170706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF INFORMATION & COMMUNICATION TECHNOLOGY


──────── * ───────

Embedded Systems

Designing MP3 model controlled by IR remote using DFPlayer mini

Instructor: Ngo Lam Trung


Students: Tran Thi Lan Anh - 20215180
Hoang Thi Hang - 20194757
Ngo Minh Quy - 20215238

Ha Noi - July 2024


TABLE OF CONTENTS
1. Goal.................................................................................................................
2. Implementation contents.................................................................................
2.1. ESP32 Research, DFPlayer Mini, PAM8403, IR remote, Oled..............
a. NodeMCU ESP32 DEVKIT..................................................................1
b. PAM8403................................................................................................3
c. DFPlayer Mini........................................................................................4
d. IR remote................................................................................................4
e. OLED......................................................................................................5
2.2. Complete pairing of embedded systems...................................................
a. Pairing ESP32 with DFPlayer mini PAM8043 and Speaker.....................
b. Pairing ESP 32 with Oled:............................................................................
c. Pairing the ESP32 with the IR remote........................................................
3. Product design and construction..................................................................
4. Division of work..............................................................................................12
1. Goal
- Embedded Product Design: Remote-controlled MP3 model with DFPlayer mini
- The product has a module that can simulate an mp3 player with basic functions such
as: play, stop, next, previous, volume up and down
2. Implementation contents
2.1. ESP32 Research, DFPlayer Mini, PAM8403, IR remote, Oled
a. NodeMCU ESP32 DEVKIT
The ESP32 is a powerful and multifunctional microcontroller developed by Espressif
Systems. It is an upgraded version of ESP8266 and offers more features and scalability to
cater to Internet of Things (IoT) projects, wireless applications, and embedded.

Figure 1: NodeMCU ESP32 DEVKIT V1 DOIT Overview

Figure 2: ESP32 DEVKIT V1 DOIT board Specifications

Some of the outstanding features and features of ESP32:


- Dual-core processor: The ESP32 is equipped with two Tensilica Xtensa LX6
processor cores, enabling efficient multi-threading and multitasking.

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.

Figure 3: NodeMCU ESP32 DEVKIT V1 MUST Pinout


Some pins in particular need to take care of to pair with microSD and ST7789:

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.

Explanation of the legs:


o VCC: Power Supply Pin (2.5V – 5.5V)
o GND: Ground Pin
o L_IN: Left channel audio input
o R_IN: Right channel audio input
o L_OUT: Left channel audio output
o R_OUT: Right channel audio output

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,...

Details of the legs:


- RX: UART serial input
- TX: UART serial output
- DAC_R: Audio output right channel
- DAC_L: Audio output left channel
- SPK2: Speaker –
- SPK1: Speaker +
- IO1: Trigger port 1 (press to play music first, press and hold to decrease the volume)
- IO2: Trigger port 2 (press to play the next song, press and hold to increase the
volume)
- ADKEY1: AD Port 1 (Trigger play first segment)
- ADKEY2: AD Port 2 (Trigger play fifth segment)
- USB+: USB+ DP
- USB-: USB- DP
- BUSY: Playing status (Low: playing, High: no)
d. IR remote
IR Remote is a remote control device that uses infrared (IR) waves to transmit control signals
to electronic devices such as TVs, DVDs, projectors, air conditioners, lights, etc. The IR
Remote usually has buttons to control the various functions of the device, and the signal sent
from the IR Remote will be decoded and perform the corresponding task on the electronic
device.

 Each button corresponds to 1 specific function or


command
 When 1 button is pressed, the control will emit an
infrared signal carrying a unique code associated
with the button being pressed

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.

Details of the legs:


o VCC: Power Supply Pin (3.3V – 5V)
o GND: Ground Pin
o SCL: I2C Clock Pin
o SDA: I2C Data Legs

7
2.2. Complete pairing of embedded systems

a. Pairing ESP32 with DFPlayer mini PAM8043 and Speaker


Proceed to pair the ESP32 with DFPlayer mini as follows:
ESP32 DFPlayer mini
GND GND
VIN VCC
D26 RX
D27 TX
D5 BUSY

DFPlayer mini PAM8403


B DAC_R
G DAC_L

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.

o The "DFRobotDFPlayerMini.h" library is used to communicate with the


DFPlayer Mini module. This library provides functions for initializing modules,
playing music, pausing music, and adjusting the volume. DFPlayer Mini is a module
that plays MP3 audio from a microSD card with a simple output that is connected
directly to the speaker.
To interact between ESP32 and IRremote, we use the following libraries:
o The "IRremote.h" library is used to control communication with infrared (IR) remote
control devices. This library allows the ESP32 to receive and decode IR signals from
the remote to perform corresponding actions. The library supports many popular IR
protocols such as NEC, Sony, RC5, RC6, and many others.
b. Pairing ESP 32 with Oled:

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.

c. Pairing the ESP32 with the IR remote


ESP32 IR remote
D34 VOUT
The "IRremote.h" library is used to control communication with infrared (IR) remote control
devices. This library allows the ESP32 to receive and decode IR signals from the remote to
perform corresponding actions. The library supports many popular IR protocols such as NEC,
Sony, RC5, RC6, and many others.
3. Product design and construction
This project will create an MP3 player using the ESP32 and the DFPlayer Mini module. The
ESP32 will control the DFPlayer Mini to play MP3 music files from the memory card and
can receive control commands from the push button or IR Remote.
Product Construction:

 Setting for IRremote


// IR remote initialize ...
IrReceiver.begin(IR_RECEIVE_PIN);
if (IrReceiver.decode())
{
uint64_t command = IrReceiver.decodedIRData.decodedRawData;
Serial.print("0x");
Serial.println(command, HEX);

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();
}

 Setting for OLED and button:


// OLED peripherals
pinMode(IR_BUSY, INPUT);
pinMode(NEXT_SONG_PIN, INPUT);
pinMode(PREV_SONG_PIN, INPUT);
pinMode(PAGE_CONVERT_PIN, INPUT);
pinMode(PAUSE_PIN, INPUT);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
{
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
display.clearDisplay();

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy