View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

Discover how to create your own Walkie Talkie using an ESP32, I2S microphones, and a 3W amplifier board with this step-by-step guide. Explore code, schematics, and more to customize your Walkie Talkie project!

Related Content
Transcript

[0:24] Hey Everyone!
[0:25] We’ve made a Walkie Talkie based around the ESP32!
[0:29] There’s a link in the description to the Fusion360 project

[0:33] and the STL files for the case - so feel free to print your own version if you want to.
[0:38] Let’s have at what’s inside and see how it works.
[0:42] We have the microphone - I’ve made space for my own ICS-43434 breakout board
[0:49] and space for the popular INMP441 microphone board.
[0:54] These are both I2S microphones that interface directly with the ESP32.
[1:00] Above the microphone, we have an I2S 3W amplifier board

[1:04] that’s powering our speaker. This also directly interfaces with the ESP32.
[1:11] We have our ESP32 board - I’m using a TinyPICO here,
[1:16] but you should be able to use any generic ESP32 dev board
[1:19] we’re not using any special features in this project.
[1:23] We’ve got a push-button switch for controlling transmission.
[1:27] We’ve got a simple slider switch to turn the battery on and off.
[1:31] You may have noticed that I’m using a custom PCB - I got this made up by the great people

[1:36] at PCBWay - as usual, they did a great job and I’m really pleased with how the boards have come out.
[1:41] I’ve got a lot of audio projects and it’s really nice to be able to just plug things together

[1:46] and not to have to worry about wires going everywhere.
[1:49] The only slight omission I’ve made is not breaking out the remaining GPIO pins - so I think I’ll do that in version 2 of the board.
[1:57] I’ve included a link to both the schematic and the project on PCBWay in case you want to order your own version.
[2:04] You can also clone the project on EasyEDA and customise it as needed.
[2:09] Having said that, you really don’t need a PCB, you can easily just connect everything

[2:14] up on breadboard - and that’s exactly what I did when I was prototyping.
[2:19] The schematic is very simple - we’re using I2S boards for both the microphone and

[2:24] the speaker which makes the wiring up of these to the ESP32 very straightforward.
[2:30] You can of course modify the code to use the built-in ADC for input and the built-in DAC

[2:36] for output. Very handy if you want to use analogue microphone boards and a headphone jack for output.
[2:43] I’ve added a bit of extra circuitry to my board to create a clean power supply for the microphones.

[2:49] If you watch some of my earlier videos then you’ll recall that we

[2:52] were picking up quite a lot of noise on the microphones when using WiFi.
[3:09] To fix this noise problem we are creating a clean 3.3v power supply for the microphones

[3:15] we do this by taking a direct feed from the battery, we filter this with an LC filter and then

[3:21] pass this to a Low Drop Out regulator. This gives us a really nice and clean

[3:25] power supply for the microphones which removes a lot of the noise issues.
[3:42] I’ve got quite a few videos on audio input and output which you might find

[3:46] interesting - I’ve linked to the playlist in the description.
[3:49] That’s really all there is on the hardware side of things.
[3:52] How does it actually work?
[3:55] All the code is on GitHub - the link is in the description - it should be

[3:59] mostly self-explanatory, but I’ll give a high-level overview here.
[4:04] The main challenge with this project

[4:06] is how to get the audio broadcast from one walkie-talkie to all the other walkie-talkies.
[4:11] I’ve implemented this in two different ways. You

[4:14] can easily switch between these in the code with a simple #define.
[4:18] The first way is using UDP broadcast.

[4:22] UDP broadcast is a very simple mechanism. You send a UDP packet to a special IP address and

[4:28] your router broadcasts this packet to all the other devices on your network.
[4:33] We can safely send up to 1436 bytes in a UDP packet

[4:38] so if we’re sampling at 16KHz and using 8-bit samples that’s around 90ms of audio data.

[4:46] So we need to send around 11 packets per second. This is well within the capabilities of the ESP32.
[4:54] The big advantage of using broadcast UDP is that we don’t need to know about our peers,

[5:00] we can just broadcast a message and anyone who is listening for it will receive it. We also don’t

[5:05] need a centralised server that everything connects to. All the heavy lifting is done by the router.
[5:11] However, there are some disadvantages of UDP that we should be aware of.
[5:16] Delivery of UDP packets is only best effort - there is

[5:20] no guarantee that someone will receive the packet you send.
[5:24] There is also no guarantee of packet ordering - someone

[5:28] may receive the packets you have sent in a completely random order.
[5:32] For this project, I’ve chosen to ignore these two issues.

[5:36] With broadcast packets, we’re generally staying in the same network

[5:39] so we probably won’t lose too many packets and our packets will probably also come in

[5:44] the correct order. If they don’t then we’ll just get a bit of noise and distortion on the audio.
[5:50] The other big advantage of UDP broadcast is that you can receive

[5:54] the packets on your desktop computer or even your phone - so it would be quite

[5:58] easy to create additional clients that are not based on the ESP32.
[6:03] The second way I’ve implemented the transport is to use ESP-NOW.
[6:08] ESP-NOW is a protocol developed by Esppresif which enables multiple

[6:12] ESP devices to communicate with each other without needing WiFi.
[6:17] This gives us one great advantage over the UDP option

[6:20] in that we don’t need a WiFi network to make our Walkie-Talkie work.
[6:24] So you could use the Walkie-Talkie outside.
[6:27] The disadvantage with ESP-NOW is that it has a much smaller packet size of 250 bytes.

[6:34] This means that we need to be sending packets 64 times a second.
[6:38] We also have all the same downsides as UDP broadcast - packet delivery is best effort

[6:44] and there is no guarantee what order the packets will arrive in.
[6:48] However, in my tests, it seems to have performed reasonably well.
[6:53] With the transport problem solved we just need to hook everything up.
[6:57] We have the I2S input - this reads samples from the microphone and passes them to our transport.
[7:04] Once the transport has accumulated enough data to fill a packet

[7:07] it sends the data through either UDP or ESP-NOW.
[7:12] On the other side, we have the same transport listening for packets.

[7:16] Every time a packet is received it queues the data up for playing

[7:20] via our I2S output. The I2S output just pushes samples out to the I2S amplifier.
[7:28] To allow for packets taking slightly longer to arrive we have a buffer

[7:31] between the transport and the I2S output. We let a small amount of time elapse before

[7:37] we start playing the samples - this gives us some spare time to allow for packet jitter.

[7:42] It does come at the cost of some latency in the audio - with everything taken into account using UDP the

[7:49] audio is played about half a second after it was made.
[7:53] All in all though the project works. Quality is not amazing,

[7:57] but it’s certainly sufficient for a hobby project.
[8:00] And sounds like a fairly low-quality Walkie-Talkie
[8:05] As always, the code is all on GitHub. Let me know what you think in the comments.

[8:09] And if you have any improvements then please open up a pull request.
[8:13] Some ideas that would be good to look at:
[8:16] Compression of the audio to reduce bandwidth.
[8:20] Some kind of Automatic Gain Control
[8:22] Echo cancellation so we can have full-duplex
[8:26] And I’m sure there’s much much more that can be improved.
[8:29] So feel free to hack away!
[8:33] So that’s it for this video.
[8:35] I hope you enjoyed it. I certainly enjoyed making it.
[8:38] And if you did enjoy it please hit the subscribe button. There are more videos coming soon.
[8:43] So I’ll see you in the next video!


HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts