When the cupboard paper is opened, it should play a song

Hello everyone. I have a small question for you experienced Arduino users. I have never used Arduino before, so I don't have any knowledge about it. However, I need to accomplish a task. Imagine a cupboard as shown in the photo below. When I open the cupboard door, I want selected music to start playing. The music should stop when the door is closed, and when I open the door again, the music should resume playing.

I don't want to use a sound bomb for this. The music should play from a computer. From what I have learned, there's a device called ESP that can connect to a computer via Wi-Fi.

In short, there should be a distance sensor or switch in the cupboard, which will connect to the ESP. From there, it will connect to the computer and play the selected songs using ready-made code.

I apologize for my limited technical knowledge and poor English. I would greatly appreciate it if you could help me. Wishing you all a good day.

Do you already have a specific computer in mind? Otherwise, this would be trivial with a Raspberry Pi. As in, it would probably take less than 5 minutes.

I don't know what a "sound bomb" is, but there are many ways to do this. e.g., using a DF Robot MP3 player

If you don't want to use a Pi, and have to use a PC, then you could use a cheap arduino clone to sense the door opening and send a message to the PC via USB. Likewise, you can do it wirelessly with the ESP32 like you said, but that is more complex.

1 Like

First of all, thank you for your interest.
I live in Turkey, and using a Raspberry Pi for the project I want to do is quite expensive. I want to use the computer in my own store for this job. The thing I referred to as a "sound bomb" is actually a "Bluetooth Wireless Speaker".
Later on, what you wrote starts to give me some ideas, but since I'm not knowledgeable in this area, I couldn't fully understand. Can you explain step by step, how to use an Arduino clone and the DF Robot MP3 for this project?

No. This is not the kind of thing that can be explained step by step without having background knowledge. You will need to learn how to use arduino, and at that time any specific questions you have can be answered.

The DF Robot player plays MP3 files. It can be connected to an arduino, or you can play audio files simply by connecting switches to it. If you go to the DF Robot website, there are diagrams and connection instructions.

To do this with an arduino and a PC is more involved and if you don't have a programming background you will probably have a fairly steep learning curve.

1 Like

OK, I've read your post and all the comments. Let me present you with some options (even though you may have covered it) in the interest of perhaps giving you more ideas.

I have plenty of experience in Arduino and specifically with DFRobotPlayer Mini (i'll explain this in a little bit).
I'm an I.T. Engineer and have done electronics since the 70's
I have also worked in Hospitality for 20 years so i understand what you need (it looks like you have convenience store or bottle shop)

First we need to understand a few things

  • You have a fridge with a door , When the door opens the sound needs to play,
    when the door closes the sound needs to stop but ready to replay when it opens again.

  • You're also a business so perhaps consider going to the section on this forum where you hire someone for a small fee to get this done for you
    Jobs and Paid Consultancy

  • Don't over complicate this, it's actually very simple
    Visualize it as a musical birthday card.
    Basically there is a circuit, it has power, there is a speaker connected to it,
    there is a sound file and a reed switch or some sort of switch or sensor (kind of like
    those spring back push button (Non Latching) switches that you find in alarm boxes when you open the door )
    The switch basically sends a signal of High resistance or Low Resistance to the circuit and sketch, so basically you are sensing HIGH or LOW condition and based on that condition you will tell the sketch (The Code) to play the file or stop the file playing.

  • You first need to decide where everything will be physically.

    • Obviously the sensor / Switch has to be attached between the door frame and the fridge so when the weight of the door hits the sensor the condition is triggered.
      you could also get a bit more complicated with this and use an Arduino Ultrasonic sensor and the condition would be when it's below a certain distance (Just a thought).

    • Then you need to consider where the Arduino will physically be.
      so are going to have a switch in the fridge them a big long wire to a development board in the office approx 20metres away or will the arduino be in the fridge in the back or perhaps in a kit box outside the fridge on the back in which case maybe a wire of 3metres would be sufficient

    • You now need to figure out where your speaker will be .
      You may have in-store speakers (bluetooth) that you wish to use (which you have stated you don't want to do ) or you may put the speaker on the fridge directly , likely near the Arduino

  • Another consideration, Arduino is probably not the best option for Audio Applications in the first place. i once built a project for a client that was an Audio Wedding Guestbook, Arduino proved to be insufficient and i used a Teensy (TeensyDuino) instead. in saying that you mentioned "ESP"

  • ESP is called Espressif systems, it's called E.S.P.32 Wroom (it supports Wifi, Bluetooth, Internet connectivity and a lot of other things, Look it up.
    Now this Dev. Board has a higher processing speed and would suit audio applications

  • now you said you want to play the sound file from a computer.
    Ok, so explain the logic of that to me .
    so there is an ESP32 board connected to a speaker on the back of a fridge, with a sketch in it that works.

  • Now the ESP32 can't play that file on it's own, it needs a media player to read from.
    As another member suggested it would be much easier for you to use a Raspberry Pi
    which can store the file and play it , thus eliminating the computer.

  • Now let's talk about DFRobotPlayer for a second
    This is a tiny circuit board that is basically a basic Hardware media Player
    it has the ability without the arduino or ESP32 to do basic things like play a file on power up or jump to a next file

see this you tube video

So as an idea, You could use this on it's own , create a basic circuit on a prototype board,
put it in a kit box. and have the door switch on the Positive Power line thus when the power is received it starts up and plays
or.. if you wanted multiple files you could have a constant power supply but have the switch in-series with the "NEXT" I/O button.

But as the other forum member said

  • No one here is going to do this for you completely
    • You have to either put the work in (and this is not really a lot of work in the first place)
    • You have to hire someone to do the job for you

Reality is, i have absolutely given you more than the answer that you need here to build this yourself (assuming you have basic electronics knowledge), and then i have gone above and beyond (ask anyone on this forum if that's true).
So realistically you now need to make a choice

Choice 1 - You're going to reach out to a forum member and pay them for the job

Choice 2 - You're going to put in some effort and when you get stuck you come back here and ask questions but show that you're putting work into it and you'll get help

Choice 3 - You're going to use the information i've given you to complete the project on your own completely

also remember that in order to keep things simple, even though ESP32 does have 2 cores you don't need to necessarily use them both, anything you can run single core on Arduino can run on ESP32
but also understand that the option where you have a file on your computer
and you're expecting the ESP32 to read that file is not very practical because

  • The computers hard drive uses NTFS or GUID Partitions, (The dev board only supports FAT32)
  • The computer has a file structure that must be adhered to but in your computer the file is probably somewhere like
    c:\Users\User\My Music\Another folder\yourfile is probably here.mp3
    (that's not gonna work)
    and even then your computer needs a WiFi network adapter
    it needs to be connected to a WiFi Capable router
    then you have Software Permissions and Antivirus and firewalls possibly blocking the Dev Board... Seriously, what you're doing is like..
    Living in Australia wanting to get a hair cut and you take a trip to turkey to have your head cut off, instead of just going to the local barber shop

My advice...
Use DFRobot Player on it's own with a 5V Power supply , hooked up to local speaker and switch
or Integrate ESP32 with it
it's not that hard, but again if you have no experience you need to show the appropriate courtesy in order for people to help you for free
FYI - I'm also a business owner of 27 years and i charge approx $320 per hour and here i am giving back to the community for free, ok
that's just how it works mate, there are no free rides and if you don't know electronics you need to show effort or pay someone if you don't want to.

Let me know your thoughts

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.