Using the ESP32 DAC - Voltages, Waveforms & Sounds
Вставка
- Опубліковано 29 тра 2024
- Oscilloscope Art, Musical Fruit - just a few of the things we’ll build with the ESP32’s built-in DAC (Digital to Analog Converter)!
Article with code: dronebotworkshop.com/esp32-dac
More articles and tutorials: dronebotworkshop.com
Join the conversation on the forum: forum.dronebotworkshop.com
Subscribe to the newsletter and stay in touch: dronebotworkshop.com/subscribe/
One of the lesser known features of the ESP32 is that it has two Digital to Analog Converters, or DAC’s, as part of its architecture. Today we will see how to use them.
The ESP32 DACs are not audio-quality by any means (use I2S for that) but still very useful for producing DC voltages and complex waveforms. We’ll see how they work and how they can be used in three different modes.
We’ll do several experiments using a multimeter, an oscilloscope, and an audio amplifier. If you have the test equipment, you can follow along; everything we are doing today will work on just about any ESP32 module.
After we see how to program the DAC, we'll have a bit of fun with it!
First, we will create some “Oscilloscope Art.” Calling this "art" is a bit of a stretch; it’s an ellipse rotating on the scope screen, but you can use it as the basis of something much more artistic!
Then we will get creative and build a musical instrument that you can also eat for dessert! We’ll use the DAC and touch switch features of the ESP32 to make music with some apples and oranges!
Here is the Table of Contents for today's video:
00:00 - Introduction
01:50 - ESP32 DAC
05:59 - Hookup and DC Voltages
10:14 - Waveform Hookup and Sine Wave (Basic)
13:20 - Waveform using a Table
15:46 - Cosine Wave using a Library
19:59 - Oscilloscope Art
25:09 - Musical Fruit
32:09 - Conclusion
33:43 - Bonus - Mozart!
Hope you enjoy the video! For those who are willing to stick it out until the end, there is a second musical serenade at the conclusion of the video. - Навчання та стиль
Hi everyone - It's come to my attention that there has been someone masquerading as myself, responding to some comments here with a link to a Telegram chat to win a prize from me. THIS IS A SCAM, I am not holding a contest, nor do I have a Telegram account. PLEASE DO NOT RESPOND TO THESE MESSAGES!!
It's happening on a lot of my videos, I'm taking steps to remove them manually, but as I have 162 videos, it will take some time. If you do run across a suspicious comment, I would appreciate you letting me know at info@dronebotworkshop.com.
Thanks!
Bill (The real one!)
Its always a good day when Bill releases a new video. Hey Bill! Hope you're doing well sir
He ate his synth
The miscommunication line was the funniest thing I had heard all day. Granted my day is less than 2 hours old.
I'm still amazed by the quality of these videos. As usual, excellent work.
Terrific tutorial! Thanks for the insights to the DAC! Best wishes!
I hope you had a great "holiday season" and that the new year is being good to you so far. Stay happy and healthy!
Look forward to seeing more this year.
As always, an excellent tutorial video. Thank you very much.
Thanks you very much for another great tutorial! Happy 2023 to you and your followers!
Hi Bill, hope you had an excellent holiday season! Thank you for this in depth look at the ESP32 DACs
Hope you had a good holiday Bill. Thanks for the new video- very useful.
Excellent video. A little note: the speaker (before the use of potentiometer) is always in saturaton, so the emitted sound is that of a sinusoid clipped
What a lucky day, I have been waiting for a new vide,plus I'm interested in the esp32 more than anything these days and I have been looking for a use of it's DAC , so this is by definition the perfect video for me
As always, an excellent presentation of hi-value info.
The Applesauce comment had me chuckling for several seconds.
We’re on the same wavelength today! I’m welcome in your workshop!
Just about to fire mine up and play along at home.
thanks for putting all the hard work into your presentation.
Excellent video on the not well exploited DAC feature, thanks!
@32:07 Informative and joyful at the same time.. keep going Bill.. your videos are amazingly good.. 👏👍😍
I found your channel and from the few videos I have viewed on ESP32 I am impressed with the easy to follow. I manufacture wireless radio controlled LED fixtures. My goto processor is the PIC and its a great platform but I want to share our technology with the DIY community and the ESP32 looks like a better fit for most DIY. my products use radios, sd card, flash, ram and OLED display all of which I will have to learn to use with the ESP32. Thank you
Very good one. Informative, educational and entertaining.
Thanks Bill, another great video
Just one thing, the art forms or patterns on the oscilloscope are called Lisajou Patterns. Look them up online. They were also used for teletype mark/space alignment.
very good, love the fruit piano!
Great video about the esp32 thanks for the information
Great esp32 dac video!
Great, really very helpful videos, thank's
That oscilloscope art makes me creazy. Looking at it, it sometimes turns left and a blink later, it turns right. It makes me crazy!!! :)
very nice présentation ! very well done and cover every aspect.
Very good video , as usual.
New vid! I have some of those boards but have not delved into them yet.
The DAC on the ESP32 might not be high end audio quality, but I used it just over a year ago to create a little device as a joke for my new electric car....
I stuck the ESP32 inside an old set of USB powered (but analog input) computer speakers, and had it play the old clip from The Simpsons where they saw the electric cars or tomorrow... "Hello. I'm an electric car. I can't go very fast, or very far. And if you drive me, people will think you're gayyyy".
Shoved the speakers into the glovebox, ran the USB power cable out to a standard USB phone charger cigarette lighter socket adaptor, and it would play the clip when you start the car up....
Several hours of fiddling with electronics and libraries and stuff for a 20 second joke for when my brother visited for Christmas 🤣
Good information = thank you.
Superb video 😍
Very well done
You are so sweet. Thank you for your outstanding performances.❤
Wow, this is a great video Bill, thanks for the time and energy you put into teaching. The ESP32 is an amazing little board and I love it. Q) have you ever done any work with the maple board? I purchased 20 of them some years back and not much luck with them and my Linux home! Thanks again ❤
Today I got "shocked" by the electricity bill - but the same day another Bill video! Thanks!
Nice project!
amazing channel, here working on music and uCs
Again an amazing video, I will probably try to make this fruity keyboard myself in the future 😀
Sir, I have been waiting for you ❤
Due to a miscommunication the McIntosh were cut from the video LOL!
I have a lot of evil musician ideas now! Another great video!!
Excellent video sir.Thanks you very much for another great tutorial.If possible, make a video on how to make an MPPT solar charger using ESP32. Thanks.
Good fun, thanks! Now I love fruity music. :)
Good ideas 💡
Fantastic video! Can you do one demonstrating TDM?
hey bill very nice .... god bless u..
I'll never see my Candy Apple Red Gibson Guitar the same! I'll have to be careful when I am plucking the strings with my teeth! 🤣 🍏🎸 At the end I had my lighter lit and in the air and I was swaying back and forth! Bravo! 🍎🟠 🤘😂
Great video. Can you do a video of how to control the DAC voltage output with a rotary encoder.
Bill, how about doing a video on the various ESP32's, since it's so confusing on which one to purchase!
Do you mean the chips now that there's different flavours, or do you mean the different types of development boards?
@@tin2001 - Which chip does what?
If you ever want to see a mechanical version of a DAC just find a video on how a IBM Selectric Typewriter works, it's the DAC that rotate and tilt's the ball with the letters on it.
Like this from Kenya
Commenting for the algorithm, cheers!
Great video!
You mentioned that a DAC can be used as a digital potentiometer. Where can one find more details on how to do that?
Great work as always.... I wish you need to make videos without having even a little amount of tension in your face... Be happy and confident about yourself... Don't try to be 100% perfect... That makes you to be more tensed 😊
could you use a microphone as an adc input ,record the outputs from the microphone, and replay it thru the speakers via dac?
Excellent tutorial on what the ESP32 DAC can do, however, I have been looking everywhere for a way to build a high quality music player without I2S (your I2S video was awesome) considering the ESP32 is the only hobbyist microcontroller with I2S support. They have been building great sounding CD players, for example, since the early 80s and since modern microcontrollers are so much better than what they had available then, there must be a way to do this.
The RP2040 also has I2S support with PIO, RE: hobbyist microcontrollers. In fact, you could even do a bunch of channels on one if you wanted to.
so is the fruit project can be done with the development board version of the esp 32 cause i m confused
Sir please release video on remote sensing using aurduino....means how we can drive motor through remote.......Your videos are very informative sir. LOVE FROM INDIA
At 9:13 into the video, you mention not using an external reference. I was hoping the esp32 would allow that but the datasheet says the reference can only be the power supply voltage. That is regrettable. I was hoping you were right since I need an 8 volt reference. Nice video nonetheless. You put a lot effort into it. It is appreciated!
Enjoyed the applesauce
At 12:13 What is the logic behind the int value of 128 + 64*sin(deg*(pi/180)). I mean what is the significance of 128 and 64? Is 128 the base value of sine wave and 128+64 the max value. So 64 is the amplitude. If that is the case can we not start at 0?
I have a question. Does the Musical Fruits also need an oscilloscope? Thanks!
good job! my compiling for ESP32 S3 got ERROR: undefined reference to `dacWrite' , how can fix that? thanks.
we missed you Bill
Orange you glad you watched this video? He took a byte out of his project! That was a real Apple computer! 🤣🤣🤣
Interesting how when you play the sinusoidal waves through the speaker in the first experiments, it still sounds sawtoothy. Is that a limitation of the speaker, the amp, or the signal generated from the ESP32?
Yes. Sounds to me as though it is clipping.
Funny, I was just thinking about using esp32 for vinyl player repairs.
is possible the dac was destroyed or something interfere because i canot more get variable output using dacwrite(17,150);
strangely it randomly vary from 3.4v to 4v instead of 3.3v
i tryed to get a 1.450V for adc potentiometer as recommanded for best accuracy
Ironically, no Adafruit libraries were used in the DroneBot Workshop Orchestra project ;)
Haven't heard from Music by Moose-Art before.
HI SIR WE NEED TO HAVE OUTPUT OF 2 DAC OUTPUT TO ACTIVATE 25 &26 PIN OF ESP32 TO PLAY THE TWO DIFF AUDIO SIGNALS PLEASE HELP ME IN THIS SEGANEL
Hmmmm.... As I watched this and got to the sine wave experiment, I wondered if an ESP32 could be used to convert a "modified sine wave" inverter (12V to 120VAC) to a "Pure sine wave" inverter (12V to 120VAC)
I've seen some videos of this conversion, but they've usually built a circuit to produce a true sine wave.
For those who are unfamiliar with inverters, they come in 2 types (basically). A "modified" sine and pure sine wave.
The "Modified" sine is actually a very messy square wave that tries to appear like a stair step square wave.
The Pure sine wave inverter produces a very stable, solid and true sine wave. This is what one needs to power most equipment.
Sadly, many if not most people get fooled by "modified sine" thinking that it's a sine wave and ok for sensitive equipment. IT IS NOT!
So there have been those out there who have come up with modifications to these cheap ModSine devices to remove the garbage wave generator and replace it with a pure, proper, 60Hz sine wave.
So now, seeing this ESP32 in action and producing such a clean sine wave, I wonder how difficult it would be to use these to mod one of those inverters.
I have several inverters. My 2 main ones are pure sine, while one that I keep in the car for emergencies, is a modified sine. I actually don't use it due to the damage it can cause to electronics.
Hmmm...
Musical fruit and no baked beans!
cool one question( Now) background music i hear so many in youtube. i notice different. with your voice. NOw now now XD software? where come from.
Gpo pin how work over 20 to 30 . which object can swap in apple? bio cell and electron mate sensor or fiber can touch?
SIR PLS MAKE A VIDEO ON AS5600 MAGNETIC ENCODER WITHOUT USING THE LIBRARY
I stopped playing piano because I always get hungry after a session. Now I know I just need to trade in the Yamaha for a Granny Smith.
Probably could have used beans for the "Musical Fruit" segment 🤭
DAC doesn't work when wifi is on (at least on my esp32-cam)
Where's DB1? We miss her :(
…and eat at last, hahaha
13:00 at 86hz it sounds like a trimmer 🤣. If anyone wants to simulate trimmer sound just play a sine wave at 86 hz.
mmm edible instrument
Third 🥉
Second
First 😀
I see you removed part of my comment so I removed the entire thing and unsubscribed.... all the info I need is on the website I linked to so I won't be needing the help of your haphazard videos after all.
Omg, still using that embarrassing music
Synchronous. Sin-kron-us. There is no 'i' or 'i' sound in there.