DIY Wifi Audio Notifier for ESP8266: Play MP3, TTS & RTTL (Cloud-free)

39K5892

Intro: DIY Wifi Audio Notifier for ESP8266: Play MP3, TTS & RTTL (Cloud-free)

In this project, I will show you how you can use NOTHING but an ESP8266 board like the Wemos D1 Mini and a simple audio jack to play MP3, TTS and RTTL .... CLOUD-FREE!

New to ESP8266? Watch my Introduction to ESP8266 video.

This is controlled over MQTT. You will be able to send it an MQTT message with the URL of the MP3 file and it will play it for it. It is also capable to doing basic TTS and playback RTTL (aka Nokia) ringtone.

STEP 1: Watch the Video


The video has step-by-step instructions that will guide you through the process. Feel free to add your questions in the comment section of the YouTube video if you need any futher assistance.

STEP 2: Order the Components

-- LINKS -- (When available, I use affiliate links and may earn a commission)

Amazon.com:
- ESP8266 module - https://amzn.to/3fx28Lq
- Amplifier shown in video - https://amzn.to/32drav2
- Audio jack with bare wires - https://amzn.to/2Zokkkr

AliExpress:

- Wemos d1 mini - https://s.click.aliexpress.com/e/_dXcNTYU
- Audio Jack with Bare Wire - https://s.click.aliexpress.com/e/_dVT9yWy
- Amplifier shown in video - https://s.click.aliexpress.com/e/_Bff4EpdO

Amazon (Canada):
- Wemos d1 mini - https://amzn.to/3fx28Lq
- A good audio amplifier - https://amzn.to/32drav2
- Audio jack with bare wires - https://amzn.to/2Zokkkr

STEP 3: Hardware

The hardware is very simple. You will need a Wemos d1 mini and an audio jack. Connect the left and right channel wires to RX pin on Wemos D1 Mini and the audio ground wire to the D1 mini GND pin.

STEP 4: Software

To load the software, download MrDIY_Notifier.bin

Step 1: Connect the Wemos d1 mini to your computer, open Tasmotizer, load the file you just downloaded, and flash it.

Step 2: When it is finished loading and restarting, connect to the wifi network called "MrDIY Notifier". The password is "mrdiy.ca".

Step 3: You should get a popup. If you don't, go to 192.168.4.1 and fill-in your wifi network name, password, MQTT server IP, and credentials. Click SAVE and connect back to your home wifi.

By using this bin file that I created, you can simply load the file directly to a Wemos D1 Mini. This eliminates the long process of having to download the code, update the wifi & MQTT credentials, download & install the libraries, configure esp8266 for Arduino, change the Arduino settings and then finally upload the code. However, if you wish to access the full source code, it is available on my MrDIY Gitlab page.

** UPDATE **
I added support to custom MQTT topic in the source code, so check my gitlab page. If you are a Pateron, check my page, I posted the updated bin file there as a thank you for your support!

STEP 5: Commands

Here is the full list of commands you can use. You can also subscribe to the /mrdiynotifier/status topic to get status updates.

     - Play MP3              MQTT topic: "/mrdiynotifier/play"
                             MQTT load: http://url-to-the-mp3-file/file.mp3

     - Play Icecast Stream   MQTT topic: "/mrdiynotifier/stream"
                             MQTT load: http://url-to-the-icecast-stream/file.mp3

     - Play Ringtone         MQTT topic: "/mrdiynotifier/tone"
                             MQTT load: RTTTL formated text, example: Soap:d=8,o=5,b=125:g,a,c6,p,a,4c6,4p,a,g,e,c,4p,4g,a

     - Say Text              MQTT topic: "/mrdiynotifier/say"
                             MQTT load: Text to be read, example: Hello There. How. Are. You?

     - Change Volume         MQTT topic: "/mrdiynotifier/volume"
                             MQTT load: a double between 0.00 and 1.00, example: 0.7

     - Stop Playing         MQTT topic: "/mrdiynotifier/stop"                           

     To get status:

     - The notifier sends status update on this MQTT topic: "/mrdiynotifier/status"

                  "playing"       either paying an mp3, streaming, playing a ringtone or saying a text
                  "idle"          waiting for a command
                  "error"         error when receiving a command: example: MP3 file URL can't be loaded
                  "connected"     device just connected to MQTT server

     - The notifier plays a 2 second audio clip when it is first booted and connected to Wifi & MQTT


STEP 6: Home Assistant & NodeRED

At this stage, you should have everything setup, loaded, and ready to accept MQTT messages. You can now use your the home automation program of your choice, such as Home Assistant or NodeRED, to send the audio notifier MQTT messages. Check the screenshots above for examples that show you how to do a simple daily alarm at 7AM for both Home Assisant and NodeRED.

STEP 7: Done

You are done! You can now use this notifier to play MP3, TTS & RTTL tones cloud-free and control it locally over MQTT.

If you found this useful, please consider subscribing to my YouTube channel - It helps me a lot.
If you are interested in supporting my work, you can check my Patreon page.

Much of the information contained is based on personal knowledge and experience. It is the responsibility of the viewer to independently verify all information.

47 Comments

Hi.

I built your project.

When i'm trying to play mp3 file, i have loud white noise.

The Wemos D1 is connected to Herdio power amplifier which connected to passive speaker.

Actions i tried to do so far:

  1. Changing mp3 file to different song.
  2. Changing the aux cable.
  3. Changing the Wemos D1 power supply
  4. Tried to use ESP32 with internal DAC (with schmurtz edition) - the song have white noise and also hangs a bit.
  5. Tried to use ESP32 without DAC (with schmurtz edition) - got the same white noise

I'm trying to play the song from HomeAssistant local folder as you did.


any advice?

I built the project like you. The say command works perfectly but the play command doesn't. It doesn't matter whether I try http or https. When I enter the URL in the browser it works immediately

My bad, I had to use http url, no https
Hi!
Thanks for your work! That's amazing
I have same ikea speaker and I'm trying to use another esp8266 to power it on and turn volume up and I'm having some problems. I can power it on but I don't know how to turn volume up (to a value I want). I don't know if you can help me.
Thanks!
Hi!
This is a really awesome project!
Is it possible to use a public broker instead of creating a server yourself?
I can't seem to get a connection via the public broker iam using...
Can Someone Guide me To Make a MQTT Server ;( I'm a beginner in that please help me friends
Im confused! Why do you list the amplifier but I don’t see it used in any step?
I need help for the "Step 1: Connect the Wemos d1 mini to your computer, open Tasmotizer, load the file you just downloaded, and flash it.
a. I have a wemos mini d1, i have added it to ESPhome in my HomeAsistant
b. I have a WiFi address for it
c. I have downloaded the MrDIY_Notifier.bin and software Tasmotizer to my Windows10 computer.
d. I connect the wemos mini d1 via USB cable to my computer
e. I start Tasmotizer.
f. I see as port COM5, which is the standard com port for "serial connection via bluetooth"?
g. I fill in the Bin file
h. I press button "Tasmotize!
i. I get an the Error "Write Time Out" or "Permiission error, Access denied"
What do I do wrong and what is the solution? Please advise?
Have you tried a different Wemos D1 mini?
Yes, I tried another wemos d1 mini, but the same result. Other suggestions?
A feature request: If a loop playback is implemented, that is perfect for background sound.

A question: Seems multiple access to the same mp3 on my internet web server causes a lot of breaks of the music on every client. I placed the mp3 in my web server html directory. I connected 1 esp8266 playing the music while I opened a brower to play the same file, break occured. I wonder if there is a way to solve this.
Hello MrDiy, I was really excited with your project till I decided to carry it out ... I expended hours without getting it work. I don't know what I'm doing wrong, it seems it communicates with my mosquito broker as the functions tone and say are working but mp3 doesn't. Should I add the port 1883 after the ip broker address? I'm using your already compiled bin file on a NodeMcu card. The personalized topic requested on the bottom of the very first setting form, should be plain text or with slash "/" before and after?. The files I'm trying to play are located \config\www\ I guess it's ok because the boot_sound.wav is also located there and it plays at boot (very distorted by the way)
Hello,things you might want to try: (1) the MP3 files need to be accessible over HTTP ( not HTTPS). Visit the URL of the MP3 from your browser and see if it starts playing. (2) try MP3 files with lower bitrates, maybe try a 128kbps and see if that works.
BTW, the boot sound is built-in and is not loaded from a server.
please guide me
error: 'class iotwebconf::IotWebConf' has no member named 'addParameter'
iotWebConf.addParameter(&mqttTopicParam);

'IotWebConfParameter' does not name a type
You need to use IotWebConf version 2 not 3.
Hi, thanks for this great project ! I've made some little modifications on it :
- ported to platformio
- can be compiled for ESP8266 and ESP32
- Google Translate TTS added (so a little less "cloudless" but multilingual and better voice than the included ESP8266SAM)
- This code also allows to switch easily between no DAC (version used by mr DIY) , external DAC or internal DAC (for ESP32).
- You'll also find some useful comments for wiring your DAC quickly or to improve the code.

https://github.com/schmurtzm/MrDiy-Audio-Notifier

I still have some bugs related to the compatibility of the ESP32 with of the ESP8266Audio library (these bugs are described in the github's readme, help is welcome ;) )
I was really having hard time in getting "/play" command working for local files. The example shared by MrDIY is of Node Red instance in Home Assistant and I am using NodeRed on RaspberryPi OS. Coundn't figure out the error I was getting.
After some searching and a headache found this solution that worked for me. https://github.com/Hypnos3/node-red-contrib-cast/i...
The idea is to serve an mp3 file directly from Node-Red using an HTTP node. So you need to add a flow of three nodes anywhere in NodeRed and your local mp3 file path will be 'converted' to a HTTP request, which works very well in this project. Attached are screenshots of my nodes config.
Thanks for sharing your tip!
More Comments