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

13,479

37

24

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

3 People Made This Project!

Recommendations

  • Robots Contest

    Robots Contest
  • Retro Tech Challenge

    Retro Tech Challenge
  • Space Contest

    Space Contest

24 Comments

0
t0mer
t0mer

5 weeks 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

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

0
power000
power000

11 months ago

Hi that is great project! I have added mp3 files in my raspberry
\\HOMEASSISTANT\media

When i try to play
http://192.168.1.103/media/poison.mp3
i get error.
I think a wifi device should know samba password of my raspberry so that can play files. I also try share folder. what can i do

0
MrDIYLab
MrDIYLab

Reply 11 months ago

The player can only play non-password protected http files - so no samba or any other non-http protocols.

Try to host the mp3 files on an http server (like apache or ngnix) and give it another try.

0
power000
power000

Reply 11 months ago

thank you, i already install apache on rpi and it works perfect!! i try now to make it play Icecast Stream but i can't. As far as i can understant , after insert link for cast ,with some way i have to click play button on the page because it does not start play. Is it right? you have done great work!

0
MrDIYLab
MrDIYLab

Reply 11 months ago

You play streams by sending the URL of the icecast to the "/your_mqtt_topic/stream" topic just like you do with the /play command.

Please note that you can only play HTTP urls and not HTTPS.

0
radic123
radic123

9 months ago

Very nice project. Is it possible to change the MQTT path /mrdiynotifier/ ? I would like to use multiple mqtt devices at my home.....
Thanks

0
radic123
radic123

Reply 9 months ago

Got it :) the custom image file contains the mqtt topic settings.

0
gazzagoobrush
gazzagoobrush

9 months ago

Works great, the only issue I have is almost a ticking sound every like half second. I've tried rewiring, removing speakers and swapping + and - on speakers. Everything shares the ground from the nodemcu and I'm powering from USB to the breadboard.

Any ideas of the noise?

20201202_113727.jpg
0
radic123
radic123

Reply 9 months ago

I had a similar issue, solved by replacing the power source. Try to use powering from a battery

0
aryeduino
aryeduino

12 months ago

As far as I can see it - this is ONE Flash project.
After I upload the BIN Files I can NOT see it as a COM Port anymore. That is a bit shame since I want to be able to test it and see if it works for me and if need to upload an update that would be great to have the COM Port back.
No place on the page you have mentioned the username and password for the web interface - that made me wondering a lot till I looked in the comments here. I think that you should put the info on the main page as well.
Regarding the COM Port I would be happy to get back to work with my D1 Mini again as a COM Port and not loosing it at all. I am sure that the BIN file just overwritten my bootloader and that is the reason I can NOT see my device anymore in COM Ports.
Please let me knwo How to make it back with tasmota or what should I do if I need to upgrade the firmware?
One of the changes I want to make is the topic. How can I do that? and How it can be done after the First time of flashing?
Thanks for the project.

0
MrDIYLab
MrDIYLab

Reply 12 months ago

Hi Arye, that is good idea. I will add the username (admin) to the README.

The COM port is managed by the OS not ESP8266. No code on the ESP8266 will prevent you from seeing the COMs. Check your cable/setup.

The full source code is on my gitlab (link is in the artice above) if you want to do any change.

0
mr.botche
mr.botche

1 year ago

great project. i have been very interested in something like this. i uploaded your bin file and it is connected to my home network. however, when i go to the ip address it is asking for a usr and pass. you didnt mention any user or pw that i noticed other than "mrdiy.ca" . can you share the usr and pw to connect to it once on the network. thanks

0
MrDIYLab
MrDIYLab

Reply 1 year ago

Yes, the username is "admin" and the password is the same as the AP's password (mrdiy.ca if you didn't change it).

0
mr.botche
mr.botche

Reply 1 year ago

perfect i got it working, great project! is there any way to still use the other pins on the d1mini maybe for a sensor or light?

0
MrDIYLab
MrDIYLab

Reply 1 year ago

Great!

No, not with the bin file. But you can always download the source code and add any extra functionality you like. All other PINs are available for IO.

By the way, I have been getting reports that someone people when they restart the device, it asks them again to go through the setup. Are you having this issue as well?

0
mr.botche
mr.botche

Reply 1 year ago

No, i am not having that issue. However it does play the initial connection sound quite often roughly every 5-10 mins.

I will try to set the other io pins for a light or motion sensor. And try to change the voice.

0
aspork42
aspork42

1 year ago

Thanks for posting - this is /exactly/ what I was wanting to create to add audible notifications on my home automation system. I posted a few notes in the GitLab page.

Tested and working on Adafruit Huzzah.

IMG_9597.jpeg
0
MrDIYLab
MrDIYLab

Reply 1 year ago

Thank you! I will look into those.