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

25,755

51

42

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

About: I am a techie DIYer who loves tinkering with electronics. Twitter @MrDIYca. For more info and my full contacts, please visit www.MrDIY.ca

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.

Audio Challenge 2020

Participated in the
Audio Challenge 2020

4 People Made This Project!

Recommendations

  • CNC and 3D Printing Contest

    CNC and 3D Printing Contest
  • Rice & Grains Challenge

    Rice & Grains Challenge
  • Lamps Challenge

    Lamps Challenge

42 Comments

0
SQA
SQA

Question 3 months ago

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

0
kevinedward3746
kevinedward3746

6 months ago

Can Someone Guide me To Make a MQTT Server ;( I'm a beginner in that please help me friends

0
justnickname
justnickname

Reply 5 months ago

did you figured it out?

0
yothatsm3
yothatsm3

7 months ago

Im confused! Why do you list the amplifier but I don’t see it used in any step?

0
florisdg
florisdg

Question 8 months ago on Step 3

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?
tasmotize error.JPG
0
MrDIYLab
MrDIYLab

Answer 7 months ago

Have you tried a different Wemos D1 mini?

0
florisdg
florisdg

Reply 7 months ago

Yes, I tried another wemos d1 mini, but the same result. Other suggestions?

0
tony_wk
tony_wk

9 months ago on Introduction

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.

0
sunset_ita
sunset_ita

10 months ago

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)

0
MrDIYLab
MrDIYLab

Reply 10 months ago

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.

0
Jack-123
Jack-123

11 months ago

please guide me
error: 'class iotwebconf::IotWebConf' has no member named 'addParameter'
iotWebConf.addParameter(&mqttTopicParam);

'IotWebConfParameter' does not name a type

Screenshot_1.jpg
0
MrDIYLab
MrDIYLab

Reply 10 months ago

You need to use IotWebConf version 2 not 3.

1
Schmurtz
Schmurtz

Tip 11 months ago

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

1
harishjachak
harishjachak

Tip 11 months ago

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.

inject node.jpgMQTT Out.jpghttp in.jpgfile in.jpghttp response.jpg
0
MrDIYLab
MrDIYLab

Reply 11 months ago

Thanks for sharing your tip!

0
harishjachak
harishjachak

1 year ago

Hello MrDIY. This is an awesome project. I replicated for myself and it's working great till now. I'm facing one issue though. Currently, (May be just for me) the speech/voice generated from the text payload feels rushed and very difficult to understand. Is there a way to slow down the speed of speech for "/Say" message?

0
MrDIYLab
MrDIYLab

Reply 12 months ago

Thank you!
I think you can add a . between words to slow it down - try "My.name.is"

0
harishjachak
harishjachak

Reply 11 months ago

Thanks. I had tried breaking the sentence in several payloads (with one word each) and adding a delay between each message. It works but adds noise as it starts and ends each word. This method (adding a . between words) works much better. Thanks again.

flow sliced.png
0
t0mer
t0mer

1 year ago

HI,
wonderful project.
if I want to use esp8266 instead of D1 mini, to wich pin do I need to connect the Left&Right channels?
I also would like to see the source code for the bin if possible.
Thanks.

0
csmukku
csmukku

1 year ago

Hi!,
I use home assistant for esp8266 switches with tasmota. currently, i am trying to install room-assistant for presence detection. For this, with your speaker project, I would like to have two mqtt topics.
one would be for each room to announce presence while the other would be used for a "global" announcement from home assistant. currently, i use echo dots for announcements. It would be to good to make everything local.
I am not really a software guy, so any help would be appreciated.
thank you, your project is great.