ESP8266 (NodeMCU)
Module for reading SD cards (microSD module)
A speaker (for example, a small speaker with an amplifier)
Audio amplifier (eg PAM8403)
Breadboard and wires for connection
SD card with recorded audio file in WAV format
USB cable for ESP8266 programming
A computer with the Arduino IDE installed
A Telegram account to create a bot
Open Telegram and search for “BotFather”.
Use the /newbot command to create a new bot.
Get an API token that will be used to interact with the bot.
Installing the required libraries: In the Arduino IDE, add the libraries for working with Wi-Fi (`ESP8266WiFi`), Telegram (UniversalTelegramBot), SD card (`SD`) and audio playback (TMRpcm). To do this, go to “Sketch” > “Include Library” > “Manage Libraries” and find and install the appropriate libraries.
Writing code for ESP8266: https://pastebin.com/RuB8kmns
SD card connection: Connect the SD card module to the ESP8266 (for example, using the D2 pin for the CS pin).
Speaker Connection: Connect the speaker to the audio amplifier and the amplifier to the ESP8266 (eg pin D1 for audio signal and GND for ground).
Take the SD card and load a WAV file named `sound.wav` onto it.
Connect the ESP8266 to the computer via a USB cable.
Select the appropriate board and port in the Arduino IDE.
Upload the code to the ESP8266.
Open Telegram and find your bot.
Send the /play command
The ESP8266 should play the sound from the SD card through the connected speaker.
With this project, we will be able to place our device and reproduce interesting sounds, surprising our friends. Note – this project must be repeated with an understanding of the Arduino and knowledge of the properties of electric current.
Disclaimer. This article is created for informational purposes only. All advice and instructions are provided for educational purposes and we are not responsible for any possible consequences related to the implementation of this project. Always use safety precautions when working with electronic components.